mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
chore: add roleTransactions tests
This commit is contained in:
parent
67aa15e006
commit
53f5b97afd
1 changed files with 25 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
|||
import { RoleTransaction, TransactionType } from '@roleypoly/types';
|
||||
import { makeRoleTransactions } from './roleTransactions';
|
||||
|
||||
it('creates a transactional diff of two sets of roles', () => {
|
||||
const currentRoles = ['aaa', 'bbb', 'ccc', 'ddd'];
|
||||
const nextRoles = ['bbb', 'ccc', 'ddd', 'eee', 'fff']; // removes aaa, adds eee + fff
|
||||
|
||||
const transactions = makeRoleTransactions(currentRoles, nextRoles);
|
||||
expect(transactions).toEqual(
|
||||
expect.arrayContaining<RoleTransaction>([
|
||||
{
|
||||
id: 'aaa',
|
||||
action: TransactionType.Remove,
|
||||
},
|
||||
{
|
||||
id: 'fff',
|
||||
action: TransactionType.Add,
|
||||
},
|
||||
{
|
||||
id: 'eee',
|
||||
action: TransactionType.Add,
|
||||
},
|
||||
])
|
||||
);
|
||||
});
|
Loading…
Add table
Reference in a new issue