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 back and forward with two viewports', async function () {
this.timeout(5000);
const { scheduler, host, router, tearDown } = await createFixture();
await $goto('foo@left', router, scheduler);
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: bar', `host.textContent`);
await $goto('bar@right', router, scheduler);
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
await router.back();
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: bar', `host.textContent`);
await router.forward();
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
await tearDown();
it('clears viewport', async function () {
this.timeout(5000);
const { scheduler, host, router, tearDown } = await createFixture();
await $goto('foo@left', router, scheduler);
assert.includes(host.textContent, 'foo', `host.textContent`);
await $goto('-@left', router, scheduler);
assert.notIncludes(host.textContent, 'foo', `host.textContent`);
await tearDown();
});
it('cancels if not canLeave', async function () {
this.timeout(5000);
const { scheduler, host, router, tearDown } = await createFixture();
quxCantLeave = 1;
await $goto('baz@left+qux@right', router, scheduler);
assert.includes(host.textContent, 'Viewport: baz', `host.textContent`);
assert.includes(host.textContent, 'Viewport: qux', `host.textContent`);
await $goto('foo@left+bar@right', router, scheduler);
assert.includes(host.textContent, 'Viewport: baz', `host.textContent`);
assert.includes(host.textContent, 'Viewport: qux', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: foo', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: bar', `host.textContent`);
await tearDown();
});
it('generates nav with a link', async function () {
this.timeout(5000);
const { host, router, tearDown, scheduler } = await createFixture('foo');
await scheduler.yieldAll();
assert.includes(host.innerHTML, 'foo', `host.innerHTML`);
assert.includes(host.innerHTML, 'Bar', `host.innerHTML`);
assert.includes(host.innerHTML, 'href="bar"', `host.innerHTML`);
assert.notIncludes(host.innerHTML, 'nav-active', `host.innerHTML`);
await tearDown();
});
if (secondClassList instanceof Array) {
for (const cls of secondClassList) {
assertClassChanges(initialClassList, classList, cls, secondUpdatedClassList);
}
return;
}
if (secondClassList instanceof Object) {
for (const cls in secondClassList) {
if (!!secondClassList[cls]) {
assert.includes(secondUpdatedClassList, cls, `secondUpdatedClassList includes class from secondClassList "${JSON.stringify(secondClassList)}"`);
continue;
}
if (!initialClasses.includes(cls)) {
assert.notIncludes(secondUpdatedClassList, cls, `secondUpdatedClassList ${JSON.stringify(secondUpdatedClassList)} does not exclude class ${cls} from initial class prop but does if not secondClassList "${JSON.stringify(secondClassList)}"`);
}
}
}
};
it.skip('keeps input when grandparent stateful', async function () {
this.timeout(5000);
const { scheduler, host, router, tearDown } = await createFixture();
await $goto('waldo@left', router, scheduler);
assert.includes(host.textContent, 'Viewport: waldo', `host.textContent`);
assert.includes(host.textContent, 'toggle', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.notIncludes(host.textContent, 'garply', `host.textContent`);
(host as any).getElementsByTagName('INPUT')[0].click();
await scheduler.yieldAll();
assert.includes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.includes(host.textContent, 'garply', `host.textContent`);
(host as any).getElementsByTagName('INPUT')[1].value = 'asdf';
await $goto('waldo@left/foo@waldo', router, scheduler);
assert.notIncludes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
inputs[i].value = values[i] as string;
}
}
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
}
await $goto('parent@left/sibling@parent', router, scheduler);
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|sibling|', `host.textContent`);
assert.notIncludes(host.textContent, '|child|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandgrandchild|', `host.textContent`);
await router.back();
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|child|', `host.textContent`);
assert.includes(host.textContent, '|grandchild|', `host.textContent`);
assert.includes(host.textContent, '|grandgrandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|sibling|', `host.textContent`);
inputs = inputs = host.getElementsByTagName('INPUT') as HTMLCollectionOf;
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
it.skip('keeps input when grandparent stateful', async function () {
this.timeout(5000);
const { scheduler, host, router, tearDown } = await createFixture();
await $goto('waldo@left', router, scheduler);
assert.includes(host.textContent, 'Viewport: waldo', `host.textContent`);
assert.includes(host.textContent, 'toggle', `host.textContent`);
assert.notIncludes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.notIncludes(host.textContent, 'garply', `host.textContent`);
(host as any).getElementsByTagName('INPUT')[0].click();
await scheduler.yieldAll();
assert.includes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.includes(host.textContent, 'garply', `host.textContent`);
(host as any).getElementsByTagName('INPUT')[1].value = 'asdf';
await $goto('waldo@left/foo@waldo', router, scheduler);
assert.notIncludes(host.textContent, 'Viewport: grault', `host.textContent`);
assert.includes(host.textContent, 'Viewport: foo', `host.textContent`);
await $goto('waldo@left/grault@waldo', router, scheduler);
inputs[i].value = values[i] as string;
}
}
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
}
await $goto('parent@left/sibling@parent', router, scheduler);
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|sibling|', `host.textContent`);
assert.notIncludes(host.textContent, '|child|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandgrandchild|', `host.textContent`);
await router.back();
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|child|', `host.textContent`);
assert.includes(host.textContent, '|grandchild|', `host.textContent`);
assert.includes(host.textContent, '|grandgrandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|sibling|', `host.textContent`);
inputs = inputs = host.getElementsByTagName('INPUT') as HTMLCollectionOf;
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
}
if (typeof values[i] === 'string') {
inputs[i].value = values[i] as string;
}
}
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
}
await $goto('parent@left/sibling@parent', router, scheduler);
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|sibling|', `host.textContent`);
assert.notIncludes(host.textContent, '|child|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|grandgrandchild|', `host.textContent`);
await router.back();
assert.includes(host.textContent, '|parent|', `host.textContent`);
assert.includes(host.textContent, '|child|', `host.textContent`);
assert.includes(host.textContent, '|grandchild|', `host.textContent`);
assert.includes(host.textContent, '|grandgrandchild|', `host.textContent`);
assert.notIncludes(host.textContent, '|sibling|', `host.textContent`);
inputs = inputs = host.getElementsByTagName('INPUT') as HTMLCollectionOf;
for (let i = 0; i < inputs.length; i++) {
if (typeof values[i] === 'string') {
assert.strictEqual(inputs[i].value, values[i], `host.getElementsByTagName('INPUT')[${i}].value`);
}
}