11import { module , test } from 'qunit' ;
22import { setupTest } from 'ember-qunit' ;
33import { Server , Model , JSONAPISerializer } from 'miragejs' ;
4+ import { get } from '@ember/object' ;
45import EDModel , { attr } from '@ember-data/model' ;
56import { pushMirageIntoStore as pushMirageIntoStoreTestSupport } from "ember-cli-mirage/test-support" ;
67import { pushMirageIntoStore } from "ember-cli-mirage" ;
@@ -64,38 +65,38 @@ module('Unit | Utils | Push Mirage Into Store', function(hooks) {
6465
6566 test ( 'can push records all the records without a config' , function ( assert ) {
6667 pushMirageIntoStoreTestSupport ( ) ;
67- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
68- assert . equal ( this . store . peekAll ( 'blog' ) . length , 2 ) ;
68+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
69+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 2 ) ;
6970 } ) ;
7071
7172 test ( 'can push one resource as array' , function ( assert ) {
7273 pushMirageIntoStoreTestSupport ( [ 'users' ] ) ;
73- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
74- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
74+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
75+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
7576 } ) ;
7677
7778 test ( 'can push one resource as config true' , function ( assert ) {
7879 pushMirageIntoStoreTestSupport ( {
7980 users : true
8081 } ) ;
81- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
82- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
82+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
83+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
8384 } ) ;
8485
8586 test ( 'can push one resource as config where hash' , function ( assert ) {
8687 pushMirageIntoStoreTestSupport ( {
8788 users : { name : 'Joe Brown' }
8889 } ) ;
89- assert . equal ( this . store . peekAll ( 'user' ) . length , 1 ) ;
90- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
90+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 1 ) ;
91+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
9192 } ) ;
9293
9394 test ( 'can push one resource as config where function' , function ( assert ) {
9495 pushMirageIntoStoreTestSupport ( {
9596 users : ( item ) => item . name . includes ( "Joe" )
9697 } ) ;
97- assert . equal ( this . store . peekAll ( 'user' ) . length , 2 ) ;
98- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
98+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 2 ) ;
99+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
99100 } ) ;
100101
101102 } ) ;
@@ -117,38 +118,38 @@ module('Unit | Utils | Push Mirage Into Store', function(hooks) {
117118
118119 test ( 'can push records all the records without a config' , function ( assert ) {
119120 pushMirageIntoStore ( this . server , this . store ) ;
120- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
121- assert . equal ( this . store . peekAll ( 'blog' ) . length , 2 ) ;
121+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
122+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 2 ) ;
122123 } ) ;
123124
124125 test ( 'can push one resource as array' , function ( assert ) {
125126 pushMirageIntoStore ( this . server , this . store , [ 'users' ] ) ;
126- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
127- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
127+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
128+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
128129 } ) ;
129130
130131 test ( 'can push one resource as config true' , function ( assert ) {
131132 pushMirageIntoStore ( this . server , this . store , {
132133 users : true
133134 } ) ;
134- assert . equal ( this . store . peekAll ( 'user' ) . length , 3 ) ;
135- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
135+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 3 ) ;
136+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
136137 } ) ;
137138
138139 test ( 'can push one resource as config where hash' , function ( assert ) {
139140 pushMirageIntoStore ( this . server , this . store , {
140141 users : { name : 'Joe Brown' }
141142 } ) ;
142- assert . equal ( this . store . peekAll ( 'user' ) . length , 1 ) ;
143- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
143+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 1 ) ;
144+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
144145 } ) ;
145146
146147 test ( 'can push one resource as config where function' , function ( assert ) {
147148 pushMirageIntoStore ( this . server , this . store , {
148149 users : ( item ) => item . name . includes ( "Joe" )
149150 } ) ;
150- assert . equal ( this . store . peekAll ( 'user' ) . length , 2 ) ;
151- assert . equal ( this . store . peekAll ( 'blog' ) . length , 0 ) ;
151+ assert . equal ( get ( this . store . peekAll ( 'user' ) , ' length' ) , 2 ) ;
152+ assert . equal ( get ( this . store . peekAll ( 'blog' ) , ' length' ) , 0 ) ;
152153 } ) ;
153154 } ) ;
154155} ) ;
0 commit comments