How to use the @aurelia/testing.assert.deepStrictEqual 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__ / 2-runtime / controller.spec.ts View on Github external
noHooks,
              ),
              'if',
              [new ToViewBindingInstruction(parseExpression('id===1&oneTime'), 'value')],
            ),
          ],
        ],
      );

      const viewModel = container.get(ViewModel);

      const sut = Controller.forCustomElement(viewModel, container, host);

      const expectedCalls = new CallCollection();

      assert.deepStrictEqual(
        calls,
        expectedCalls
          // ce #1
          .addCall(1, 'created', LF.getterSetterStrategy),
        '1',
      );

      sut.bind(flags);

      const ifInstance = sut.controllers[0].bindingContext as unknown as If;
      const secondCustomElementController = ifInstance.ifView.controllers[0];
      const secondIfInstance = secondCustomElementController.controllers[0].bindingContext as unknown as If;

      assert.deepStrictEqual(
        calls,
        expectedCalls
github aurelia / aurelia / packages / __tests__ / 2-runtime / binding.spec.ts View on Github external
// expect(sut.addObserver, `sut.addObserver #24`).to.have.been.calledOnce;
          // expect(sut.observeProperty, `sut.observeProperty #25`).to.have.been.calledOnce;
          // expect(sut.observeProperty, `sut.observeProperty #26`).to.have.been.calledWithExactly(flags, scope.bindingContext, expr.name);
        } else {
          // expect(sut.addObserver).not.to.have.been.called;
          // expect(sut.observeProperty).not.to.have.been.called;
        }

        // assert.strictEqual(lifecycle.flushCount, 0, `lifecycle.flushCount #27`);
        // expect(targetObserver['setValue'], `targetObserver['setValue'] #28`).to.have.been.calledOnce;
        // expect(targetObserver['setValue'], `targetObserver['setValue'] #29`).to.have.been.calledWithExactly(srcVal, flags);

        // verify the behavior of the targetObserver (redundant)
        if (srcVal instanceof Object) {
          assert.deepStrictEqual(target[prop], srcVal, `target[prop] #30`);
          assert.deepStrictEqual(targetObserver.currentValue, srcVal, `targetObserver.currentValue #31`);
        } else {
          assert.strictEqual(target[prop], srcVal, `target[prop] #32`);
          assert.strictEqual(targetObserver.currentValue, srcVal, `targetObserver.currentValue #33`);
        }

        if (!(flags & LF.fromBind)) {
          // expect(targetObserver.callSubscribers, `targetObserver.callSubscribers #34`).to.have.been.calledOnce;
        } else {
          // expect(targetObserver.callSubscribers, `targetObserver.callSubscribers #35`).not.to.have.been.called;
        }
        // expect(sut.handleChange, `sut.handleChange #36`).not.to.have.been.called;

        // - Arrange - Part 2
        // massReset(targetObserver);
        // massReset(sut);
        // massReset(expr);
github aurelia / aurelia / packages / __tests__ / router / link-handler.spec.ts View on Github external
it('can be activated', function () {
    const { sut, ctx } = createFixture();

    const addEventListener = createSpy(ctx.doc, 'addEventListener');

    sut.activate({ callback: info => console.log('can be activated', info) });

    assert.strictEqual(sut['isActive'], true, `linkHandler.isActive`);

    assert.deepStrictEqual(
      addEventListener.calls,
      [
        ['click', sut['handler'], true],
      ],
      `addEventListener.calls`,
    );

    addEventListener.restore();

    sut.deactivate();
  });
github aurelia / aurelia / packages / __tests__ / 1-kernel / metadata.spec.ts View on Github external
it('returns correct keys in definition order when metadata exists and without key', function () {
        const obj = {};
        Metadata.define('key1', 'value', obj, void 0);
        Metadata.define('key0', 'value', obj, void 0);

        const actual = Metadata.getKeys(obj, void 0);

        assert.deepStrictEqual(actual, ['key1', 'key0']);
      });
github aurelia / aurelia / packages / __tests__ / 1-kernel / di.spec.ts View on Github external
it(`can decorate constructor parameters explicitly`, function () {
    class Foo { public constructor(@inject(Dep1)dep1, @inject(Dep2)dep2, @inject(Dep3)dep3) { return; } }

    assert.deepStrictEqual(DI.getDependencies(Foo), [Dep1, Dep2, Dep3], `Foo['inject']`);
  });
