@@ -4,6 +4,7 @@ import { assert } from 'chai'
4
4
import feathersVuex from '../../src/index'
5
5
import { feathersRestClient as feathersClient } from '../fixtures/feathers-client'
6
6
import Vuex from 'vuex'
7
+ import { isEmpty } from 'lodash'
7
8
8
9
const { makeAuthPlugin, makeServicePlugin, BaseModel } = feathersVuex (
9
10
feathersClient ,
@@ -209,4 +210,43 @@ describe('Auth Module', () => {
209
210
assert ( store . state . auth . isTrue === true , 'the custom action was run' )
210
211
} )
211
212
} )
213
+
214
+ it ( 'Calls auth service without params' , async function ( ) {
215
+ let receivedData = null
216
+ let receivedParams = null
217
+ feathersClient . use ( 'authentication' , {
218
+ create ( data , params ) {
219
+ receivedData = data
220
+ receivedParams = params
221
+ return Promise . resolve ( { accessToken : 'jg54jh2gj6fgh734j5h4j25jbh' } )
222
+ }
223
+ } )
224
+
225
+ const { store } = makeContext ( )
226
+
227
+ const request = { strategy : 'local' , email : 'test' , password : 'test' }
228
+ await store . dispatch ( 'auth/authenticate' , request )
229
+ assert ( receivedData , 'got data' )
230
+ assert ( receivedData . strategy === 'local' , 'got strategy' )
231
+ assert ( receivedData . email === 'test' , 'got email' )
232
+ assert ( receivedData . password === 'test' , 'got password' )
233
+ assert ( receivedParams && isEmpty ( receivedParams ) , 'empty params' )
234
+ } )
235
+
236
+ it ( 'Calls auth service with params' , async function ( ) {
237
+ let receivedParams = null
238
+ feathersClient . use ( 'authentication' , {
239
+ create ( data , params ) {
240
+ receivedParams = params
241
+ return Promise . resolve ( { accessToken : 'jg54jh2gj6fgh734j5h4j25jbh' } )
242
+ }
243
+ } )
244
+
245
+ const { store } = makeContext ( )
246
+
247
+ const request = { strategy : 'local' , email : 'test' , password : 'test' }
248
+ const customParams = { theAnswer : 42 }
249
+ await store . dispatch ( 'auth/authenticate' , [ request , customParams ] )
250
+ assert ( receivedParams && receivedParams . theAnswer === 42 , 'got params' )
251
+ } )
212
252
} )
0 commit comments