Skip to content

Commit 20184db

Browse files
committed
Add a test for going to the all versions page
Also add a new test helper that matches a regex instead of text exactly because timezones :(
1 parent dcd730d commit 20184db

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

tests/.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"currentURL",
2525
"currentPath",
2626
"currentRouteName",
27-
"hasText"
27+
"hasText",
28+
"matchesText"
2829
],
2930
"node": false,
3031
"browser": false,

tests/acceptance/crate-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ test('visiting a crate page directly', function(assert) {
2121
assert.equal(document.title, 'nanomsg - Cargo: packages for Rust');
2222
});
2323
});
24+
25+
test('navigating to the all versions page', function(assert) {
26+
visit('/crates/nanomsg');
27+
click('#crate-versions span.small a');
28+
29+
andThen(function() {
30+
matchesText(assert, '.info', /All 12 versions of nanomsg since December \d+, 2014/);
31+
});
32+
});

tests/helpers/matches-text.js

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

tests/helpers/start-app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Ember from 'ember';
22
import Application from '../../app';
33
import config from '../../config/environment';
44
import './has-text';
5+
import './matches-text';
56

67
export default function startApp(attrs) {
78
let application;

0 commit comments

Comments
 (0)