2015-12-13 04:42:28 +00:00
|
|
|
|
require('chai').should();
|
|
|
|
|
|
|
|
|
|
import userStore from '../../stores/user';
|
|
|
|
|
import data from '../blobs/users';
|
|
|
|
|
|
|
|
|
|
describe('stores/user', () => {
|
2015-12-22 17:46:54 +00:00
|
|
|
|
beforeEach(() => userStore.init(data.users, data.currentUser));
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
|
|
describe('#init', () => {
|
|
|
|
|
it('correctly sets data state', () => {
|
|
|
|
|
userStore.state.users.should.equal(data.users);
|
|
|
|
|
userStore.state.current.should.equal(data.currentUser);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#all', () => {
|
|
|
|
|
it('correctly returns all users', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
|
userStore.all.should.equal(data.users);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#byId', () => {
|
|
|
|
|
it('correctly gets a user by ID', () => {
|
|
|
|
|
userStore.byId(1).should.equal(data.users[0]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#current', () => {
|
|
|
|
|
it('correctly gets the current user', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
|
userStore.current.id.should.equal(1);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly sets the current user', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
|
userStore.current = data.users[1];
|
|
|
|
|
userStore.current.id.should.equal(2);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#setAvatar', () => {
|
|
|
|
|
it('correctly sets the current user’s avatar', () => {
|
|
|
|
|
userStore.setAvatar();
|
2016-03-18 04:45:12 +00:00
|
|
|
|
userStore.current.avatar.should.equal('https://www.gravatar.com/avatar/b9611f1bba1aacbe6f5de5856695a202?s=256');
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly sets a user’s avatar', () => {
|
|
|
|
|
userStore.setAvatar(data.users[1]);
|
|
|
|
|
data.users[1].avatar.should.equal('https://www.gravatar.com/avatar/5024672cfe53f113b746e1923e373058?s=256');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#updateProfile', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
|
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#store', () => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#update', () => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#destroy', () => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|