Skip to content

Commit ab508f2

Browse files
committed
Add test of pluralization and format-num on categories list page
1 parent 57c609e commit ab508f2

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

app/mirage/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import summaryFixture from '../mirage/fixtures/summary';
22
import searchFixture from '../mirage/fixtures/search';
3+
import categoriesFixture from '../mirage/fixtures/categories';
34

45
export default function() {
56
this.get('/summary', () => summaryFixture);
@@ -13,6 +14,8 @@ export default function() {
1314
};
1415
}
1516
});
17+
18+
this.get('/api/v1/categories', () => categoriesFixture);
1619
}
1720

1821
function pageParams(request) {

app/mirage/fixtures/categories.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// jscs:disable validateQuoteMarks
2+
export default {
3+
"categories": [{
4+
"category": "API bindings",
5+
"crates_cnt": 0,
6+
"created_at": "2017-01-20T14:51:49Z",
7+
"description": "Idiomatic wrappers of specific APIs for convenient access from Rust. Includes HTTP API wrappers as well. Non-idiomatic or unsafe bindings can be found in External FFI bindings.",
8+
"id": "api-bindings",
9+
"slug": "api-bindings"
10+
}, {
11+
"category": "Algorithms",
12+
"crates_cnt": 1,
13+
"created_at": "2017-01-20T14:51:49Z",
14+
"description": "Rust implementations of core algorithms such as hashing, sorting, searching, and more.",
15+
"id": "algorithms",
16+
"slug": "algorithms"
17+
}, {
18+
"category": "Asynchronous",
19+
"crates_cnt": 3910,
20+
"created_at": "2017-01-20T14:51:49Z",
21+
"description": "Crates to help you deal with events independently of the main program flow, using techniques like futures, promises, waiting, or eventing.",
22+
"id": "asynchronous",
23+
"slug": "asynchronous"
24+
}],
25+
"meta": {
26+
"total": 3
27+
}
28+
};

tests/acceptance/categories-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { test } from 'qunit';
2+
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
4+
moduleForAcceptance('Acceptance | categories');
5+
6+
test('listing categories', function(assert) {
7+
visit('/categories');
8+
9+
andThen(function() {
10+
hasText(assert, '.row:eq(0) .desc .info span', '0 crates');
11+
12+
hasText(assert, '.row:eq(1) .desc .info span', '1 crate');
13+
14+
hasText(assert, '.row:eq(2) .desc .info span', '3,910 crates');
15+
});
16+
});

0 commit comments

Comments
 (0)