Skip to content

Commit

Permalink
adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Jul 30, 2020
1 parent cf4e54d commit 9b65057
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
entryHasListType,
entryHasNonEcsType,
prepareExceptionItemsForBulkClose,
lowercaseHashValues,
} from './helpers';
import { EmptyEntry } from './types';
import {
Expand Down Expand Up @@ -663,4 +664,48 @@ describe('Exception helpers', () => {
expect(result).toEqual(expected);
});
});

describe('#lowercaseHashValues', () => {
test('it should return an empty array with an empty array', () => {
const payload: ExceptionListItemSchema[] = [];
const result = lowercaseHashValues(payload);
expect(result).toEqual([]);
});

test('it should return all list items with entry hashes lowercased', () => {
const payload = [
{
...getExceptionListItemSchemaMock(),
entries: [{ field: 'user.hash', type: 'match', value: 'DDDFFF' }] as EntriesArray,
},
{
...getExceptionListItemSchemaMock(),
entries: [{ field: 'user.hash', type: 'match', value: 'aaabbb' }] as EntriesArray,
},
{
...getExceptionListItemSchemaMock(),
entries: [
{ field: 'user.hash', type: 'match_any', value: ['aaabbb', 'DDDFFF'] },
] as EntriesArray,
},
];
const result = lowercaseHashValues(payload);
expect(result).toEqual([
{
...getExceptionListItemSchemaMock(),
entries: [{ field: 'user.hash', type: 'match', value: 'dddfff' }] as EntriesArray,
},
{
...getExceptionListItemSchemaMock(),
entries: [{ field: 'user.hash', type: 'match', value: 'aaabbb' }] as EntriesArray,
},
{
...getExceptionListItemSchemaMock(),
entries: [
{ field: 'user.hash', type: 'match_any', value: ['aaabbb', 'dddfff'] },
] as EntriesArray,
},
]);
});
});
});

0 comments on commit 9b65057

Please sign in to comment.