Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('does not invoke change handler when starts with two-way usage', async function () {
const template = `<div></div>`;
const options = setup(
template,
class {
public prop: string = 'prop';
},
[Foo1]
);
const fooEl = options.appHost.querySelector('div') as INode;
const foo1Vm = CustomAttribute.for(fooEl, 'foo1').viewModel as Foo1;
assert.strictEqual(foo1Vm.propChangedCallCount, 0, `#1 Foo1 count`);
assert.strictEqual(foo1Vm.propertyChangedCallCount, 0, `#2 Foo1 count`);
assert.strictEqual(foo1Vm.prop, `prop`);
const rootVm = options.au.root.viewModel;
// changing source value should trigger the change handler
it('Simple Alias (1st position) works on binding behavior', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});
it('Simple Alias (2nd position) works on value converter', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});
it('Simple spread Alias (2nd position) works on custom attribute', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});
it('Simple Alias (2nd position) works on binding command', async function () {
const options = setup('<template> <a></a> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});
it('Simple Alias (1st position) works on value converter', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});
it('2 aliases and attribute alias original works', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});
it('Simple Alias doesn\'t break original custom attribute', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});
it('Simple spread Alias (1st position) works on value converter', async function () {
const options = setup('<template> <div></div> </template>', app, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});
function setupChangeHandlerTest(template: string) {
const options = setup(template, class {}, [Foo]);
const fooEl = options.appHost.querySelector('div') as INode;
const fooVm = CustomAttribute.for(fooEl, 'foo').viewModel as Foo;
return {
fooVm: fooVm,
tearDown: () => options.tearDown()
};
}
});