#48: add account sorting

This commit is contained in:
SleepWalker
2016-11-13 14:16:21 +02:00
parent 420ce65392
commit 81a5437be0
2 changed files with 22 additions and 1 deletions

View File

@@ -56,13 +56,26 @@ describe('Accounts reducer', () => {
token: 'newToken'
};
return expect(
expect(
accounts({...initial, available: [outdatedAccount]}, add(updatedAccount)),
'to satisfy', {
available: [updatedAccount]
});
});
it('should sort accounts by username', () => {
const newAccount = {
...account,
id: 2,
username: 'abc'
};
expect(accounts({...initial, available: [account]}, add(newAccount)),
'to satisfy', {
available: [newAccount, account]
});
});
it('throws, when account is invalid', () => {
expect(() => accounts(initial, add()),
'to throw', 'Invalid or empty payload passed for accounts.add');