Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('navigates to locally registered dep - conflicting scoped siblings - case #1', async function () {
const Conflict1 = CustomElement.define({ name: 'conflict', template: 'conflict1' }, null);
const Local1 = CustomElement.define({ name: 'local1', template: 'local1', dependencies: [Conflict1] }, null);
const Conflict2 = CustomElement.define({ name: 'conflict', template: 'conflict2' }, null);
const Local2 = CustomElement.define({ name: 'local2', template: 'local2', dependencies: [Conflict2] }, null);
const { scheduler, host, router, $teardown } = await $setup([Local1, Local2]);
await $goto('local1@default/conflict@one', router, scheduler);
assert.match(host.textContent, /.*local1.*conflict1.*/, `host.textContent`);
await $goto('local2@default/conflict@two', router, scheduler);
assert.match(host.textContent, /.*local2.*conflict2.*/, `host.textContent`);
await $teardown();
});
it('navigates to locally registered dep - double nested - case #2', async function () {
const Local3 = CustomElement.define({ name: 'local3', template: 'local3' }, null);
const Global2 = CustomElement.define({ name: 'global2', template: 'global2', dependencies: [Local3] }, null);
const Local1 = CustomElement.define({ name: 'local1', template: 'local1' }, null);
const { scheduler, host, router, container, $teardown } = await $setup([Local1]);
container.register(Global2);
await $goto('local1/global2/local3', router, scheduler);
assert.match(host.textContent, /.*local1.*global2.*local3.*/, `host.textContent`);
await $teardown();
});
it(`path: ${path}, expectedText: ${expectedText}`, async function () {
const Conflict1 = CustomElement.define({ name: 'conflict', template: 'conflict1' }, null);
const Global1 = CustomElement.define({ name: 'global1', template: 'global1', dependencies: [Conflict1] }, null);
const Conflict2 = CustomElement.define({ name: 'conflict', template: 'conflict2' }, null);
const Local2 = CustomElement.define({ name: 'local2', template: 'local2', dependencies: [Conflict2] }, null);
const { scheduler, host, router, container, $teardown } = await $setup([Local2]);
container.register(Global1);
await $goto(path, router, scheduler);
assert.match(host.textContent, expectedText, `host.textContent`);
await $teardown();
});
}
it('navigates to locally registered dep - conflicting scoped siblings - case #1', async function () {
const Conflict1 = CustomElement.define({ name: 'conflict', template: 'conflict1' }, null);
const Local1 = CustomElement.define({ name: 'local1', template: 'local1', dependencies: [Conflict1] }, null);
const Conflict2 = CustomElement.define({ name: 'conflict', template: 'conflict2' }, null);
const Local2 = CustomElement.define({ name: 'local2', template: 'local2', dependencies: [Conflict2] }, null);
const { scheduler, host, router, $teardown } = await $setup([Local1, Local2]);
await $goto('local1@default/conflict@one', router, scheduler);
assert.match(host.textContent, /.*local1.*conflict1.*/, `host.textContent`);
await $goto('local2@default/conflict@two', router, scheduler);
assert.match(host.textContent, /.*local2.*conflict2.*/, `host.textContent`);
await $teardown();
});
it('navigates to locally registered dep - conflicting scoped siblings - case #2', async function () {
const Conflict1 = CustomElement.define({ name: 'conflict', template: 'conflict1' }, null);
const Global1 = CustomElement.define({ name: 'global1', template: 'global1', dependencies: [Conflict1] }, null);
const Conflict2 = CustomElement.define({ name: 'conflict', template: 'conflict2' }, null);
const Global2 = CustomElement.define({ name: 'global2', template: 'global2', dependencies: [Conflict2] }, null);
const { scheduler, host, router, container, $teardown } = await $setup();
container.register(Global1, Global2);
await $goto('global1@default/conflict@one', router, scheduler);
assert.match(host.textContent, /.*global1.*conflict1.*/, `host.textContent`);
await $goto('global2@default/conflict@two', router, scheduler);
assert.match(host.textContent, /.*global2.*conflict2.*/, `host.textContent`);
await $teardown();
});
it(`logs ${loggerMethodName}`, function () {
const { sut, mock } = createFixture(configLevel, colorOpts, scopeTo);
sut[loggerMethodName](msgOrGetMsg, ...optionalParams);
assert.strictEqual(mock.calls.length, 1, `mock.calls.length`);
const [method, args] = mock.calls[0];
assert.strictEqual(method, consoleMethodName, `method`);
assert.strictEqual(args.length, optionalParams.length + 1, `args.length`);
assert.match(args[0], new RegExp(`${timestampRE} ${abbrevRE} test`));
if (optionalParams.length > 0) {
assert.deepStrictEqual(args.slice(1), optionalParams);
}
});
} else {
it('navigates to locally registered dep - double nested - case #4', async function () {
const Local3 = CustomElement.define({ name: 'local3', template: 'local3' }, null);
const Local2 = CustomElement.define({ name: 'local2', template: 'local2', dependencies: [Local3] }, null);
const Local1 = CustomElement.define({ name: 'local1', template: 'local1', dependencies: [Local2] }, null);
const { scheduler, host, router, $teardown } = await $setup([Local1]);
await $goto('local1/local2/local3', router, scheduler);
assert.match(host.textContent, /.*local1.*local2.*local3.*/, `host.textContent`);
await $teardown();
});
it('navigates to locally registered dep - double nested - case #3', async function () {
const Local3 = CustomElement.define({ name: 'local3', template: 'local3' }, null);
const Local2 = CustomElement.define({ name: 'local2', template: 'local2', dependencies: [Local3] }, null);
const Global1 = CustomElement.define({ name: 'global1', template: 'global1', dependencies: [Local2] }, null);
const { scheduler, host, router, container, $teardown } = await $setup();
container.register(Global1);
await $goto('global1/local2/local3', router, scheduler);
assert.match(host.textContent, /.*global1.*local2.*local3.*/, `host.textContent`);
await $teardown();
});
it('navigates to locally registered dep', async function () {
const Local = CustomElement.define({ name: 'local', template: 'local' }, null);
const { scheduler, host, router, $teardown } = await $setup([Local]);
await $goto('local', router, scheduler);
assert.match(host.textContent, /.*local.*/, `host.textContent`);
await $teardown();
});
Reflect.defineProperty(Foo.prototype, 'bar', {
writable: true,
value: 1,
configurable: true
});
const pd = Reflect.getOwnPropertyDescriptor(Foo.prototype, 'bar');
const foo = new Foo();
let err: Error;
try {
createComputedObserver(LF.none, locator, dirtyChecker, lifecycle, foo, 'bar', pd);
} catch (e) {
err = e;
}
assert.match(err.message, /18/);
});
});