chore: add roleTransactions tests

This commit is contained in:
41666 2021-03-13 04:15:29 -05:00
parent 67aa15e006
commit 53f5b97afd

View file

@ -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,
},
])
);
});