Skip to content

Commit

Permalink
feat(alias): Add convention add tests fix conv log
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonseydel committed Sep 11, 2019
1 parent 8aba497 commit 19399af
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 156 deletions.
47 changes: 23 additions & 24 deletions packages/__tests__/jit-html/binding-behaviors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import {
} from '@aurelia/runtime';
import { HTMLTestContext, TestContext, assert, setup } from '@aurelia/testing';

// TemplateCompiler - value converter integration
describe('value-converters', function () {
let ctx: HTMLTestContext;
let app;

beforeEach(function () {
ctx = TestContext.createHTMLTestContext();
app = class {
value = 'wOOt';
method = () => {
this.value = 'wOOt1';
}
};
});

// custom elements
Expand Down Expand Up @@ -72,58 +78,51 @@ describe('value-converters', function () {


const resources: any[] = [WootBehavior, WootBehavior2, FooAttr4, FooAttr5];
const App = class {
value = 'wOOt';
method = () => {
this.value = 'wOOt1';
}
};

it('Simple spread Alias doesn\'t break def alias works on value converter', async function () {
const options = await setup('<template> <div foo53.bind="value & woot13:method"></div> </template>', App, ctx, true, resources);
it('Simple spread Alias doesn\'t break def alias works on binding behavior', async function () {
const options = await setup('<template> <div foo53.bind="value & woot13:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple spread Alias (1st position) works on value converter', async function () {
const options = await setup('<template> <div foo51.bind="value & woot11:method"></div> </template>', App, ctx, true, resources);
it('Simple spread Alias (1st position) works on binding behavior', async function () {
const options = await setup('<template> <div foo51.bind="value & woot11:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple spread Alias (2nd position) works on value converter', async function () {
const options = await setup('<template> <div foo52.bind="value & woot12:method:method"></div> </template>', App, ctx, true, resources);
it('Simple spread Alias (2nd position) works on binding behavior', async function () {
const options = await setup('<template> <div foo52.bind="value & woot12:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple spread Alias doesn\'t break original value converter', async function () {
const options = await setup('<template> <div foo5.bind="value & woot2:method:method"></div> </template>', App, ctx, true, resources);
it('Simple spread Alias doesn\'t break original binding behavior', async function () {
const options = await setup('<template> <div foo5.bind="value & woot2:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});


it('Simple Alias doesn\'t break def alias works on value converter', async function () {
const options = await setup('<template> <div foo43.bind="value & woot23:method:method"></div> </template>', App, ctx, true, resources);
it('Simple Alias doesn\'t break def alias works on binding behavior', async function () {
const options = await setup('<template> <div foo43.bind="value & woot23:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple Alias (1st position) works on value converter', async function () {
const options = await setup('<template> <div foo41.bind="value & woot21:method:method"></div> </template>', App, ctx, true, resources);
it('Simple Alias (1st position) works on binding behavior', async function () {
const options = await setup('<template> <div foo41.bind="value & woot21:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple Alias (2nd position) works on value converter', async function () {
const options = await setup('<template> <div foo42.bind="value & woot22:method:method"></div> </template>', App, ctx, true, resources);
it('Simple Alias (2nd position) works on binding behavior', async function () {
const options = await setup('<template> <div foo42.bind="value & woot22:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});

it('Simple Alias doesn\'t break original value converter', async function () {
const options = await setup('<template> <div foo4.bind="value & woot2:method:method"></div> </template>', App, ctx, true, resources);
it('Simple Alias doesn\'t break original binding behavior', async function () {
const options = await setup('<template> <div foo4.bind="value & woot2:method:method"></div> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt1');
await options.tearDown();
});
Expand Down
67 changes: 35 additions & 32 deletions packages/__tests__/jit-html/binding-commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,87 @@ import {
} from '@aurelia/runtime';
import { HTMLTestContext, TestContext, assert, setup } from '@aurelia/testing';
import { IBindingCommand, PlainAttributeSymbol, BindingSymbol, bindingCommand, OneTimeBindingCommand } from '@aurelia/jit';
const App = class {
value = 'wOOt';
};
// TemplateCompiler - binding command integration

describe('binding-commands', function () {
let ctx: HTMLTestContext;
let app;

beforeEach(function () {
ctx = TestContext.createHTMLTestContext();
app = class {
value = 'wOOt';
};
});

class BaseBindingCommand implements IBindingCommand {
public readonly bindingType: BindingType.BindCommand = BindingType.BindCommand;

public compile(binding: PlainAttributeSymbol | BindingSymbol): AttributeInstruction {
return OneTimeBindingCommand.prototype.compile(binding);
}
}


// custom elements
describe('01. Aliases', async function () {

@bindingCommand({ name: 'woot1', aliases: ['woot13'] })
@alias(...['woot11', 'woot12'])
class WootCommand extends BaseBindingCommand { }
class WootCommand implements IBindingCommand {
public readonly bindingType: BindingType.BindCommand = BindingType.BindCommand;

public compile(binding: PlainAttributeSymbol | BindingSymbol): AttributeInstruction {
return OneTimeBindingCommand.prototype.compile(binding);
}
}

@bindingCommand({ name: 'woot2', aliases: ['woot23'] })
@alias('woot21', 'woot22')
class WootCommand2 extends BaseBindingCommand { }
class WootCommand2 implements IBindingCommand {
public readonly bindingType: BindingType.BindCommand = BindingType.BindCommand;

public compile(binding: PlainAttributeSymbol | BindingSymbol): AttributeInstruction {
return OneTimeBindingCommand.prototype.compile(binding);
}
}

const resources: any[] = [WootCommand, WootCommand2];

it('Simple spread Alias doesn\'t break def alias works on value converter', async function () {
const options = await setup('<template> <a href.woot1="value"></a> </template>', App, ctx, true, resources);
it('Simple spread Alias doesn\'t break def alias works on binding command', async function () {
const options = await setup('<template> <a href.woot1="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple spread Alias (1st position) works on value converter', async function () {
const options = await setup('<template> <a href.woot11="value"></a> </template>', App, ctx, true, resources);
it('Simple spread Alias (1st position) works on binding command', async function () {
const options = await setup('<template> <a href.woot11="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple spread Alias (2nd position) works on value converter', async function () {
const options = await setup('<template> <a href.woot12="value"></a> </template>', App, ctx, true, resources);
it('Simple spread Alias (2nd position) works on binding command', async function () {
const options = await setup('<template> <a href.woot12="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple spread Alias doesn\'t break original value converter', async function () {
const options = await setup('<template> <a href.woot13="value"></a> </template>', App, ctx, true, resources);
it('Simple spread Alias doesn\'t break original binding command', async function () {
const options = await setup('<template> <a href.woot13="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});


it('Simple Alias doesn\'t break def alias works on value converter', async function () {
const options = await setup('<template> <a href.woot23="value"></a> </template>', App, ctx, true, resources);
it('Simple Alias doesn\'t break def alias works on binding command', async function () {
const options = await setup('<template> <a href.woot23="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple Alias (1st position) works on value converter', async function () {
const options = await setup('<template> <a href.woot21="value"></a> </template>', App, ctx, true, resources);
it('Simple Alias (1st position) works on binding command', async function () {
const options = await setup('<template> <a href.woot21="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple Alias (2nd position) works on value converter', async function () {
const options = await setup('<template> <a href.woot22="value"></a> </template>', App, ctx, true, resources);
it('Simple Alias (2nd position) works on binding command', async function () {
const options = await setup('<template> <a href.woot22="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});

it('Simple Alias doesn\'t break original value converter', async function () {
const options = await setup('<template> <a href.woot2="value"></a> </template>', App, ctx, true, resources);
it('Simple Alias doesn\'t break original binding command', async function () {
const options = await setup('<template> <a href.woot2="value"></a> </template>', app, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('href'), 'wOOt');
await options.tearDown();
});
Expand Down
46 changes: 42 additions & 4 deletions packages/__tests__/jit-html/custom-attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {
bindable,
alias,
customAttribute,
INode
INode,
CustomElement
} from '@aurelia/runtime';
import { HTMLTestContext, TestContext, assert, setup } from '@aurelia/testing';

;

// TemplateCompiler - custom element integration
describe('custom-attributes', function () {
let ctx: HTMLTestContext;

Expand All @@ -26,7 +26,7 @@ describe('custom-attributes', function () {
public value: any;
constructor(@INode private readonly element: Element) {
}

bound() {
this.element.setAttribute('test', this.value);
}
Expand All @@ -45,15 +45,53 @@ describe('custom-attributes', function () {
}
}

@customAttribute({ name: 'foo44', aliases: ['foo431'] })
@alias('foo411', 'foo421')
@alias('foo422', 'foo422')
class FooMultipleAlias {
@bindable({ primary: true })
public value: any;
constructor(@INode private readonly element: Element) {
}

bound() {
this.element.setAttribute('test', this.value);
}
}

const resources: any[] = [Fooatt4, Fooatt5];
const resources: any[] = [Fooatt4, Fooatt5, FooMultipleAlias];

it('Simple spread Alias doesn\'t break def alias works on custom attribute', async function () {
const options = await setup('<template> <div foo53.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});

it('2 aliases and attribute alias original works', async function () {
const options = await setup('<template> <div foo44.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});

it('2 aliases and attribute alias first alias deco works', async function () {
const options = await setup('<template> <div foo411.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});

it('2 aliases and attribute alias def alias works', async function () {
const options = await setup('<template> <div foo431.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});

it('2 aliases and attribute alias second alias works', async function () {
const options = await setup('<template> <div foo422.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
await options.tearDown();
});


it('Simple spread Alias (1st position) works on custom attribute', async function () {
const options = await setup('<template> <div foo51.bind="value"></div> </template>', class { value = 'wOOt' }, ctx, true, resources);
assert.strictEqual(options.appHost.firstElementChild.getAttribute('test'), 'wOOt');
Expand Down
Loading

0 comments on commit 19399af

Please sign in to comment.