Skip to content

Commit 76e1906

Browse files
committed
Integration tests use native DOM instead of jQuery
1 parent 5d2e739 commit 76e1906

File tree

10 files changed

+130
-117
lines changed

10 files changed

+130
-117
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased][unreleased]
66
### Updated
77
- `package.json` dependencies
8+
- Integration tests now use standard DOM instead of jQuery
89

910
### Removed
1011
- Acceptance tests

tests/integration/components/t-add-test.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('it renders', function(assert) {
1818

1919
this.render(hbs`{{t-add}}`);
2020

21-
assert.equal(this.$().text().trim(), 'add item');
21+
assert.equal(find('button').textContent.trim(), 'add item');
2222

2323
// Template block usage:
2424
this.render(hbs`
@@ -27,22 +27,23 @@ test('it renders', function(assert) {
2727
{{/t-add}}
2828
`);
2929

30-
assert.equal(this.$().text().trim(), 'add item');
30+
assert.equal(find('button').textContent.trim(), 'add item');
3131
});
3232

3333
test('it creates an add transformicon with defaults', function(assert) {
34-
assert.expect(5);
34+
assert.expect(6);
3535

3636
this.render(hbs`{{t-add}}`);
3737
percySnapshot(assert);
3838

39-
let compButton = this.$('button');
39+
let button = find('button');
4040

41-
assert.equal(compButton.attr('type'), 'button');
42-
assert.equal(compButton.attr('aria-label'), 'add item');
43-
assert.ok(compButton.hasClass('tcon'));
44-
assert.ok(compButton.hasClass('tcon-plus'));
45-
assert.ok(compButton.hasClass('tcon-plus--minus'));
41+
assert.equal(button.getAttribute('type'), 'button');
42+
assert.equal(button.getAttribute('aria-label'), 'add item');
43+
assert.ok(button.classList.contains('tcon'));
44+
assert.ok(button.classList.contains('tcon-plus'));
45+
assert.ok(button.classList.contains('tcon-plus--minus'));
46+
assert.notOk(button.classList.contains('tcon-transform'));
4647
});
4748

