2018-08-09 10:41:52 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render } from '@ember/test-helpers';
|
2017-09-28 18:37:38 -07:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
module('Integration | Component | empty state', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
test('it renders', async function(assert) {
|
|
|
|
// Set any properties with this.set('myProperty', 'value');
|
|
|
|
// Handle any actions with this.on('myAction', function(val) { ... });
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
await render(hbs`{{empty-state}}`);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.equal(
|
|
|
|
this.$()
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
'No data found'
|
|
|
|
);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
// Template block usage:
|
|
|
|
await render(hbs`
|
|
|
|
{{#empty-state}}
|
|
|
|
template block text
|
|
|
|
{{/empty-state}}
|
|
|
|
`);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.equal(
|
|
|
|
this.$()
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
'template block text'
|
|
|
|
);
|
|
|
|
});
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
test('it renders a heading', async function(assert) {
|
|
|
|
const heading = 'Not found!';
|
|
|
|
assert.expect(1);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
this.set('heading', heading);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
await render(hbs`{{empty-state heading=heading}}`);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.equal(
|
|
|
|
this.$()
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
heading,
|
|
|
|
'shows the heading text'
|
|
|
|
);
|
|
|
|
});
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
test('it renders a subheading', async function(assert) {
|
|
|
|
const subHeading = 'We could not find any results.';
|
|
|
|
assert.expect(1);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
this.set('subHeading', subHeading);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
await render(hbs`{{empty-state subHead=subHeading}}`);
|
2017-09-28 18:37:38 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.equal(
|
|
|
|
this.$('.empty-state__sub-head')
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
subHeading,
|
|
|
|
'shows the subheading text'
|
|
|
|
);
|
|
|
|
});
|
2017-09-28 18:37:38 -07:00
|
|
|
});
|