Skip to content

Commit 2e5c7b3

Browse files
committed
tests/categories: Add checks for large crates_cnt values
1 parent 0a72e74 commit 2e5c7b3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/acceptance/categories-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,47 @@ import { module, test } from 'qunit';
44

55
import percySnapshot from '@percy/ember';
66
import a11yAudit from 'ember-a11y-testing/test-support/audit';
7+
import window from 'ember-window-mock';
8+
import { setupWindowMock } from 'ember-window-mock/test-support';
79

810
import axeConfig from '../axe-config';
911
import setupMirage from '../helpers/setup-mirage';
1012

1113
module('Acceptance | categories', function (hooks) {
1214
setupApplicationTest(hooks);
15+
setupWindowMock(hooks);
1316
setupMirage(hooks);
1417

1518
test('listing categories', async function (assert) {
19+
window.navigator = { languages: ['en'] };
20+
1621
this.server.create('category', { category: 'API bindings' });
1722
this.server.create('category', { category: 'Algorithms' });
1823
this.server.createList('crate', 1, { categoryIds: ['algorithms'] });
1924
this.server.create('category', { category: 'Asynchronous' });
2025
this.server.createList('crate', 15, { categoryIds: ['asynchronous'] });
26+
this.server.create('category', { category: 'Everything', crates_cnt: 1234 });
2127

2228
await visit('/categories');
2329

2430
assert.dom('[data-test-category="api-bindings"] [data-test-crate-count]').hasText('0 crates');
2531
assert.dom('[data-test-category="algorithms"] [data-test-crate-count]').hasText('1 crate');
2632
assert.dom('[data-test-category="asynchronous"] [data-test-crate-count]').hasText('15 crates');
33+
assert.dom('[data-test-category="everything"] [data-test-crate-count]').hasText('1,234 crates');
2734

2835
await percySnapshot(assert);
2936
await a11yAudit(axeConfig);
3037
});
3138

39+
test('listing categories (locale: de)', async function (assert) {
40+
window.navigator = { languages: ['de'] };
41+
42+
this.server.create('category', { category: 'Everything', crates_cnt: 1234 });
43+
44+
await visit('/categories');
45+
assert.dom('[data-test-category="everything"] [data-test-crate-count]').hasText('1.234 crates');
46+
});
47+
3248
test('category/:category_id index default sort is recent-downloads', async function (assert) {
3349
this.server.create('category', { category: 'Algorithms' });
3450

0 commit comments

Comments
 (0)