Start implementing backends and authentication
This commit is contained in:
40
test/reducers/auth.spec.js
Normal file
40
test/reducers/auth.spec.js
Normal file
@ -0,0 +1,40 @@
|
||||
import expect from 'expect';
|
||||
import Immutable from 'immutable';
|
||||
import { authenticating, authenticate, authError } from '../../src/actions/auth';
|
||||
import { auth } from '../../src/reducers/auth';
|
||||
|
||||
describe('auth', () => {
|
||||
it('should handle an empty state', () => {
|
||||
expect(
|
||||
auth(undefined, {})
|
||||
).toEqual(
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle an authentication request', () => {
|
||||
expect(
|
||||
auth(undefined, authenticating())
|
||||
).toEqual(
|
||||
Immutable.Map({isFetching: true})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle authentication', () => {
|
||||
expect(
|
||||
auth(undefined, authenticate({email: 'joe@example.com'}))
|
||||
).toEqual(
|
||||
Immutable.fromJS({user: {email: 'joe@example.com'}})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle an authentication error', () => {
|
||||
expect(
|
||||
auth(undefined, authError(new Error('Bad credentials')))
|
||||
).toEqual(
|
||||
Immutable.Map({
|
||||
error: 'Error: Bad credentials'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user