@@ -4,31 +4,47 @@ import { module, test } from 'qunit';
4
4
5
5
import percySnapshot from '@percy/ember' ;
6
6
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' ;
7
9
8
10
import axeConfig from '../axe-config' ;
9
11
import setupMirage from '../helpers/setup-mirage' ;
10
12
11
13
module ( 'Acceptance | categories' , function ( hooks ) {
12
14
setupApplicationTest ( hooks ) ;
15
+ setupWindowMock ( hooks ) ;
13
16
setupMirage ( hooks ) ;
14
17
15
18
test ( 'listing categories' , async function ( assert ) {
19
+ window . navigator = { languages : [ 'en' ] } ;
20
+
16
21
this . server . create ( 'category' , { category : 'API bindings' } ) ;
17
22
this . server . create ( 'category' , { category : 'Algorithms' } ) ;
18
23
this . server . createList ( 'crate' , 1 , { categoryIds : [ 'algorithms' ] } ) ;
19
24
this . server . create ( 'category' , { category : 'Asynchronous' } ) ;
20
25
this . server . createList ( 'crate' , 15 , { categoryIds : [ 'asynchronous' ] } ) ;
26
+ this . server . create ( 'category' , { category : 'Everything' , crates_cnt : 1234 } ) ;
21
27
22
28
await visit ( '/categories' ) ;
23
29
24
30
assert . dom ( '[data-test-category="api-bindings"] [data-test-crate-count]' ) . hasText ( '0 crates' ) ;
25
31
assert . dom ( '[data-test-category="algorithms"] [data-test-crate-count]' ) . hasText ( '1 crate' ) ;
26
32
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' ) ;
27
34
28
35
await percySnapshot ( assert ) ;
29
36
await a11yAudit ( axeConfig ) ;
30
37
} ) ;
31
38
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
+
32
48
test ( 'category/:category_id index default sort is recent-downloads' , async function ( assert ) {
33
49
this . server . create ( 'category' , { category : 'Algorithms' } ) ;
34
50
0 commit comments