Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assertionFn: (ctx, host, comp: { target: any; divdiv: HTMLDivElement; renderContext: HTMLElement }) => {
assert.notStrictEqual(
childrenQuerySelector(ctx.doc.body, '.divdiv'),
null,
'it should have been moved to body'
);
comp.target = '.mock-target';
assert.strictEqual(comp.divdiv.parentElement.id, 'mock-1-0');
comp.target = null;
assert.strictEqual(comp.divdiv.parentElement, ctx.doc.body);
comp.target = '.mock-target';
// still not #mock-1-1 yet, because render context is unclear, so #mock-1-0 comes first for .mock-target
assert.strictEqual(comp.divdiv.parentElement.id, 'mock-1-0');
comp.renderContext = host.querySelector('#mock-render-context');
it('can be created', function () {
const { sut } = createFixture();
assert.notStrictEqual(sut, null, `sut`);
});
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']`);
});
it(`callback child registration is invoked each time`, function () {
@inject(ICallback)
class TransientParent implements ITransientParent { constructor(public dep: ICallback) {} }
register(TransientParent);
const actual1 = container.get(ITransientParent);
assert.instanceOf(actual1, TransientParent, `actual1`);
assert.instanceOf(actual1.dep, Callback, `actual1.dep`);
const actual2 = container.get(ITransientParent);
assert.instanceOf(actual2, TransientParent, `actual2`);
assert.instanceOf(actual2.dep, Callback, `actual2.dep`);
assert.notStrictEqual(actual1, actual2, `actual1`);
assert.notStrictEqual(actual1.dep, actual2.dep, `actual1.dep`);
assert.deepStrictEqual(
callback.calls,
[
[container, container, container.getResolver(ICallback)],
[container, container, container.getResolver(ICallback)],
],
`callback.calls`,
);
assert.deepStrictEqual(
get.calls,
[
[ITransientParent],
[ICallback],
[ITransientParent],
it('can be created', function () {
const { sut, tearDown, callback } = createFixture();
assert.notStrictEqual(sut, null, `sut`);
tearDown();
});
it(_`getObserver() - {} - twice in a row different property - returns different observer`, function () {
const { sut } = setup();
const obj = {};
const expected = sut.getObserver(LF.none, obj, 'foo');
const actual = sut.getObserver(LF.none, obj, 'bar');
assert.notStrictEqual(actual, expected, `actual`);
});
const sut = new TemplateBinder(dom, resources, attrParser, exprParser, transformer);
const template = factory.createTemplate(markup) as HTMLTemplateElement;
const manifestRoot = sut.bind(template);
const div = manifestRoot.childNodes[0] as PlainElementSymbol;
const { customAttributes } = div;
assert.strictEqual(customAttributes.length, 1, 'customAttributes.length');
const [{ bindings }] = customAttributes;
assert.strictEqual(bindings.length, expectedBindings.length, 'bindings.length');
for (const expectedBinding of expectedBindings) {
const binding = bindings.find(b => b.target === expectedBinding.target && b.rawValue === expectedBinding.rawValue);
assert.notStrictEqual(binding, void 0, `${JSON.stringify(bindings.map(({ target, rawValue }) => ({ target, rawValue })))}.find(b => b.target === ${expectedBinding.target} && b.rawValue === ${expectedBinding.rawValue})`);
}
});
}
const result = parse(state, Access.Reset, Precedence.Assign, bindingType);
if ((result.$kind & ExpressionKind.IsPrimary) > 0 ||
(result.$kind & ExpressionKind.Unary) === ExpressionKind.Unary ||
(result.$kind & ExpressionKind.Binary) === ExpressionKind.Binary ||
(result.$kind & ExpressionKind.Conditional) === ExpressionKind.Conditional ||
(result.$kind & ExpressionKind.Assign) === ExpressionKind.Assign) {
if ((expected.$kind & ExpressionKind.IsPrimary) > 0 ||
(expected.$kind & ExpressionKind.Unary) === ExpressionKind.Unary ||
(expected.$kind & ExpressionKind.Binary) === ExpressionKind.Binary ||
(expected.$kind & ExpressionKind.Conditional) === ExpressionKind.Conditional ||
(expected.$kind & ExpressionKind.Assign) === ExpressionKind.Assign) {
assert.deepStrictEqual(result, expected);
assert.strictEqual(state.index >= state.length, true, `state.index >= state.length`);
} else {
assert.strictEqual(state.index < state.length, true, `state.index < state.length`);
assert.notStrictEqual(result.$kind, expected.$kind, 'result.$kind');
}
} else {
throw new Error('Should not parse anything higher than AssignExpression');
}
});
}
const controller = Controller.forCustomElement(component, ctx.container, host);
const projector = locator.getElementProjector(dom, controller, host, definition);
assert.instanceOf(projector, ContainerlessProjector, `projector`);
assert.strictEqual(projector['childNodes'].length, 0, `projector['childNodes'].length`);
assert.strictEqual(host.parentNode, null, `host.parentNode`);
assert.instanceOf(parent.firstChild, ctx.Comment, `parent.firstChild`);
assert.strictEqual(parent.firstChild.textContent, 'au-start', `parent.firstChild.textContent`);
assert.instanceOf(parent.lastChild, ctx.Comment, `parent.lastChild`);
assert.strictEqual(parent.lastChild.textContent, 'au-end', `parent.lastChild.textContent`);
assert.strictEqual(parent.firstChild.nextSibling['$controller'], component, `parent.firstChild.nextSibling['$controller']`);
assert.strictEqual(projector.children.length, projector.host['childNodes'].length, `projector.children.length`);
if (projector.children.length > 0) {
assert.deepStrictEqual(projector.children, projector.host['childNodes'], `projector.children`);
}
assert.notStrictEqual(projector.provideEncapsulationSource(), projector['host'], `projector.provideEncapsulationSource()`);
assert.strictEqual(projector.provideEncapsulationSource(), parent, `projector.provideEncapsulationSource()`);
});
public bound(): void {
this.boundCalls++;
assert.notStrictEqual(this.div, undefined, '[bound] div !== undefined');
assert.notContains(this.el, this.div, '[bound] this.el.contains(this.div) === false');
}