How to use the @aurelia/testing.assert.strictEqual 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__ / 5-jit-html / computed-observer.spec.ts View on Github external
assert.strictEqual(totalPropObserver['collectionDeps']?.length, 1);

        totalPropObserver['propertyDeps'].forEach((observerDep: SetterObserver, idx: number) => {
          if (idx === 0) {
            assert.instanceOf(observerDep, GetterObserver);
          } else {
            assert.instanceOf(observerDep, SetterObserver);
          }
        });

        assert.strictEqual(host.textContent, '30' /* idx 0, 2, 4, 6, 8 only */);
        component.items[0].isDone = false;
        assert.strictEqual(component.activeItems.length, 6);
        assert.strictEqual(host.textContent, '30');
        ctx.container.get(IScheduler).getRenderTaskQueue().flush();
        assert.strictEqual(host.textContent, '31');
      }
    },
github aurelia / aurelia / packages / __tests__ / kernel / eventaggregator.spec.ts View on Github external
it('adds handler with messageType and callback to the messageHandlers array', function () {
        const ea = new EventAggregator() as EA;
        const callback = function () { return; };
        ea.subscribe(DinnerEvent, callback);

        assert.strictEqual(ea.messageHandlers.length, 1, `ea.messageHandlers.length`);
        assert.strictEqual(ea.messageHandlers[0].messageType, DinnerEvent, `ea.messageHandlers[0].messageType`);
        assert.strictEqual(ea.messageHandlers[0].callback, callback, `ea.messageHandlers[0].callback`);
      });
github aurelia / aurelia / packages / __tests__ / runtime / debounce-binding-behavior.spec.ts View on Github external
it('bind()   should apply the correct behavior', function () {
    assert.strictEqual(binding['debouncedMethod'] === originalFn, true, `binding['debouncedMethod'] === originalFn`);
    assert.strictEqual(binding['debouncedMethod'].originalName, 'handleChange', `binding['debouncedMethod'].originalName`);
    assert.strictEqual(binding.handleChange === originalFn, false, `binding.handleChange === originalFn`);
    assert.strictEqual(typeof binding.handleChange, 'function', `typeof binding.handleChange`);
    assert.notStrictEqual(binding['debounceState'], null, `binding['debounceState']`);
    assert.strictEqual(typeof binding['debounceState'], 'object', `typeof binding['debounceState']`);
  });
github aurelia / aurelia / packages / __tests__ / runtime-html / select-value-observer.spec.ts View on Github external
it('disconnect node observer', function () {
      for (const isMultiple of [true, false]) {
        const { sut } = createFixture([], [], isMultiple);

        let count = 0;
        const nodeObserver: any = { disconnect() {
          count++;
        } };
        sut['nodeObserver'] = nodeObserver;

        sut.unbind(LF.none);

        assert.strictEqual(count, 1, `count`);
        assert.strictEqual(sut['nodeObserver'], null, `sut['nodeObserver']`);
      }
    });
    it('unsubscribes array observer', function () {
github aurelia / aurelia / packages / __tests__ / runtime-html / create-element.spec.ts View on Github external
it(`translates raw object properties to attributes`, function () {
        const ctx = TestContext.createHTMLTestContext();
        const actual = sut(ctx.dom, tag, { title: 'asdf', foo: 'bar' });

        const node = actual['node'] as Element;

        assert.strictEqual(node.getAttribute('title'), 'asdf', `node.getAttribute('title')`);
        assert.strictEqual(node.getAttribute('foo'), 'bar', `node.getAttribute('foo')`);

        assert.strictEqual(actual['instructions'].length, 0, `actual['instructions'].length`);
        assert.strictEqual(node.getAttribute('class'), null, `node.getAttribute('class')`);
      });
github aurelia / aurelia / packages / __tests__ / router / queue.spec.ts View on Github external
this.timeout(5000);
    const callback = async (qAnimal: QueueItem) => {
      const animal = qAnimal as Animal;
      await wait(100);
      if (animal.name === 'dog') {
        qAnimal.reject();
      } else {
        qAnimal.resolve();
      }
    };
    const q = new Queue(callback as (item: QueueItem) => void);
    q.enqueue(new Animal('dog', 'Pluto')).catch((error: Error) => { throw error; });
    assert.strictEqual(q.pending.length, 0, `q.pending.length`);
    q.enqueue(new Animal('cat', 'Figaro')).catch((error: Error) => { throw error; });
    assert.strictEqual(q.pending.length, 1, `q.pending.length`);
    assert.strictEqual(q.pending[0].cost, 1, `q.pending[0].cost`);
    q.enqueue(new Animal('cat', 'Figaro II'), 2).catch((error: Error) => { throw error; });
    assert.strictEqual(q.pending.length, 2, `q.pending.length`);
    assert.strictEqual(q.pending[1].cost, 2, `q.pending[1].cost`);
    q.enqueue([
      new Animal('dog', 'Pluto III'),
      new Animal('cat', 'Figaro III')], 3);
    assert.strictEqual(q.pending.length, 4, `q.pending.length`);
    assert.strictEqual(q.pending[2].cost, 3, `q.pending[2].cost`);
    assert.strictEqual(q.pending[3].cost, 3, `q.pending[3].cost`);
    q.enqueue([
      new Animal('dog', 'Pluto IV'),
      new Animal('cat', 'Figaro V')], [6, 7]);
    assert.strictEqual(q.pending.length, 6, `q.pending.length`);
    assert.strictEqual(q.pending[4].cost, 6, `q.pending[4].cost`);
    assert.strictEqual(q.pending[5].cost, 7, `q.pending[5].cost`);
  });
