How to use the @aurelia/testing.assert.includes function in @aurelia/testing

To help you get started, we’ve selected a few @aurelia/testing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
public constructor() { this['IdName'] = IdName; }
    }

    const { host, router, container, tearDown, scheduler } = await createFixture({ useHref: false }, App);

    container.register(IdName);

    for (let i = 0; i < tests.length; i++) {
      const test = tests[i];
      console.log('link', test);

      (host.getElementsByTagName('A')[i] as HTMLElement).click();

      await scheduler.yieldAll();

      assert.includes(host.textContent, '|id-name|', `host.textContent`);
      assert.includes(host.textContent, `Parameter id: [${test.result}]`, `host.textContent`);

      await router.back();
      assert.notIncludes(host.textContent, '|id-name|', `host.textContent`);
    }

    await tearDown();
  });
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
it('parses parameters after component', async function () {
    this.timeout(5000);

    const { scheduler, host, router, tearDown } = await createFixture();

    await $goto('bar(123)@left', router, scheduler);
    assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
    assert.includes(host.textContent, 'Parameter id: [123]', `host.textContent`);

    await $goto('bar(456)@left', router, scheduler);
    assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
    assert.includes(host.textContent, 'Parameter id: [456]', `host.textContent`);

    await tearDown();
  });
github aurelia / aurelia / packages / __tests__ / router / nav.spec.ts View on Github external
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();
  });
github aurelia / aurelia / packages / __tests__ / router / nav.spec.ts View on Github external
it('generates nav with child links', async function () {
    this.timeout(5000);
    const { host, router, tearDown, scheduler } = await createFixture('qux');
    router.activeComponents =[new ViewportInstruction('baz', 'main-viewport')];

    await scheduler.yieldAll();

    assert.includes(host.innerHTML, 'href="baz"', `host.innerHTML`);
    assert.includes(host.innerHTML, 'nav-has-children', `host.innerHTML`);
    assert.includes(host.innerHTML, 'nav-level-1', `host.innerHTML`);
    await tearDown();
  });
});
github aurelia / aurelia / packages / __tests__ / router / nav.spec.ts View on Github external
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();
  });
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
}

    const { host, router, container, tearDown, scheduler } = await createFixture({ useHref: false }, App);

    container.register(IdName);

    for (let i = 0; i < tests.length; i++) {
      const test = tests[i];
      console.log('link', test);

      (host.getElementsByTagName('A')[i] as HTMLElement).click();

      await scheduler.yieldAll();

      assert.includes(host.textContent, '|id-name|', `host.textContent`);
      assert.includes(host.textContent, `Parameter id: [${test.result}]`, `host.textContent`);

      await router.back();
      assert.notIncludes(host.textContent, '|id-name|', `host.textContent`);
    }

    await tearDown();
  });
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
it('replaces foo in left', async function () {
    this.timeout(5000);

    const { scheduler, host, router, tearDown } = await createFixture();

    const historyLength = router.navigation.history.length;
    await $goto('foo@left', router, scheduler);
    assert.includes(host.textContent, 'foo', `host.textContent`);
    assert.strictEqual(router.navigation.history.length, historyLength + 1, `router.navigation.history.length`);

    await router.goto('bar@left', { replace: true });

    assert.includes(host.textContent, 'bar', `host.textContent`);
    assert.strictEqual(router.navigation.history.length, historyLength + 1, `router.navigation.history.length`);

    await tearDown();
  });
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
this.timeout(5000);

    const { scheduler, host, router, tearDown } = await createFixture();

    await $goto('bar(456)@left?id=123', router, scheduler);
    assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
    assert.includes(host.textContent, 'Parameter id: [456]', `host.textContent`);

    await $goto('bar(456&FourFiveSix)@left?id=123&name=OneTwoThree', router, scheduler);
    assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
    assert.includes(host.textContent, 'Parameter id: [456]', `host.textContent`);
    assert.includes(host.textContent, 'Parameter name: [FourFiveSix]', `host.textContent`);

    await $goto('bar(name=SevenEightNine&id=789)@left?id=123&name=OneTwoThree', router, scheduler);
    assert.includes(host.textContent, 'Viewport: bar', `host.textContent`);
    assert.includes(host.textContent, 'Parameter id: [789]', `host.textContent`);
    assert.includes(host.textContent, 'Parameter name: [SevenEightNine]', `host.textContent`);

    await tearDown();
  });
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
const { scheduler, host, router, tearDown, container } = await createFixture({ statefulHistoryLength: 2 });

    const GrandGrandChild = CustomElement.define({ name: 'grandgrandchild', template: '|grandgrandchild|<input>' }, null);
    const GrandChild = CustomElement.define({ name: 'grandchild', template: '|grandchild|<input> ', dependencies: [GrandGrandChild] }, null);
    const Child = CustomElement.define({ name: 'child', template: '|child|<input> <input type="checkbox"> <div><input> </div>', dependencies: [GrandChild] }, class { public toggle = true; });
    const ChildSibling = CustomElement.define({ name: 'sibling', template: '|sibling|' }, null);
    const Parent = CustomElement.define({ name: 'parent', template: '<br><br>|parent|<input> ', dependencies: [Child, ChildSibling] }, null);
    container.register(Parent);

    const values = ['parent', 'child', false, 'child-hidden', 'grandchild', 'grandgrandchild'];

    await $goto('parent@left/child@parent/grandchild@child', router, scheduler);

    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`);

    let inputs = host.getElementsByTagName('INPUT') as HTMLCollectionOf;
    for (let i = 0; i &lt; inputs.length; i++) {
      if (typeof values[i] === 'string') {
        inputs[i].value = values[i] as string;
      }
    }
    for (let i = 0; i &lt; 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);
github aurelia / aurelia / packages / __tests__ / router / router.spec.ts View on Github external
await $goto('plugh(123)@left', router, scheduler);
    assert.includes(host.textContent, 'Parameter: 123', `host.textContent`);
    assert.includes(host.textContent, 'Entry: 1', `host.textContent`);

    await $goto('plugh(123)@left', router, scheduler);
    assert.includes(host.textContent, 'Parameter: 123', `host.textContent`);
    assert.includes(host.textContent, 'Entry: 1', `host.textContent`);

    await $goto('plugh(456)@left', router, scheduler);
    assert.includes(host.textContent, 'Parameter: 456', `host.textContent`);
    assert.includes(host.textContent, 'Entry: 2', `host.textContent`);

    await $goto('plugh(456)@left', router, scheduler);
    assert.includes(host.textContent, 'Parameter: 456', `host.textContent`);
    assert.includes(host.textContent, 'Entry: 2', `host.textContent`);

    await tearDown();
  });