1
0
Fork 0
js-utils/test/utils/TestChecklist.ts

48 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-03-29 14:52:40 +00:00
import { expect } from 'chai';
import { Checklist, ChecklistMode } from '../../src/Checklist';
2020-03-29 14:52:40 +00:00
import { describeLeaks, itLeaks } from '../helpers/async';
const EXISTING_ITEM = 'foo';
const MISSING_ITEM = 'bin';
const TEST_DATA = [EXISTING_ITEM, 'bar'];
// tslint:disable:no-duplicate-functions
describeLeaks('checklist', async () => {
describeLeaks('exclude mode', async () => {
itLeaks('should check for present values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(false);
});
itLeaks('should check for missing values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
});
expect(list.check(MISSING_ITEM)).to.equal(true);
});
});
describeLeaks('include mode', async () => {
itLeaks('should check for present values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(true);
});
itLeaks('should check for missing values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
});
expect(list.check(MISSING_ITEM)).to.equal(false);
});
});
});