Skip to content

Commit 85bc7c4

Browse files
committed
tests/helpers: Convert sync helpers to exported functions
1 parent 50769ac commit 85bc7c4

File tree

9 files changed

+11
-10
lines changed

9 files changed

+11
-10
lines changed

tests/.eslintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module.exports = {
33
embertest: true
44
},
55
globals: {
6-
'hasText': true,
7-
'matchesText': true,
86
'server': true,
97
'wait': true,
108
},

tests/acceptance/categories-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import hasText from 'cargo/tests/helpers/has-text';
34

45
moduleForAcceptance('Acceptance | categories');
56

tests/acceptance/crate-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import matchesText from 'cargo/tests/helpers/matches-text';
4+
import hasText from 'cargo/tests/helpers/has-text';
35

46
moduleForAcceptance('Acceptance | crate page');
57

tests/acceptance/front-page-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import hasText from 'cargo/tests/helpers/has-text';
34

45
moduleForAcceptance('Acceptance | front page');
56

tests/acceptance/search-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import hasText from 'cargo/tests/helpers/has-text';
34

45
moduleForAcceptance('Acceptance | search');
56

tests/acceptance/team-page-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import hasText from 'cargo/tests/helpers/has-text';
34

45
moduleForAcceptance('Acceptance | team page');
56

tests/acceptance/user-page-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import hasText from 'cargo/tests/helpers/has-text';
34

45
moduleForAcceptance('Acceptance | user page');
56

tests/helpers/has-text.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Ember from 'ember';
2-
3-
export default Ember.Test.registerHelper('hasText', function(app, assert, selector, expected) {
1+
export default function hasText(assert, selector, expected) {
42
assert.equal(findWithAssert(selector).text().trim().replace(/\s+/g, ' '), expected);
5-
});
3+
}

tests/helpers/matches-text.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import Ember from 'ember';
2-
3-
export default Ember.Test.registerHelper('matchesText', function(app, assert, selector, expectedRegex) {
1+
export default function matchesText(assert, selector, expectedRegex) {
42
const $selected = findWithAssert(selector);
53
const $actual = $selected.text().trim().replace(/\s+/g, ' ');
64
assert.notEqual(
75
null,
86
$actual.match(expectedRegex),
97
`Text found ('${$actual}') did not match regex ('${expectedRegex}')`
108
);
11-
});
9+
}

0 commit comments

Comments
 (0)