This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gina Contrino
committed
Oct 19, 2017
1 parent
154eae2
commit a9fc68e
Showing
14 changed files
with
246 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import actionTypes from '../../constants/actions'; | ||
import { socketSetup } from '../../utils/socket'; | ||
|
||
const socketMiddleware = store => ( | ||
next => (action) => { | ||
switch (action.type) { | ||
case actionTypes.accountLoggedIn: | ||
socketSetup(store, action); | ||
break; | ||
default: break; | ||
} | ||
next(action); | ||
}); | ||
|
||
export default socketMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect } from 'chai'; | ||
import { spy, stub } from 'sinon'; | ||
import middleware from './socket'; | ||
import * as socket from '../../utils/socket'; | ||
import actionTypes from '../../constants/actions'; | ||
|
||
describe('Socket middleware', () => { | ||
let store; | ||
let next; | ||
let socketSetup; | ||
|
||
beforeEach(() => { | ||
next = spy(); | ||
store = stub(); | ||
}); | ||
|
||
it('should call socketSetup when metronome is initialized', () => { | ||
socketSetup = stub(socket, 'socketSetup'); | ||
|
||
middleware(store)(next)({ type: actionTypes.accountLoggedIn }); | ||
expect(socketSetup).to.have.been.calledWith(); | ||
socketSetup.reset(); | ||
}); | ||
|
||
it('should passes the action to next middleware', () => { | ||
const expectedAction = { | ||
type: actionTypes.accountLoggedIn, | ||
}; | ||
middleware(store)(next)(expectedAction); | ||
expect(next).to.have.been.calledWith(); | ||
}); | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.