Skip to content

Commit a70c92f

Browse files
committed
Add test fixtures to assert TS support
1 parent a7a8c5e commit a70c92f

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { click } from '@ember/test-helpers';
2+
import { moduleForComponent, test } from 'ember-qunit';
3+
import hbs from 'htmlbars-inline-precompile';
4+
5+
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
6+
integration: true
7+
});
8+
9+
function fillInHelper(value: string) {
10+
this.$('.foo input').val(value);
11+
this.$('.foo input').change();
12+
}
13+
14+
test('it renders', async function(assert) {
15+
this.render(hbs`{{foo-bar}}`);
16+
17+
await click('.foo');
18+
assert.equal(this.$('.foo').attr('id'), 'foo');
19+
this.$('.foo input').val('bar').change();
20+
assert.equal(this.$('.foo').text().trim(), 'foo');
21+
});
22+
23+
test('it renders again', function(assert) {
24+
this.render(hbs`{{foo-bar}}`);
25+
26+
let selector = '.foo input';
27+
assert.equal(this.$(selector).length, 1);
28+
assert.equal(this.$(selector).val(), 'foo');
29+
assert.ok(this.$('.foo').hasClass('selected'));
30+
});
31+
32+
test('and again', function(assert) {
33+
this.render(hbs`{{foo-bar}}`);
34+
35+
this.$('foo').click();
36+
37+
fillInHelper.call(this, 'bar');
38+
assert.ok(this.$('.foo').hasClass('selected'));
39+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { click, find, findAll, fillIn, blur, triggerEvent } from '@ember/test-helpers';
2+
import { moduleForComponent, test } from 'ember-qunit';
3+
import hbs from 'htmlbars-inline-precompile';
4+
5+
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
6+
integration: true
7+
});
8+
9+
async function fillInHelper(value: string) {
10+
await fillIn('.foo input', value);
11+
await triggerEvent('.foo input', 'change');
12+
}
13+
14+
test('it renders', async function(assert) {
15+
this.render(hbs`{{foo-bar}}`);
16+
17+
await click('.foo');
18+
assert.equal(find('.foo').id, 'foo');
19+
await fillIn('.foo input', 'bar');
20+
await blur('.foo input');
21+
assert.equal(find('.foo').textContent.trim(), 'foo');
22+
});
23+
24+
test('it renders again', function(assert) {
25+
this.render(hbs`{{foo-bar}}`);
26+
27+
let selector = '.foo input';
28+
assert.equal(findAll(selector).length, 1);
29+
assert.equal(find(selector).value, 'foo');
30+
assert.ok(find('.foo').classList.contains('selected'));
31+
});
32+
33+
test('and again', async function(assert) {
34+
this.render(hbs`{{foo-bar}}`);
35+
36+
await click('foo');
37+
38+
fillInHelper.call(this, 'bar');
39+
assert.ok(find('.foo').classList.contains('selected'));
40+
});

0 commit comments

Comments
 (0)