Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
[KFI]test(Login): Add tests for testing the new login buffer action a…
Browse files Browse the repository at this point in the history
…nd epic
  • Loading branch information
herflis committed Sep 22, 2017
1 parent 387f687 commit 52cd433
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
14 changes: 12 additions & 2 deletions test/ActionsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,12 @@ describe('Actions', () => {
expect(Actions.UserLogin('alba', 'alba')).to.deep.equal(expectedAction)
});
it('should create an action to a user login success', () => {
const user = Content.Create({ Name: 'alba' }, ContentTypes.User, repo)
const expectedAction = {
type: 'USER_LOGIN_SUCCESS',
response: true
response: user
}
expect(Actions.UserLoginSuccess(true)).to.deep.equal(expectedAction)
expect(Actions.UserLoginSuccess(user)).to.deep.equal(expectedAction)
});
it('should create an action to a user login failure', () => {
const expectedAction = {
Expand All @@ -496,6 +497,15 @@ describe('Actions', () => {
expect(Actions.UserLoginFailure({ message: 'The username or the password is not valid!', status: 403 })).to.deep.equal(expectedAction)
});
});
describe('UserLoginBuffer', () => {
it('should create an action to a user login buffering', () => {
const expectedAction = {
type: 'USER_LOGIN_BUFFER',
response: true
}
expect(Actions.UserLoginBuffer(true)).to.deep.equal(expectedAction)
});
});
describe('UserLogout', () => {
it('should create an action to a user logout request', () => {
const expectedAction = {
Expand Down
21 changes: 20 additions & 1 deletion test/EpicsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ describe('Epics', () => {
response: user
},
{ type: 'CHECK_LOGIN_STATE_REQUEST' },
{ type: 'USER_LOGIN_SUCCESS', response: 2 }]);
{ type: 'USER_LOGIN_BUFFER', response: true }]);
})
it('handles an error', () => {
(repo.Authentication as Mocks.MockAuthService).stateSubject.next(Authentication.LoginState.Unauthenticated);
Expand Down Expand Up @@ -724,4 +724,23 @@ describe('Epics', () => {
{ type: 'LOAD_CONTENT_ACTIONS_FAILURE', error: 'error' }]);
})
});
describe('userLoginBufferEpic Epic', () => {
let store;
const epicMiddleware = createEpicMiddleware(Epics.userLoginBufferEpic, { dependencies: { repository: repo } });
const mockStore = configureMockStore([epicMiddleware]);

before(() => {
store = mockStore();
});

after(() => {
epicMiddleware.replaceEpic(Epics.userLoginBufferEpic);
});
it('handles the success', () => {
store.dispatch({ type: 'USER_LOGIN_BUFFER', response: true });
console.log(store.getActions())
expect(store.getActions()).to.be.deep.eq(
[ { type: 'USER_LOGIN_BUFFER', response: true } ]);
})
})
});

0 comments on commit 52cd433

Please sign in to comment.