@@ -71,4 +71,100 @@ describe('InstallationsRouter', () => {
7171 done ( ) ;
7272 } ) ;
7373 } ) ;
74+
75+ it ( 'query installations with limit = 0' , ( done ) => {
76+ var androidDeviceRequest = {
77+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abc' ,
78+ 'deviceType' : 'android'
79+ } ;
80+ var iosDeviceRequest = {
81+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abd' ,
82+ 'deviceType' : 'ios'
83+ } ;
84+ var request = {
85+ config : config ,
86+ auth : auth . master ( config ) ,
87+ body : { } ,
88+ query : {
89+ limit : 0
90+ }
91+ } ;
92+
93+ var router = new InstallationsRouter ( ) ;
94+ rest . create ( config , auth . nobody ( config ) , '_Installation' , androidDeviceRequest )
95+ . then ( ( ) => {
96+ return rest . create ( config , auth . nobody ( config ) , '_Installation' , iosDeviceRequest ) ;
97+ } ) . then ( ( ) => {
98+ return router . handleFind ( request ) ;
99+ } ) . then ( ( res ) => {
100+ var response = res . response ;
101+ expect ( response . results . length ) . toEqual ( 0 ) ;
102+ done ( ) ;
103+ } ) ;
104+ } ) ;
105+
106+ it ( 'query installations with count = 1' , ( done ) => {
107+ var androidDeviceRequest = {
108+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abc' ,
109+ 'deviceType' : 'android'
110+ } ;
111+ var iosDeviceRequest = {
112+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abd' ,
113+ 'deviceType' : 'ios'
114+ } ;
115+ var request = {
116+ config : config ,
117+ auth : auth . master ( config ) ,
118+ body : { } ,
119+ query : {
120+ count : 1
121+ }
122+ } ;
123+
124+ var router = new InstallationsRouter ( ) ;
125+ rest . create ( config , auth . nobody ( config ) , '_Installation' , androidDeviceRequest )
126+ . then ( ( ) => {
127+ return rest . create ( config , auth . nobody ( config ) , '_Installation' , iosDeviceRequest ) ;
128+ } ) . then ( ( ) => {
129+ return router . handleFind ( request ) ;
130+ } ) . then ( ( res ) => {
131+ var response = res . response ;
132+ expect ( response . results . length ) . toEqual ( 2 ) ;
133+ expect ( response . count ) . toEqual ( 2 ) ;
134+ done ( ) ;
135+ } ) ;
136+ } ) ;
137+
138+ it ( 'query installations with limit = 0 and count = 1' , ( done ) => {
139+ var androidDeviceRequest = {
140+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abc' ,
141+ 'deviceType' : 'android'
142+ } ;
143+ var iosDeviceRequest = {
144+ 'installationId' : '12345678-abcd-abcd-abcd-123456789abd' ,
145+ 'deviceType' : 'ios'
146+ } ;
147+ var request = {
148+ config : config ,
149+ auth : auth . master ( config ) ,
150+ body : { } ,
151+ query : {
152+ limit : 0 ,
153+ count : 1
154+ }
155+ } ;
156+
157+ var router = new InstallationsRouter ( ) ;
158+ rest . create ( config , auth . nobody ( config ) , '_Installation' , androidDeviceRequest )
159+ . then ( ( ) => {
160+ return rest . create ( config , auth . nobody ( config ) , '_Installation' , iosDeviceRequest ) ;
161+ } ) . then ( ( ) => {
162+ return router . handleFind ( request ) ;
163+ } ) . then ( ( res ) => {
164+ var response = res . response ;
165+ expect ( response . results . length ) . toEqual ( 0 ) ;
166+ expect ( response . count ) . toEqual ( 2 ) ;
167+ done ( ) ;
168+ } ) ;
169+ } ) ;
74170} ) ;
0 commit comments