Start implementing backends and authentication

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 12:31:21 -08:00
parent c60d8ba706
commit 67cdd92bfb
13 changed files with 247 additions and 15 deletions

View 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'
})
);
});
});