4849
test('it creates an add transformicon with `is-added=true`', function(assert) {
@@ -51,31 +52,31 @@ test('it creates an add transformicon with `is-added=true`', function(assert) {
5152
this.render(hbs`{{t-add is-added=true}}`);
5253
percySnapshot(assert);
5354

54-
let compButton = this.$('button');
55+
let button = find('button');
5556

56-
assert.ok(compButton.hasClass('tcon-transform'));
57+
assert.ok(button.classList.contains('tcon-transform'));
5758
});
5859

5960
test('it creates an add transformicon with a non-default animation `a="check"`', function(assert) {
6061
assert.expect(1);
6162

6263
this.render(hbs`{{t-add a="check"}}`);
6364

64-
let compButton = this.$('button');
65+
let button = find('button');
6566

66-
assert.ok(compButton.hasClass('tcon-plus--check'));
67+
assert.ok(button.classList.contains('tcon-plus--check'));
6768
});
6869

6970
test('user can click on the transformicon', function(assert) {
7071
assert.expect(2);
7172

7273
this.render(hbs`{{t-add id="t-add"}}`);
7374

74-
let elem = find('#t-add');
75-
assert.equal(this.$(elem).hasClass('tcon-transform'), false);
75+
let button = find('#t-add');
76+
assert.equal(button.classList.contains('tcon-transform'), false);
7677

7778
click('#t-add');
7879
percySnapshot(assert);
7980

80-
assert.equal(this.$(elem).hasClass('tcon-transform'), true);
81+
assert.equal(button.classList.contains('tcon-transform'), true);
8182
});

tests/integration/components/t-form-test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('it renders', function(assert) {
1818

1919
this.render(hbs`{{t-form}}`);
2020

21-
assert.equal(this.$().text().trim(), 'toggle search');
21+
assert.equal(find('button').textContent.trim(), 'toggle search');
2222

2323
// Template block usage:
2424
this.render(hbs`
@@ -27,21 +27,22 @@ test('it renders', function(assert) {
2727
{{/t-form}}
2828
`);
2929

30-
assert.equal(this.$().text().trim(), 'toggle search');
30+
assert.equal(find('button').textContent.trim(), 'toggle search');
3131
});
3232

3333
test('it creates a form transformicon with defaults', function(assert) {
34-
assert.expect(4);
34+
assert.expect(5);
3535

3636
this.render(hbs`{{t-form}}`);
3737
percySnapshot(assert);
3838

39-
let compButton = this.$('button');
39+
let button = find('button');
4040

41-
assert.equal(compButton.attr('type'), 'button');
42-
assert.equal(compButton.attr('aria-label'), 'toggle search');
43-
assert.ok(compButton.hasClass('tcon'));
44-
assert.ok(compButton.hasClass('tcon-search--xcross'));
41+
assert.equal(button.getAttribute('type'), 'button');
42+
assert.equal(button.getAttribute('aria-label'), 'toggle search');
43+
assert.ok(button.classList.contains('tcon'));
44+
assert.ok(button.classList.contains('tcon-search--xcross'));
45+
assert.notOk(button.classList.contains('tcon-transform'));
4546
});
4647

4748
test('it creates a form transformicon with `is-searching=true`', function(assert) {
@@ -50,21 +51,21 @@ test('it creates a form transformicon with `is-searching=true`', function(assert
5051
this.render(hbs`{{t-form is-searching=true}}`);
5152
percySnapshot(assert);
5253

53-
let compButton = this.$('button');
54+
let button = find('button');
5455

55-
assert.ok(compButton.hasClass('tcon-transform'));
56+
assert.ok(button.classList.contains('tcon-transform'));
5657
});
5758

5859
test('user can click on the transformicon', function(assert) {
5960
assert.expect(2);
6061

6162
this.render(hbs`{{t-form id="t-form"}}`);
6263

63-
let elem = find('#t-form');
64-
assert.equal(this.$(elem).hasClass('tcon-transform'), false);
64+
let button = find('#t-form');
65+
assert.equal(button.classList.contains('tcon-transform'), false);
6566

6667
click('#t-form');
6768
percySnapshot(assert);
6869

69-
assert.equal(this.$(elem).hasClass('tcon-transform'), true);
70+
assert.equal(button.classList.contains('tcon-transform'), true);
7071
});

tests/integration/components/t-grid-test.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('it renders', function(assert) {
1818

1919
this.render(hbs`{{t-grid}}`);
2020

21-
assert.equal(this.$().text().trim(), 'toggle grid');
21+
assert.equal(find('button').textContent.trim(), 'toggle grid');
2222

2323
// Template block usage:
2424
this.render(hbs`
@@ -27,22 +27,23 @@ test('it renders', function(assert) {
2727
{{/t-grid}}
2828
`);
2929

30-
assert.equal(this.$().text().trim(), 'toggle grid');
30+
assert.equal(find('button').textContent.trim(), 'toggle grid');
3131
});
3232

3333
test('it creates a grid transformicon with defaults', function(assert) {
34-
assert.expect(5);
34+
assert.expect(6);
3535

3636
this.render(hbs`{{t-grid}}`);
3737
percySnapshot(assert);
3838

39-
let compButton = this.$('button');
39+
let button = find('button');
4040

41-
assert.equal(compButton.attr('type'), 'button');
42-
assert.equal(compButton.attr('aria-label'), 'toggle grid');
43-
assert.ok(compButton.hasClass('tcon'));
44-
assert.ok(compButton.hasClass('tcon-grid'));
45-
assert.ok(compButton.hasClass('tcon-grid--rearrange'));
41+
assert.equal(button.getAttribute('type'), 'button');
42+
assert.equal(button.getAttribute('aria-label'), 'toggle grid');
43+
assert.ok(button.classList.contains('tcon'));
44+
assert.ok(button.classList.contains('tcon-grid'));
45+
assert.ok(button.classList.contains('tcon-grid--rearrange'));
46+
assert.notOk(button.classList.contains('tcon-transform'));
4647
});
4748

4849
test('it creates a grid transformicon with `is-open=true`', function(assert) {
@@ -51,31 +52,31 @@ test('it creates a grid transformicon with `is-open=true`', function(assert) {
5152
this.render(hbs`{{t-grid is-open=true}}`);
5253
percySnapshot(assert);
5354

54-
let compButton = this.$('button');
55+
let button = find('button');
5556

56-
assert.ok(compButton.hasClass('tcon-transform'));
57+
assert.ok(button.classList.contains('tcon-transform'));
5758
});
5859

5960
test('it creates a grid transformicon with a non-default animation `a="collapse"`', function(assert) {
6061
assert.expect(1);
6162

6263
this.render(hbs`{{t-grid a="collapse"}}`);
6364

64-
let compButton = this.$('button');
65+
let button = find('button');
6566

66-
assert.ok(compButton.hasClass('tcon-grid--collapse'));
67+
assert.ok(button.classList.contains('tcon-grid--collapse'));
6768
});
6869

6970
test('user can click on the transformicon', function(assert) {
7071
assert.expect(2);
7172

7273
this.render(hbs`{{t-grid id="t-grid"}}`);
7374

74-
let elem = find('#t-grid');
75-
assert.equal(this.$(elem).hasClass('tcon-transform'), false);
75+
let button = find('#t-grid');
76+
assert.equal(button.classList.contains('tcon-transform'), false);
7677

7778
click('#t-grid');
7879
percySnapshot(assert);
7980

80-
assert.equal(this.$(elem).hasClass('tcon-transform'), true);
81+
assert.equal(button.classList.contains('tcon-transform'), true);
8182
});

tests/integration/components/t-loader-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { moduleForComponent, test } from 'ember-qunit';
22
import hbs from 'htmlbars-inline-precompile';
3+
import { find } from 'ember-native-dom-helpers/test-support/helpers';
34

45
/*
56
* {{t-loader}}
@@ -16,7 +17,7 @@ test('it renders', function(assert) {
1617

1718
this.render(hbs`{{t-loader}}`);
1819

19-
assert.equal(this.$().text().trim(), 'loading');
20+
assert.equal(find('span').textContent.trim(), 'loading');
2021

2122
// Template block usage:
2223
this.render(hbs`
@@ -25,16 +26,16 @@ test('it renders', function(assert) {
2526
{{/t-loader}}
2627
`);
2728

28-
assert.equal(this.$().text().trim(), 'loading');
29+
assert.equal(find('span').textContent.trim(), 'loading');
2930
});
3031

3132
test('it creates a loader transformicon with defaults', function(assert) {
3233
assert.expect(2);
3334

3435
this.render(hbs`{{t-loader}}`);
3536

36-
let compSpan = this.$('span');
37+
let span = find('span');
3738

38-
assert.equal(compSpan.attr('aria-label'), 'loading');
39-
assert.ok(compSpan.hasClass('tcon-loader--spinner360'));
39+
assert.equal(span.getAttribute('aria-label'), 'loading');
40+
assert.ok(span.classList.contains('tcon-loader--spinner360'));
4041
});

tests/integration/components/t-mail-test.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('it renders', function(assert) {
1818

1919
this.render(hbs`{{t-mail}}`);
2020

21-
assert.equal(this.$().text().trim(), 'open mailbox');
21+
assert.equal(find('button').textContent.trim(), 'open mailbox');
2222

2323
// Template block usage:
2424
this.render(hbs`
@@ -27,22 +27,23 @@ test('it renders', function(assert) {
2727
{{/t-mail}}
2828
`);
2929

30-
assert.equal(this.$().text().trim(), 'open mailbox');
30+
assert.equal(find('button').textContent.trim(), 'open mailbox');
3131
});
3232

3333
test('it creates a mail transformicon with defaults', function(assert) {
34-
assert.expect(5);
34+
assert.expect(6);
3535

3636
this.render(hbs`{{t-mail}}`);
3737
percySnapshot(assert);
3838

39-
let compButton = this.$('button');
39+
let button = find('button');
4040

41-
assert.equal(compButton.attr('role'), 'button');
42-
assert.equal(compButton.attr('type'), 'button');
43-
assert.equal(compButton.attr('aria-label'), 'open mailbox');
44-
assert.ok(compButton.hasClass('tcon'));
45-
assert.ok(compButton.hasClass('tcon-mail--envelope'));
41+
assert.equal(button.getAttribute('role'), 'button');
42+
assert.equal(button.getAttribute('type'), 'button');
43+
assert.equal(button.getAttribute('aria-label'), 'open mailbox');
44+
assert.ok(button.classList.contains('tcon'));
45+
assert.ok(button.classList.contains('tcon-mail--envelope'));
46+
assert.notOk(button.classList.contains('tcon-transform'));
4647
});
4748

4849
test('it creates a mail transformicon with `is-open=false`', function(assert) {
@@ -51,21 +52,21 @@ test('it creates a mail transformicon with `is-open=false`', function(assert) {
5152
this.render(hbs`{{t-mail is-open=false}}`);
5253
percySnapshot(assert);
5354

54-
let compButton = this.$('button');
55+
let button = find('button');
5556

56-
assert.ok(compButton.hasClass('tcon-transform'));
57+
assert.ok(button.classList.contains('tcon-transform'));
5758
});
5859

5960
test('user can click on the transformicon', function(assert) {
6061
assert.expect(2);
6162

6263
this.render(hbs`{{t-mail id="t-mail"}}`);
6364

64-
let elem = find('#t-mail');
65-
assert.equal(this.$(elem).hasClass('tcon-transform'), false);
65+
let button = find('#t-mail');
66+
assert.equal(button.classList.contains('tcon-transform'), false);
6667

6768
click('#t-mail');
6869
percySnapshot(assert);
6970

70-
assert.equal(this.$(elem).hasClass('tcon-transform'), true);
71+
assert.equal(button.classList.contains('tcon-transform'), true);
7172
});

0 commit comments

Comments
 (0)