' +
@@ -554,16 +549,16 @@ describe('components', function() {
});
it('updates within template content', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.page.model.set('_page.width', 10);
- this.page.model.set('_page.color', 'blue');
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ page.model.set('_page.width', 10);
+ page.model.set('_page.color', 'blue');
+ app.views.register('Body',
'
'
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with #root._page.color as #color}}' +
'
' +
'{{content}}' +
@@ -571,32 +566,30 @@ describe('components', function() {
'{{/with}}'
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
expect(fragment).html('
lightblue
');
- this.page.model.set('_page.color', 'green');
+ page.model.set('_page.color', 'green');
expect(fragment).html('
lightgreen
');
});
it('updates within template attribute', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'{{if #show}}Show me!{{else}}Hide me.{{/if}}' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'
{{@message}}
' +
'{{/with}}'
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('
Hide me.
');
expect(swatch.model.get('message')).instanceof(templates.Template);
swatch.model.set('show', true);
@@ -605,23 +598,22 @@ describe('components', function() {
});
it('updates within template attribute in model', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'{{if #show}}Show me!{{else}}Hide me.{{/if}}' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'
{{message}}
' +
'{{/with}}'
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('
Hide me.
');
expect(swatch.model.get('message')).instanceof(templates.Template);
swatch.model.set('show', true);
@@ -630,23 +622,22 @@ describe('components', function() {
});
it('updates within expression attribute by making it a template', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'{{#show ? "Show me!" : "Hide me."}}' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'
{{message}}
' +
'{{/with}}'
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('
Hide me.
');
expect(swatch.model.get('message')).instanceof(templates.Template);
expect(swatch.getAttribute('message')).equal('Hide me.');
@@ -658,19 +649,18 @@ describe('components', function() {
});
it('updates within attribute bound to component model path', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'{{if show}}Show me!{{else}}Hide me.{{/if}}' +
''
);
- this.app.views.register('swatch', '
{{message}}
');
+ app.views.register('swatch', '
{{message}}
');
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('
Hide me.
');
expect(swatch.model.get('message')).instanceof(templates.Template);
expect(swatch.getAttribute('message')).equal('Hide me.');
@@ -680,15 +670,15 @@ describe('components', function() {
});
it('updates array within template attribute', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'{{each @items as #item}}' +
'{{#item.content}}' +
@@ -697,10 +687,9 @@ describe('components', function() {
{arrays: 'item/items'}
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.getAttribute('items')).eql([
{content: 'Hide me.'},
@@ -715,15 +704,15 @@ describe('components', function() {
});
it('updates array within template attribute with content alias', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'{{each @items as #item}}' +
'{{with #item.content as #itemContent}}' +
@@ -734,10 +723,9 @@ describe('components', function() {
{arrays: 'item/items'}
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.getAttribute('items')).eql([
{content: 'Hide me.'},
@@ -752,15 +740,15 @@ describe('components', function() {
});
it('updates array within template attribute in model', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'{{each items as #item}}' +
'{{#item.content}}' +
@@ -769,10 +757,9 @@ describe('components', function() {
{arrays: 'item/items'}
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.model.get('items').length).equal(2);
expect(swatch.model.get('items')[0].content).instanceof(templates.Template);
@@ -782,30 +769,29 @@ describe('components', function() {
});
it('updates array within template attribute in model from partial', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
'- {{if #show}}Show me!{{else}}Hide me.{{/if}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'
' +
'{{/with}}',
{arrays: 'item/items'}
);
- this.app.views.register('swatch-items',
+ app.views.register('swatch-items',
'{{each items as #item}}' +
'{{#item.content}}' +
'{{/each}}'
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.model.get('items').length).equal(2);
expect(swatch.model.get('items')[0].content).instanceof(templates.Template);
@@ -815,25 +801,24 @@ describe('components', function() {
});
it('updates array within attribute bound to component model path', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{if show}}Show me!{{else}}Hide me.{{/if}}
' +
'- {{if show}}Show me!{{else}}Hide me.{{/if}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{each @items as #item}}' +
'{{#item.content}}' +
'{{/each}}',
{arrays: 'item/items'}
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.getAttribute('items')).eql([
{content: 'Hide me.'},
@@ -848,15 +833,15 @@ describe('components', function() {
});
it('updates array within expression attribute by making it a template', function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.app.views.register('Body',
+ const app = runner.createHarness().app;
+ const page = app.createPage();
+ app.views.register('Body',
'
' +
'- {{#show ? "Show me!" : "Hide me."}}
' +
'- {{#show ? "Show me!" : "Hide me."}}
' +
''
);
- this.app.views.register('swatch',
+ app.views.register('swatch',
'{{with show as #show}}' +
'{{each items as #item}}' +
'{{#item.content}}' +
@@ -865,10 +850,9 @@ describe('components', function() {
{arrays: 'item/items'}
);
function Swatch() {}
- this.Swatch = Swatch;
- this.app.component('swatch', Swatch);
- var fragment = this.page.getFragment('Body');
- var swatch = this.page._components._1;
+ app.component('swatch', Swatch);
+ const fragment = page.getFragment('Body');
+ const swatch = page._components._1;
expect(fragment).html('Hide me.Hide me.');
expect(swatch.model.get('items').length).equal(2);
expect(swatch.model.get('items')[0].content).instanceof(templates.Template);
@@ -880,35 +864,38 @@ describe('components', function() {
});
describe('rendering', function() {
+ let app;
+ let page;
+
beforeEach(function() {
- this.app = runner.createHarness().app;
- this.page = this.app.createPage();
- this.page.model.set('_page.title', 'Good day');
- this.app.views.register('Body',
+ app = runner.createHarness().app;
+ page = app.createPage();
+ page.model.set('_page.title', 'Good day');
+ app.views.register('Body',
'
' +
'Hello.' +
'' +
''
);
- this.app.views.register('box',
+ app.views.register('box',
'
' +
'{{@title}}' +
'{{@content}}' +
'
'
);
- this.app.views.register('box-title',
+ app.views.register('box-title',
'
{{@content}}'
);
function Box() {}
this.Box = Box;
- this.app.component('box', this.Box);
+ app.component('box', this.Box);
function BoxTitle() {}
this.BoxTitle = BoxTitle;
- this.app.component('box-title', this.BoxTitle);
+ app.component('box-title', this.BoxTitle);
});
it('renders a component', function() {
- var html = this.page.get('Body');
+ const html = page.get('Body');
expect(html).equal(
'
' +
'Good day' +
@@ -919,7 +906,7 @@ describe('components', function() {
});
it('sets attributes as values on component model', function() {
- var tests = {
+ const tests = {
container: function(box, boxTitle) {
expect(box.model.get('title')).equal('Good day');
expect(boxTitle.model.get('tip')).equal('Good day');
@@ -942,7 +929,7 @@ describe('components', function() {
});
it('Component::getAttribute returns passed in values', function() {
- var tests = {
+ const tests = {
container: function(box, boxTitle) {
expect(box.getAttribute('title')).equal('Good day');
expect(boxTitle.getAttribute('tip')).equal('Good day');
@@ -966,13 +953,13 @@ describe('components', function() {
function testInit(tests) {
this.BoxTitle.prototype.init = function() {
- var box = this.parent;
- var boxTitle = this;
- var role = box.model.get('role');
+ const box = this.parent;
+ const boxTitle = this;
+ const role = box.model.get('role');
tests[role](box, boxTitle);
delete tests[role];
}
- this.page.getFragment('Body');
+ page.getFragment('Body');
expect(Object.keys(tests).length).equal(0);
}
});