How to use the @aurelia/testing.assert.notEqual 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__ / integration / integration.spec.ts View on Github external
$it('uses a user preference control gets dirty checked for non-configurable property', async function ({ host, ctx: { scheduler, lifecycle, container } }) {
    const { user } = getViewModel(host);
    const userPref = host.querySelector('user-preference');
    const indeterminate = userPref.querySelector('#indeterminate');
    assert.html.textContent(indeterminate, 'test', 'incorrect text indeterminate');

    // assert that it is being dirty checked
    const dirtyChecker = container.get(IDirtyChecker);
    const dirtyCheckProperty = (dirtyChecker['tracked'] as DirtyCheckProperty[]).find(prop => Object.is(user.arr, prop.obj) && prop.propertyKey === 'indeterminate');
    assert.notEqual(dirtyCheckProperty, undefined);
    const isDirtySpy = createSpy(dirtyCheckProperty, 'isDirty', true);

    // asser disable
    DirtyCheckSettings.disabled = true;
    isDirtySpy.reset();

    await scheduler.yieldAll();
    assert.equal(isDirtySpy.calls.length, 0);

    DirtyCheckSettings.disabled = false;

    // assert rate
    await scheduler.yieldAll();
    const prevCallCount = isDirtySpy.calls.length;

    isDirtySpy.reset();
github aurelia / aurelia / packages / __tests__ / 5-jit-html / focus.spec.ts View on Github external
};

      const { startPromise, testHost, dispose, component, ctx } = createFixture(
        `<template>
          <div id="blurred"></div>
        </template>`,
        class App {
          public hasFocus = true;
        }
      );
      await startPromise;

      const activeElement = ctx.doc.activeElement;
      const div = testHost.querySelector('app div');
      assert.equal(callCount, 1, 'It should have invoked focus on DIV element prototype');
      assert.notEqual(div, null, ' <div> should not be null');
      assert.notEqual(activeElement.tagName, 'DIV');
      assert.notEqual(activeElement, div);
      assert.equal(component.hasFocus, true, 'It should not have affected component.hasFocus');

      // focus belongs to HTMLElement class
      delete HTMLDivElement.prototype.focus;

      await dispose();
    });
</div>
github aurelia / aurelia / packages / __tests__ / integration / integration.spec.ts View on Github external
const container = ce.querySelector("div");
    const button = container.querySelector("button");

    let prev = vm.random;
    const assertAttr = () => {
      assert.equal(container['foobar'], vm.random);
      assert.equal(container.getAttribute('foobar'), undefined);
      assert.equal(container['foo-bar'], undefined);
      assert.equal(container.getAttribute('foo-bar'), vm.random);
    };
    assertAttr();

    // self BB
    container.click();
    await ctx.scheduler.yieldAll();
    assert.notEqual(vm.random, prev, 'new random expected1');
    assertAttr();

    prev = vm.random;
    button.click();
    await ctx.scheduler.yieldAll();
    assert.equal(vm.random, prev, 'new random not expected');

    container.click();
    await ctx.scheduler.yieldAll();
    assert.notEqual(vm.random, prev, 'new random expected2');
    assertAttr();
  });
});
github aurelia / aurelia / packages / __tests__ / 5-jit-html / focus.spec.ts View on Github external
const { startPromise, testHost, dispose, component, ctx } = createFixture(
        `<template>
          <div id="blurred"></div>
        </template>`,
        class App {
          public hasFocus = true;
        }
      );
      await startPromise;

      const activeElement = ctx.doc.activeElement;
      const div = testHost.querySelector('app div');
      assert.equal(callCount, 1, 'It should have invoked focus on DIV element prototype');
      assert.notEqual(div, null, ' <div> should not be null');
      assert.notEqual(activeElement.tagName, 'DIV');
      assert.notEqual(activeElement, div);
      assert.equal(component.hasFocus, true, 'It should not have affected component.hasFocus');

      // focus belongs to HTMLElement class
      delete HTMLDivElement.prototype.focus;

      await dispose();
    });
