it('should get components', () => { assert.deepStrictEqual(c.getComponents(), [ expected.r, expected.g, expected.b, ]); });
it('should get sub constraints', () => { const sc1 = new DoubleConstraint(); const sc2 = new DecrementConstraint(); const c = new CompositeConstraint({ constraints: [sc1, sc2], }); assert.deepStrictEqual(c.constraints, [sc1, sc2]); });
it('should convert mixed to color', () => { // tslint:disable:object-literal-sort-keys assert.deepStrictEqual(ColorConverter.fromMixed('#112233').toObject(), { r: 0x11, g: 0x22, b: 0x33, }); assert.deepStrictEqual(ColorConverter.fromMixed('foobar').toObject(), { r: 0, g: 0, b: 0, }); assert.deepStrictEqual(ColorConverter.fromMixed(123).toObject(), { r: 0, g: 0, b: 0, }); });
it('should get list options', () => { const options = [ {text: 'foo', value: 1.41}, {text: 'bar', value: 2.72}, {text: 'baz', value: 3.14}, ]; const c = new ListConstraint({ options: options, }); assert.deepStrictEqual(options, c.options); });
it('should export JSON', () => { const PARAMS = { bar: 'hello', foo: 1, }; const preset = Preset.exportJson([ new Target(PARAMS, 'foo'), new Target(PARAMS, 'bar'), ]); assert.deepStrictEqual(preset, { bar: 'hello', foo: 1, }); });
it('should export inputs as preset', () => { const PARAMS = { bar: 'hello', baz: 2, foo: 1, }; const api = createApi(); api.addInput(PARAMS, 'foo'); api.addInput(PARAMS, 'bar'); api.addMonitor(PARAMS, 'baz', { interval: 0, }); const preset = api.exportPreset(); assert.deepStrictEqual(preset, { bar: 'hello', foo: 1, }); });
it('should import preset', () => { const PARAMS = { bar: 'hello', foo: 1, }; const api = createApi(); api.addInput(PARAMS, 'foo'); api.addInput(PARAMS, 'bar'); api.importPreset({ bar: 'world', foo: 123, }); assert.deepStrictEqual(PARAMS, { bar: 'world', foo: 123, }); });
it('should convert to object', () => { assert.deepStrictEqual(c.toObject(), expected); });
it(`it should parse as ${JSON.stringify(testCase.expected)}`, () => { const actual = ColorParser(testCase.input); assert.deepStrictEqual(actual && actual.toObject(), testCase.expected); });