How to use the @aurelia/testing.assert.throws 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__ / 1-kernel / di.spec.ts View on Github external
it(_`throws on invalid key ${key}`, function () {
        const { sut } = setup();
        assert.throws(() => sut.registerTransformer(key, null as any), /5/, `() => sut.registerTransformer(key, null as any)`);
      });
    }
github aurelia / aurelia / packages / __tests__ / 5-jit-html / blur.unit.spec.ts View on Github external
it('throws when given anything not a Node but also not null/undefined', function () {
      const { sut } = createFixture();
      sut.value = true;
      for (const imcompatValue of [true, false, 'a', 5, Symbol(), Number, new Date(), {}, [], new Proxy({}, {})]) {
        assert.throws(() => sut.contains(imcompatValue as unknown as Element));
      }
    });
github aurelia / aurelia / packages / __tests__ / kernel / eventaggregator.spec.ts View on Github external
it('throws if channelOrType is undefined', function () {
        assert.throws(() => { ea.publish(undefined, {}); }, 'Code 0');
      });
github aurelia / aurelia / packages / __tests__ / 2-runtime / binding-context.spec.ts View on Github external
it('undefined', function () {
      assert.throws(() => BindingContext.get(undefined, undefined, undefined, LF.none), 'Code 250', `() => BindingContext.get(undefined, undefined, undefined, LF.none)`);
    });
github aurelia / aurelia / packages / __tests__ / router / route-recognizer.spec.ts View on Github external
it('should require dynamic segment parameters when generating', function () {
    const sut = new RouteRecognizer();
    sut.add([dynamicRoute]);

    assert.throws(() => sut.generate('dynamic'), void 0, `() => sut.generate('dynamic')`);
    assert.throws(() => sut.generate('dynamic', {}), void 0, `() => sut.generate('dynamic', {})`);
    assert.throws(() => sut.generate('dynamic', { id: null }), void 0, `() => sut.generate('dynamic', { id: null })`);
  });
github aurelia / aurelia / packages / __tests__ / plugin-conventions / name-convention.spec.ts View on Github external
it('complains about empty input', function() {
    assert.throws(() => nameConvention(''));
  });
github aurelia / aurelia / packages / __tests__ / 2-runtime / binding-context.spec.ts View on Github external
it('undefined', function () {
      assert.throws(() => Scope.fromOverride(LF.none, undefined), 'Code 252', `() => Scope.fromOverride(LF.none, undefined)`);
    });
github aurelia / aurelia / packages / __tests__ / runtime / template.spec.ts View on Github external
assert.strictEqual(typeof sut['dispose'], 'function', `typeof sut['dispose']`);

    assert.throws(() => sut.get(IViewFactory), /50/, `() => sut.get(IViewFactory)`);
    assert.strictEqual(sut.get(IController), null, `sut.get(IController)`);
    assert.strictEqual(sut.get(ITargetedInstruction), null, `sut.get(ITargetedInstruction)`);
    assert.strictEqual(sut.get(IRenderLocation), null, `sut.get(IRenderLocation)`);

    const renderable = {} as any;
    const target = {} as any;
    const instruction = {} as any;
    const parts = {} as any;
    const location = {} as any;

    sut.beginComponentOperation(renderable, target, instruction, viewFactory as any, parts, location);

    assert.throws(() => sut.get(IViewFactory), /51/, `() => sut.get(IViewFactory)`);
    assert.strictEqual(sut.get(IController), renderable, `sut.get(IController)`);
    assert.strictEqual(sut.get(INode), target, `sut.get(INode)`);
    assert.strictEqual(sut.get(AuNode), target, `sut.get(AuNode)`);
    assert.strictEqual(sut.get(ITargetedInstruction), instruction, `sut.get(ITargetedInstruction)`);
    assert.strictEqual(sut.get(IRenderLocation), location, `sut.get(IRenderLocation)`);
  });
});
github aurelia / aurelia / packages / __tests__ / jit-html / template-compiler.spec.ts View on Github external
attrs.forEach(attr => {
            assert.throws(
              () =&gt; compileWith(`<template></template>`, []),
              /Invalid surrogate attribute/,
            );
          });
        });
github aurelia / aurelia / packages / __tests__ / runtime / template.spec.ts View on Github external
assert.strictEqual(sut['parent'], parent, `sut['parent']`);

    assert.strictEqual(sut.has(IViewFactory, false), true, `sut.has(IViewFactory, false)`);
    assert.strictEqual(sut.has(IController, false), true, `sut.has(IController, false)`);
    assert.strictEqual(sut.has(ITargetedInstruction, false), true, `sut.has(ITargetedInstruction, false)`);
    assert.strictEqual(sut.has(IRenderLocation, false), true, `sut.has(IRenderLocation, false)`);
    assert.strictEqual(sut.has(Foo, false), true, `sut.has(Foo, false)`);
    assert.strictEqual(sut.has(Bar, false), true, `sut.has(Bar, false)`);
    assert.strictEqual(sut.has(INode, false), true, `sut.has(INode, false)`);
    assert.strictEqual(sut.has(AuNode, false), true, `sut.has(AuNode, false)`);

    assert.strictEqual(typeof sut.render, 'function', `typeof sut.render`);
    assert.strictEqual(typeof sut.beginComponentOperation, 'function', `typeof sut.beginComponentOperation`);
    assert.strictEqual(typeof sut['dispose'], 'function', `typeof sut['dispose']`);

    assert.throws(() => sut.get(IViewFactory), /50/, `() => sut.get(IViewFactory)`);
    assert.strictEqual(sut.get(IController), null, `sut.get(IController)`);
    assert.strictEqual(sut.get(ITargetedInstruction), null, `sut.get(ITargetedInstruction)`);
    assert.strictEqual(sut.get(IRenderLocation), null, `sut.get(IRenderLocation)`);

    const renderable = {} as any;
    const target = {} as any;
    const instruction = {} as any;
    const parts = {} as any;
    const location = {} as any;

    sut.beginComponentOperation(renderable, target, instruction, viewFactory as any, parts, location);

    assert.throws(() => sut.get(IViewFactory), /51/, `() => sut.get(IViewFactory)`);
    assert.strictEqual(sut.get(IController), renderable, `sut.get(IController)`);
    assert.strictEqual(sut.get(INode), target, `sut.get(INode)`);
    assert.strictEqual(sut.get(AuNode), target, `sut.get(AuNode)`);