</div>
github aurelia / aurelia / packages / __tests__ / 5-jit-html / template-compiler.ref.spec.ts View on Github external
assertFn: (ctx, host, comp) => {
        assert.notEqual(comp.hello, undefined);
        assert.strictEqual(host.querySelector('div'), comp.hello);
      },
      assertFnAfterDestroy: (ctx, host, comp) => {
github aurelia / aurelia / packages / __tests__ / 5-jit-html / portal.spec.tsx View on Github external
assertionFn: (ctx, host, comp) => {
          assert.notEqual(
            childrenQuerySelector(comp.localDiv, '.divdiv'),
            null,
            'comp.localDiv should have contained .divdiv'
          );
        },
        postTeardownAssertionFn: (ctx, host, comp) => {
github aurelia / aurelia / packages / __tests__ / 5-jit-html / focus.spec.ts View on Github external
return HTMLElement.prototype.focus.call(this, options);
                }
              }
            });
            await start();

            const activeElement = ctx.doc.activeElement;
            const ceEl = testHost.querySelector(`app ${ceName}`);
            assert.equal(callCount, 1, 'It should have called focus()');
            assert.notEqual(ceEl, null);
            if (isFocusable) {
              if (hasShadowRoot) {
                assert.equal(activeElement.tagName, ceName.toUpperCase());
                assert.equal(activeElement, ceEl);
              } else {
                assert.notEqual(
                  activeElement,
                  ceEl,
                  'Custom element should NOT have focus when it has focusable light dom child'
                );
              }
            }
            assert.equal(component.hasFocus, true, 'It should not have affected component.hasFocus');

            await dispose();
          });
        }
github aurelia / aurelia / packages / __tests__ / 5-jit-html / focus.spec.ts View on Github external
|| this.querySelector('select')
                    || this.querySelector('[contenteditable]')
                    || this.querySelector('[tabindex]');
                  if (focusableEl) {
                    return (focusableEl as HTMLElement).focus();
                  }
                  return HTMLElement.prototype.focus.call(this, options);
                }
              }
            });
            await start();

            const activeElement = ctx.doc.activeElement;
            const ceEl = testHost.querySelector(`app ${ceName}`);
            assert.equal(callCount, 1, 'It should have called focus()');
            assert.notEqual(ceEl, null);
            if (isFocusable) {
              if (hasShadowRoot) {
                assert.equal(activeElement.tagName, ceName.toUpperCase());
                assert.equal(activeElement, ceEl);
              } else {
                assert.notEqual(
                  activeElement,
                  ceEl,
                  'Custom element should NOT have focus when it has focusable light dom child'
                );
              }
            }
            assert.equal(component.hasFocus, true, 'It should not have affected component.hasFocus');

            await dispose();
          });
github aurelia / aurelia / packages / __tests__ / 5-jit-html / focus.spec.ts View on Github external
assertionFn(ctx, testHost, component, focusable) {
          const input2: HTMLInputElement = testHost.querySelector('#input2');
          assert.notEqual(focusable, input2, '@setup: focusable === #input2');
          input2.focus();
          dispatchEventWith(ctx, input2, 'focus', false);
          dispatchEventWith(ctx, focusable, 'blur', false);
          assert.equal(ctx.doc.activeElement, input2, '#input2@focus -> document.activeElement === #input2');
          assert.equal(component.isFocused2, true, '#input2@focus -> component.isFocused2 === true');
          assert.equal(component.hasFocus, false, '#input2@focus -> component.hasFocus === false');
        }
      }
github aurelia / aurelia / packages / __tests__ / 5-jit-html / portal.spec.tsx View on Github external
assertionFn: (ctx, host, component) =&gt; {
          assert.equal(host.childElementCount, 0, 'It should have been empty.');
          assert.notEqual(
            childrenQuerySelector(ctx.doc.body, '.portaled'),
            null,
            ' should have been portaled'
          );
        }
      },