Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(`verify if/else behavior - strategySpec ${strategySpec.t}, duplicateOperationSpec ${duplicateOperationSpec.t}, bindSpec ${bindSpec.t}, mutationSpec ${mutationSpec.t}, flagsSpec ${flagsSpec.t}, `, function () {
const { strategy } = strategySpec;
const { bindTwice, attachTwice, detachTwice, unbindTwice, newScopeForDuplicateBind, newValueForDuplicateBind } = duplicateOperationSpec;
const { ifPropName, elsePropName, ifText, elseText, value1, value2 } = bindSpec;
const { newValue1, newValue2 } = mutationSpec;
const { bindFlags1, attachFlags1, detachFlags1, unbindFlags1, bindFlags2, attachFlags2, detachFlags2, unbindFlags2 } = flagsSpec;
// common stuff
const baseFlags: LifecycleFlags = strategy as unknown as LifecycleFlags;
const proxies = (strategy & BindingStrategy.proxies) > 0;
const container = AuDOMConfiguration.createContainer();
const dom = container.get(IDOM);
const observerLocator = container.get(IObserverLocator);
const lifecycle = container.get(ILifecycle);
const location = AuNode.createRenderLocation();
const location2 = AuNode.createRenderLocation();
const host = AuNode.createHost().appendChild(location.$start).appendChild(location).appendChild(location2.$start).appendChild(location2);
const ifTemplate: ITemplate = {
renderContext: null as any,
dom: null as any,
definition: null as any,
render(controller: IController) {
const text = AuNode.createText();
const wrapper = AuNode.createTemplate().appendChild(text);
it(`verify repeat behavior - strategySpec ${strategySpec.t}, duplicateOperationSpec ${duplicateOperationSpec.t}, bindSpec ${bindSpec.t}, flagsSpec ${flagsSpec.t}, `, function () {
const { strategy } = strategySpec;
const { bindTwice, attachTwice, detachTwice, unbindTwice, newScopeForDuplicateBind } = duplicateOperationSpec;
const { items: $items, flush, mutations } = bindSpec;
const { bindFlags1, attachFlags1, detachFlags1, unbindFlags1, bindFlags2, attachFlags2, detachFlags2, unbindFlags2 } = flagsSpec;
const items = $items.slice();
// common stuff
const baseFlags: LifecycleFlags = strategy as unknown as LifecycleFlags;
const proxies = (strategy & BindingStrategy.proxies) > 0;
const container = AuDOMConfiguration.createContainer();
const dom = container.get(IDOM);
const observerLocator = container.get(IObserverLocator);
const lifecycle = container.get(ILifecycle);
const scheduler = container.get(IScheduler);
const location = AuNode.createRenderLocation();
const host = AuNode.createHost().appendChild(location.$start).appendChild(location);
const itemTemplate: ITemplate = {
renderContext: null as any,
dom: null as any,
definition: null as any,
render(itemRenderable) {
const text = AuNode.createText();
const wrapper = AuNode.createTemplate().appendChild(text);
it('properly initializes a renderContext', function () {
const parent = AuDOMConfiguration.createContainer();
class Foo {}
class Bar {public static register(container: IContainer) { container.register(Registration.singleton(Bar, Bar)); }}
const sut = createRenderContext(new AuDOM(), parent as any, [Foo as any, Bar], null);
const viewFactory = new ViewFactory(null, null, null);
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)`);
it('queues the rendering of an else view when one is linked and its value is false', function () {
const container = AuDOMConfiguration.createContainer();
const { attribute: ifAttr, location } = hydrateCustomAttribute(If as typeof If & ICustomAttributeType, { container });
const { attribute: elseAttr, lifecycle } = hydrateCustomAttribute(Else as typeof Else & ICustomAttributeType, { container });
elseAttr.link(ifAttr as If);
ifAttr.value = true;
ifAttr.$bind(LifecycleFlags.fromBind, createScopeForTest());
ifAttr.value = false;
let child = getCurrentView(ifAttr as If);
let elseView = ifAttr['elseView'] as IController;
expect(child).not.to.equal(null);
expect(elseView).to.equal(undefined);
lifecycle.processFlushQueue(LifecycleFlags.none);
it(`creates a new createNodeSequence function`, function () {
class Foo {}
class Bar {public static register(container2: IContainer) { container2.register(Registration.singleton(Bar, Bar)); }}
const container = AuDOMConfiguration.createContainer();
const dom = container.get(IDOM);
const templateNode = AuNode.createTemplate().appendChild(AuNode.createText('foo'));
const nsFactory = new AuNodeSequenceFactory(dom, templateNode);
const def = { template: templateNode, dependencies: [Foo, Bar] } as unknown as TemplateDefinition;
const sut = new CompiledTemplate(dom, def, nsFactory, container as any);
const nodes = sut.factory.createNodeSequence();
assert.strictEqual(nodes.childNodes[0].textContent, 'foo', `nodes.childNodes[0].textContent`);
});
});
beforeEach(function () {
sut = new Aurelia(AuDOMConfiguration.createContainer());
});
function setup() {
const container = AuDOMConfiguration.createContainer();
IExpressionParserRegistration.register(container as any);
const dom = container.get(IDOM);
const renderable: IController = {
$bindingHead: null,
$bindingTail: null,
$componentHead: null,
$componentTail: null,
$context: null,
$nodes: null,
$scope: null
};
container.register(Registration.instance(IController, renderable));
const target = AuNode.createMarker();
const renderingEngine = container.get(IRenderingEngine);
const sut = container.get(IRenderer);