2020-08-12 00:15:16 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
2020-08-29 05:18:35 +00:00
|
|
|
import { resolveProject } from '../src/resolve';
|
2020-08-12 00:15:16 +00:00
|
|
|
import { TEST_CASES } from './resolve/cases';
|
|
|
|
|
2020-08-29 15:33:30 +00:00
|
|
|
const TEST_LABELS = ['bar', 'foo'];
|
2020-08-15 14:31:28 +00:00
|
|
|
|
2020-08-12 00:15:16 +00:00
|
|
|
describe('resolve labels', () => {
|
2020-08-15 14:31:28 +00:00
|
|
|
describe('with empty rule set', () => {
|
|
|
|
it('should return the existing labels', () => {
|
2020-08-29 05:18:35 +00:00
|
|
|
const result = resolveProject({
|
2020-08-15 14:31:28 +00:00
|
|
|
flags: [],
|
2020-08-31 04:29:17 +00:00
|
|
|
initial: [],
|
2020-08-15 14:31:28 +00:00
|
|
|
labels: TEST_LABELS,
|
|
|
|
states: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result.labels).to.deep.equal(TEST_LABELS);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not make any changes', () => {
|
2020-08-29 05:18:35 +00:00
|
|
|
const result = resolveProject({
|
2020-08-15 14:31:28 +00:00
|
|
|
flags: [],
|
2020-08-31 04:29:17 +00:00
|
|
|
initial: [],
|
2020-08-15 14:31:28 +00:00
|
|
|
labels: TEST_LABELS,
|
|
|
|
states: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result.changes.length).to.equal(0);
|
|
|
|
});
|
|
|
|
});
|
2020-08-12 00:15:16 +00:00
|
|
|
|
2020-08-31 04:29:17 +00:00
|
|
|
describe('with empty labels', () => {
|
|
|
|
it('should return initial labels', () => {
|
|
|
|
const initial = ['bar', 'foo'];
|
|
|
|
const result = resolveProject({
|
|
|
|
flags: [],
|
|
|
|
initial,
|
|
|
|
labels: [],
|
|
|
|
states: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result.labels).to.deep.equal(initial);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-12 00:15:16 +00:00
|
|
|
// procedural tests
|
|
|
|
describe('resolver test cases', () => {
|
|
|
|
for (const test of TEST_CASES) {
|
|
|
|
it(`should resolve ${test.name}`, () => {
|
2020-08-29 05:18:35 +00:00
|
|
|
const actualResult = resolveProject(test.input);
|
2020-08-29 07:16:53 +00:00
|
|
|
expect(actualResult).to.deep.include(test.result);
|
2020-08-12 00:15:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|