@@ -49,6 +49,22 @@ describe('Scope', function() {
49
49
} ) ;
50
50
} ) ;
51
51
52
+ describe ( '#stats()' , function ( ) {
53
+ it ( 'updates stats request' , function ( ) {
54
+ scope . stats ( { total : 'count' } ) ;
55
+ scope . stats ( { average : 'cost' } ) ;
56
+
57
+ expect ( scope . _stats ) . to . eql ( {
58
+ total : 'count' ,
59
+ average : 'cost'
60
+ } ) ;
61
+ } ) ;
62
+
63
+ it ( 'returns the scope' , function ( ) {
64
+ expect ( scope . stats ( { total : 'count' } ) ) . to . be . instanceof ( Scope )
65
+ } ) ;
66
+ } ) ;
67
+
52
68
describe ( '#order()' , function ( ) {
53
69
it ( 'updates sort criteria' , function ( ) {
54
70
scope . order ( 'foo' ) ;
@@ -136,6 +152,7 @@ describe('Scope', function() {
136
152
. select ( { people : [ 'name' , 'age' ] } )
137
153
. select ( { pets : [ 'type' ] } )
138
154
. selectExtra ( { people : [ 'net_worth' ] } )
155
+ . stats ( { total : 'count' } )
139
156
. includes ( { a : [ 'b' , { c : 'd' } ] } )
140
157
let qp = scope . asQueryParams ( ) ;
141
158
@@ -156,6 +173,9 @@ describe('Scope', function() {
156
173
extra_fields : {
157
174
people : [ 'net_worth' ]
158
175
} ,
176
+ stats : {
177
+ total : 'count'
178
+ } ,
159
179
include : 'a.b,a.c.d'
160
180
} ) ;
161
181
} ) ;
@@ -170,8 +190,9 @@ describe('Scope', function() {
170
190
. order ( 'foo' )
171
191
. order ( { bar : 'desc' } )
172
192
. select ( { people : [ 'name' , 'age' ] } )
193
+ . stats ( { total : 'count' } )
173
194
. includes ( { a : [ 'b' , { c : 'd' } ] } )
174
- expect ( scope . toQueryParams ( ) ) . to . eq ( 'page[number]=2&page[size]=10&filter[foo]=bar&sort=foo,-bar&fields[people]=name,age&include=a.b,a.c.d' ) ;
195
+ expect ( scope . toQueryParams ( ) ) . to . eq ( 'page[number]=2&page[size]=10&filter[foo]=bar&sort=foo,-bar&fields[people]=name,age&stats[total]=count& include=a.b,a.c.d' ) ;
175
196
} ) ;
176
197
177
198
it ( 'does not include empty objects' , function ( ) {
0 commit comments