github aurelia / aurelia / packages / __tests__ / 3-runtime-html / event-manager.spec.ts View on Github external
it(_`dispose() removes the event listener (eventName=${eventName}, bubbles=${bubbles}, listener=${listener})`, function () {
          const { ctx, sut, callback, event, el } = createFixture(listener, eventName, bubbles);

          el.dispatchEvent(event);

          assert.deepStrictEqual(
            callback.calls,
            [
              [event],
            ],
            'callback.calls',
          );

          el.dispatchEvent(event);

          assert.deepStrictEqual(
            callback.calls,
            [
              [event],
              [event],
            ],
            'callback.calls',
github aurelia / aurelia / packages / __tests__ / router / route-recognizer.spec.ts View on Github external
it('should register unnamed routes', function () {
    const sut = new RouteRecognizer();
    sut.add([{'path': 'b', 'handler': {}}]);

    assert.deepStrictEqual(sut.names, {}, `sut.names`);
    assert.strictEqual(!!sut.recognize('/b'), true, `!!sut.recognize('/b')`);
  });
github aurelia / aurelia / packages / __tests__ / 2-runtime / controller.spec.ts View on Github external
sut.attach(flags);

      assert.deepStrictEqual(
        calls,
        expectedCalls
          .addCall(2, 'attach', LF.none)
          .addCall(2, 'attachCustomElement', LF.fromAttach)
          .addCall(1, 'attaching', LF.fromAttach)
          .addCall(2, 'attachControllers', LF.fromAttach),
        '3',
      );
      assert.strictEqual(host.textContent, '', '4');

      scheduler.getRenderTaskQueue().flush();

      assert.deepStrictEqual(
        calls,
        expectedCalls
          .addCall(2, 'mount', LF.fromTick)
          .addCall(2, 'mountCustomElement', LF.fromTick)
          .addCall(2, 'attached', LF.fromTick)
          .addCall(1, 'attached', LF.fromTick),
        '5',
      );
      assert.strictEqual(host.textContent, '1', '6');

      sut.detach(flags);

      assert.deepStrictEqual(
        calls,
        expectedCalls
          .addCall(2, 'detach', LF.none)
github aurelia / aurelia / packages / __tests__ / 2-runtime / array-observer.spec.ts View on Github external
const expectedArr = init.slice();
          const newItems = items && items.slice();
          sut = new ArrayObserver(LF.none, DI.createContainer().get(ILifecycle), arr);
          let expectedResult;
          let actualResult;
          let i = 0;
          while (i < repeat) {
            incrementItems(newItems, i);
            if (newItems === undefined) {
              expectedResult = expectedArr.push();
              actualResult = arr.push();
            } else {
              expectedResult = expectedArr.push(...newItems);
              actualResult = arr.push(...newItems);
            }
            assert.deepStrictEqual(actualResult, expectedResult);
            assert.deepStrictEqual(arr, expectedArr);
            i++;
          }
        });
github aurelia / aurelia / packages / __tests__ / jit-html / template-compiler.spec.ts View on Github external
function verifyInstructions(actual: any[], expectation: IExpectedInstruction[], type?: string) {
      assert.strictEqual(actual.length, expectation.length, `Expected to have ${expectation.length} ${type ? type : ''} instructions. Received: ${actual.length}`);
      for (let i = 0, ii = actual.length; i < ii; ++i) {
        const actualInst = actual[i];
        const expectedInst = expectation[i];
        const ofType = type ? `of ${type}` : '';
        for (const prop of expectedInst.toVerify) {
          if (expectedInst[prop] instanceof Object) {
            assert.deepStrictEqual(
              actualInst[prop],
              expectedInst[prop],
              `Expected actual instruction ${ofType} to have "${prop}": ${expectedInst[prop]}. Received: ${actualInst[prop]} (on index: ${i})`
            );
          } else {
            assert.deepStrictEqual(
              actualInst[prop],
              expectedInst[prop],
              `Expected actual instruction ${ofType} to have "${prop}": ${expectedInst[prop]}. Received: ${actualInst[prop]} (on index: ${i})`
            );
          }
        }
      }
    }
  });