github aurelia / aurelia / packages / __tests__ / 2-runtime / scheduler.spec.ts View on Github external
sut.yield(priority).then(() => {
                    if (priority !== TaskQueuePriority.microTask) {
                      assert.strictEqual(count, ++yieldCount, 'count === ++yieldCount');

                      if (yieldCount < iterations) {
                        yieldAndVerify();
                      } else {
                        task.cancel();

                        assert.isSchedulerEmpty();

                        done();
                      }
                    }
                  }).catch((error) => { throw error; });
                }
github aurelia / aurelia / packages / __tests__ / 5-jit-html / custom-attributes.spec.ts View on Github external
[Foo5]
        );
        const fooEl = options.appHost.querySelector('div');
        const rootVm = options.au.root.viewModel as any;
        const foo5Vm = CustomAttribute.for(fooEl, 'foo5').viewModel as Foo5;

        assert.strictEqual(foo5Vm.prop, NaN, '#1 <-> Foo1 initial');
        assert.strictEqual(rootVm.prop, 'prop', '#1 <-> RootVm initial');
        assert.strictEqual(options.appHost.textContent, 'prop');

        rootVm.prop = 5;
        assert.strictEqual(foo5Vm.prop, 5, '#2 <-> RootVm.prop << 5 -> foo5Vm');
        assert.strictEqual((foo5Vm as any).$observers.prop.currentValue, 5, '#2 Foo5.$observer.prop.currentValue');
        assert.strictEqual(rootVm.prop, 5, '#2 <-> RootVm.prop << 5 -> rootVm');
        options.scheduler.getRenderTaskQueue().flush();
        assert.strictEqual(options.appHost.textContent, '5');

        const date = new Date();
        foo5Vm.prop = date;
        assert.strictEqual(foo5Vm.prop, date.getTime(), '#3 <-> foo1Vm.prop << Date');
        assert.strictEqual(rootVm.prop, date.getTime(), '#3 <-> foo1Vm.prop << Date');
        options.scheduler.getRenderTaskQueue().flush();
        assert.strictEqual(options.appHost.textContent, date.getTime().toString());

        rootVm.prop = NaN;
        assert.strictEqual(Object.is(foo5Vm.prop, NaN), true, '#1 <-> Foo1 initial');
        assert.strictEqual(Object.is(rootVm.prop, NaN), true, '#1 <-> RootVm initial');
        options.scheduler.getRenderTaskQueue().flush();
        assert.strictEqual(options.appHost.textContent, 'NaN');

        await options.tearDown();
      });
github aurelia / aurelia / packages / __tests__ / kernel / eventaggregator.spec.ts View on Github external
const subscription = ea.subscribe('dinner', callback);

        const callback2 = function () { return; };
        const subscription2 = ea.subscribe('dinner', callback2);

        assert.strictEqual(ea.eventLookup.dinner.length, 2, `ea.eventLookup.dinner.length`);
        assert.strictEqual(ea.eventLookup.dinner[0], callback, `ea.eventLookup.dinner[0]`);
        assert.strictEqual(ea.eventLookup.dinner[1], callback2, `ea.eventLookup.dinner[1]`);

        subscription.dispose();

        assert.strictEqual(ea.eventLookup.dinner.length, 1, `ea.eventLookup.dinner.length`);
        assert.strictEqual(ea.eventLookup.dinner[0], callback2, `ea.eventLookup.dinner[0]`);

        subscription2.dispose();
        assert.strictEqual(ea.eventLookup.dinner.length, 0, `ea.eventLookup.dinner.length`);
      });
github aurelia / aurelia / packages / __tests__ / router / route-recognizer.spec.ts View on Github external
Object.keys(result[0].params).forEach((property) => {
        if (params[property] === undefined) {
          return;
        }
        assert.strictEqual(result[0].params[property].toUpperCase(), params[property].toUpperCase(), `result[0].params[property].toUpperCase()`);
      });
    });