Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert.equal(inputs[0].checked, true, 'checked0');
// assert if the choice is changed in VM, it is propagated to view
app[chosenProp].push(products[1]);
ctx.scheduler.getRenderTaskQueue().flush();
assert.equal(inputs[0].checked, true, 'checked00');
assert.equal(inputs[1].checked, true, 'checked1');
// assert that when choice is changed from view, it is propagaetd to VM
inputs[0].click();
inputs[2].click();
ctx.scheduler.getRenderTaskQueue().flush();
assert.equal(inputs[2].checked, true, 'checked2');
const actual = app[chosenProp].sort((pa: Product, pb: Product) => pa.id - pb.id);
if (id.includes('matcher')) {
assert.deepEqual(actual, [products[1], products[2]], 'expected change to porapagate to vm');
} else {
assert.equal(actual[0], products[1], 'expected change to porapagate to vm - 1');
assert.equal(actual[1], products[2], 'expected change to porapagate to vm - 2');
}
})
);
}
assert.equal(labels[0].querySelector('input').checked, true, 'expected radio button to be checked');
// assert if the choice is changed in VM, it is propagated to view
app[chosenProp] = contacts[1];
ctx.scheduler.getRenderTaskQueue().flush();
assert.equal(labels[1].querySelector('input').checked, true, 'expected change of checked status - checked');
assert.equal(labels[0].querySelector('input').checked, false, 'expected change of checked status - unchecked');
// assert that when choice is changed from view, it is propagaetd to VM
const lastIndex = size - 1;
const lastChoice = labels[lastIndex];
lastChoice.click();
ctx.scheduler.getRenderTaskQueue().flush();
assert.equal(lastChoice.querySelector('input').checked, true, 'expected to be checked');
assert.deepEqual(app[chosenProp], contacts[2], 'expected change to porapagate to vm');
})
);
for (let i = 0; i < 20; i++) {
assert.html.textContent(inputs[i].parentElement, `${newProducts[i].id}-${newProducts[i].name}`, `incorrect label${i + 1}`);
}
assert.equal(inputs.length, products.length);
// sort
products.sort((pa, pb) => (pa.name < pb.name ? -1 : 1));
ctx.scheduler.getRenderTaskQueue().flush();
inputs = getInputs();
assert.deepEqual(inputs.map(i => getVisibleText(undefined, i.parentElement as any, true)), products.map(p => `${p.id}-${p.name}`));
// reverse
products.reverse();
ctx.scheduler.getRenderTaskQueue().flush();
inputs = getInputs();
assert.deepEqual(inputs.map(i => getVisibleText(undefined, i.parentElement as any, true)), products.map(p => `${p.id}-${p.name}`));
// clear
products.splice(0);
ctx.scheduler.getRenderTaskQueue().flush();
inputs = getInputs();
assert.equal(inputs.length, 0);
});
it('registers alias attribute patterns when provided', function () {
const aliases = ['t', 'i18n'];
const sut = setup(aliases);
assert.instanceOf(sut, TranslationAttributePattern);
const patternDefs = [];
for (const alias of aliases) {
assert.typeOf(sut[alias], 'function');
patternDefs.push({ pattern: alias, symbols: '' });
}
assert.deepEqual(AttributePattern.getPatternDefinitions(sut.constructor as Constructable), patternDefs);
});
it('returns empty html', function() {
assert.deepEqual(stripMetaData(' '), {
html: ' ',
shadowMode: null,
deps: [],
containerless: false,
bindables: {}
});
});
it('gets custom attribute like resource', function() {
assert.deepEqual(nameConvention('FooBarCustomAttribute'), {
name: 'foo-bar',
type: 'customAttribute'
});
assert.deepEqual(nameConvention('Foo1BarCustomAttribute'), {
name: 'foo1-bar',
type: 'customAttribute'
});
});
it(`parses ${property.toString()} to ${expected}`, function () {
const { parser } = setup();
assert.deepEqual(parsePropertyName(property, parser), [expected, parser.parse(expected, BindingType.None)]);
}));
it('registers alias attribute patterns when provided', function () {
const aliases = ['t', 'i18n'];
const sut = setup(aliases);
assert.instanceOf(sut, TranslationBindAttributePattern);
assert.deepEqual(
AttributePattern.getPatternDefinitions(sut.constructor as Constructable),
aliases.reduce(
(acc, alias) => {
acc.push({ pattern: `${alias}.bind`, symbols: '.' });
return acc;
},
[]));
aliases.forEach((alias) => {
assert.typeOf(sut[`${alias}.bind`], 'function', `${alias}.bind`);
});
});
it('merges optional options, turn off stringModuleWrap if uses CSSModule', function () {
const wrap = (id: string) => `text!${id}`;
assert.deepEqual(
preprocessOptions({
cssExtensions: ['.some'],
defaultShadowOptions: { mode: 'open' },
stringModuleWrap: wrap,
useProcessedFilePairFilename: true,
useCSSModule: true
}),
{
defaultShadowOptions: { mode: 'open' },
cssExtensions: ['.css', '.less', '.sass', '.scss', '.some', '.styl'],
jsExtensions: ['.coffee', '.js', '.jsx', '.ts', '.tsx'],
templateExtensions: ['.haml', '.html', '.jade', '.md', '.pug', '.slim', '.slm'],
stringModuleWrap: undefined,
useProcessedFilePairFilename: true
}
);
it(`'evaluate' resolves key expression ${input} to ${JSON.stringify(output)}`, async function () {
const customization = {
resources: {
en: { translation }
},
skipTranslationOnMissingKey
};
const { sut } = await createFixture(customization);
const result = sut.evaluate(input);
assert.deepEqual(result, output);
}));