1- import { moduleFor , test } from 'ember-qunit' ;
1+ import { module , test } from 'qunit' ;
2+ import { setupTest } from 'ember-qunit' ;
23import sinon from 'sinon' ;
34
45let sandbox ;
56
6- moduleFor ( 'service:fastboot' , 'Unit | Service | fastboot | shoebox' , {
7- beforeEach ( ) {
7+ module ( 'Unit | Service | fastboot | shoebox' , function ( hooks ) {
8+ setupTest ( hooks ) ;
9+
10+ hooks . beforeEach ( function ( ) {
811 sandbox = sinon . sandbox . create ( ) ;
9- } ,
10- afterEach ( ) {
12+ } ) ;
13+
14+ hooks . afterEach ( function ( ) {
1115 sandbox . restore ( ) ;
12- }
13- } ) ;
16+ } ) ;
1417
15- test ( 'retrieve returns value if isFastBoot false and key is cached' , function ( assert ) {
16- let service = this . subject ( ) ;
18+ test ( 'retrieve returns value if isFastBoot false and key is cached' , function ( assert ) {
19+ let service = this . owner . lookup ( 'service:fastboot' ) ;
1720
18- service . set ( 'shoebox.foo' , 'bar' ) ;
21+ service . set ( 'shoebox.foo' , 'bar' ) ;
1922
20- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , 'bar' ) ;
21- } ) ;
23+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , 'bar' ) ;
24+ } ) ;
2225
23- test ( 'retrieve returns undefined if isFastBoot false and shoebox is missing' , function ( assert ) {
24- let service = this . subject ( ) ;
26+ test ( 'retrieve returns undefined if isFastBoot false and shoebox is missing' , function ( assert ) {
27+ let service = this . owner . lookup ( 'service:fastboot' ) ;
2528
26- let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) ;
29+ let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) ;
2730
28- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
31+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
2932
30- sinon . assert . calledOnce ( stub ) ;
31- } ) ;
33+ sinon . assert . calledOnce ( stub ) ;
34+ } ) ;
3235
33- test ( 'retrieve returns undefined if isFastBoot false and textContent is missing' , function ( assert ) {
34- let service = this . subject ( ) ;
36+ test ( 'retrieve returns undefined if isFastBoot false and textContent is missing' , function ( assert ) {
37+ let service = this . owner . lookup ( 'service:fastboot' ) ;
3538
36- let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) . returns ( { } ) ;
39+ let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) . returns ( { } ) ;
3740
38- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
41+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
3942
40- sinon . assert . calledOnce ( stub ) ;
41- } ) ;
43+ sinon . assert . calledOnce ( stub ) ;
44+ } ) ;
4245
43- test ( 'retrieve returns value if isFastBoot false and textContent is present' , function ( assert ) {
44- let service = this . subject ( ) ;
46+ test ( 'retrieve returns value if isFastBoot false and textContent is present' , function ( assert ) {
47+ let service = this . owner . lookup ( 'service:fastboot' ) ;
4548
46- let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) . returns ( {
47- textContent : '{"foo":"bar"}'
48- } ) ;
49+ let stub = sandbox . stub ( document , 'querySelector' ) . withArgs ( '#shoebox-foo' ) . returns ( {
50+ textContent : '{"foo":"bar"}'
51+ } ) ;
52+
53+ assert . deepEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , {
54+ foo : 'bar'
55+ } ) ;
4956
50- assert . deepEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , {
51- foo : 'bar'
57+ sinon . assert . calledOnce ( stub ) ;
5258 } ) ;
5359
54- sinon . assert . calledOnce ( stub ) ;
55- } ) ;
60+ test ( 'retrieve returns undefined if isFastBoot true and shoebox is missing' , function ( assert ) {
61+ let service = this . owner . factoryFor ( 'service:fastboot' ) . create ( {
62+ isFastBoot : true ,
63+ _fastbootInfo : { }
64+ } ) ;
5665
57- test ( 'retrieve returns undefined if isFastBoot true and shoebox is missing' , function ( assert ) {
58- let service = this . subject ( {
59- isFastBoot : true ,
60- _fastbootInfo : { }
66+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
6167 } ) ;
6268
63- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
64- } ) ;
69+ test ( 'retrieve returns undefined if isFastBoot true and key is missing' , function ( assert ) {
70+ let service = this . owner . factoryFor ( 'service:fastboot' ) . create ( {
71+ isFastBoot : true ,
72+ _fastbootInfo : {
73+ shoebox : { }
74+ }
75+ } ) ;
6576
66- test ( 'retrieve returns undefined if isFastBoot true and key is missing' , function ( assert ) {
67- let service = this . subject ( {
68- isFastBoot : true ,
69- _fastbootInfo : {
70- shoebox : { }
71- }
77+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
7278 } ) ;
7379
74- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , undefined ) ;
75- } ) ;
76-
77- test ( 'retrieve returns value if isFastBoot true and key is present' , function ( assert ) {
78- let service = this . subject ( {
79- isFastBoot : true ,
80- _fastbootInfo : {
81- shoebox : {
82- foo : 'bar'
80+ test ( 'retrieve returns value if isFastBoot true and key is present' , function ( assert ) {
81+ let service = this . owner . factoryFor ( 'service:fastboot' ) . create ( {
82+ isFastBoot : true ,
83+ _fastbootInfo : {
84+ shoebox : {
85+ foo : 'bar'
86+ }
8387 }
84- }
85- } ) ;
88+ } ) ;
8689
87- assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , 'bar' ) ;
88- } ) ;
90+ assert . strictEqual ( service . get ( 'shoebox' ) . retrieve ( 'foo' ) , 'bar' ) ;
91+ } ) ;
92+ } ) ;
0 commit comments