@@ -16,7 +16,7 @@ import _omit from 'lodash/omit'
16
16
17
17
Vue . use ( Vuex )
18
18
19
- describe ( 'makeServicePlugin' , function ( ) {
19
+ describe ( 'makeServicePlugin' , function ( ) {
20
20
beforeEach ( ( ) => {
21
21
clearModels ( )
22
22
} )
@@ -28,29 +28,30 @@ describe('makeServicePlugin', function() {
28
28
assert ( clients . byAlias [ 'this is a test' ] , 'got a reference to the client.' )
29
29
} )
30
30
31
- it ( 'registers the vuex module with options' , function ( ) {
31
+ it ( 'registers the vuex module with options' , function ( ) {
32
32
interface RootState {
33
33
todos : { }
34
34
}
35
35
36
- const serverAlias = 'default '
36
+ const serverAlias = 'make-service-plugin '
37
37
const { makeServicePlugin, BaseModel } = feathersVuex ( feathers , {
38
38
serverAlias
39
39
} )
40
- const servicePath = 'todos'
40
+ const servicePath = 'make-service-plugin- todos'
41
41
class Todo extends BaseModel {
42
42
public static modelName = 'Todo'
43
43
public static servicePath = servicePath
44
44
}
45
45
const todosPlugin = makeServicePlugin ( {
46
46
servicePath,
47
47
Model : Todo ,
48
- service : feathers . service ( servicePath )
48
+ service : feathers . service ( servicePath ) ,
49
+ namespace : 'make-service-plugin-todos'
49
50
} )
50
51
const store = new Vuex . Store < RootState > ( { plugins : [ todosPlugin ] } )
51
52
52
- const keys = Object . keys ( store . state . todos )
53
- const received = _pick ( store . state . todos , keys )
53
+ const keys = Object . keys ( store . state [ 'make-service-plugin- todos' ] )
54
+ const received = _pick ( store . state [ 'make-service-plugin- todos' ] , keys )
54
55
const expected = {
55
56
addOnUpsert : false ,
56
57
autoRemove : false ,
@@ -76,16 +77,16 @@ describe('makeServicePlugin', function() {
76
77
keyedById : { } ,
77
78
modelName : 'Todo' ,
78
79
nameStyle : 'short' ,
79
- namespace : 'todos' ,
80
+ namespace : 'make-service-plugin- todos' ,
80
81
pagination : {
81
82
defaultLimit : null ,
82
83
defaultSkip : null
83
84
} ,
84
85
paramsForServer : [ '$populateParams' ] ,
85
86
preferUpdate : false ,
86
87
replaceItems : false ,
87
- serverAlias : 'default ' ,
88
- servicePath : 'todos' ,
88
+ serverAlias : 'make-service-plugin ' ,
89
+ servicePath : 'make-service-plugin- todos' ,
89
90
skipRequestIfExists : false ,
90
91
tempsById : { } ,
91
92
whitelist : [ ]
@@ -94,13 +95,13 @@ describe('makeServicePlugin', function() {
94
95
assert . deepEqual ( _omit ( received ) , _omit ( expected ) , 'defaults in place.' )
95
96
} )
96
97
97
- it ( 'sets up Model.store && service.FeathersVuexModel' , function ( ) {
98
- const serverAlias = 'default '
98
+ it ( 'sets up Model.store && service.FeathersVuexModel' , function ( ) {
99
+ const serverAlias = 'make-service-plugin '
99
100
const { makeServicePlugin, BaseModel } = feathersVuex ( feathers , {
100
101
serverAlias
101
102
} )
102
103
103
- const servicePath = 'todos'
104
+ const servicePath = 'make-service-plugin- todos'
104
105
const service = feathers . service ( servicePath )
105
106
class Todo extends BaseModel {
106
107
public static modelName = 'Todo'
@@ -114,14 +115,14 @@ describe('makeServicePlugin', function() {
114
115
assert . equal ( service . FeathersVuexModel , Todo , 'Model accessible on service' )
115
116
} )
116
117
117
- it ( 'allows accessing other models' , function ( ) {
118
- const serverAlias = 'default '
118
+ it ( 'allows accessing other models' , function ( ) {
119
+ const serverAlias = 'make-service-plugin '
119
120
const { makeServicePlugin, BaseModel, models } = feathersVuex ( feathers , {
120
121
idField : '_id' ,
121
122
serverAlias
122
123
} )
123
124
124
- const servicePath = 'todos'
125
+ const servicePath = 'make-service-plugin- todos'
125
126
class Todo extends BaseModel {
126
127
public static modelName = 'Todo'
127
128
public static servicePath = servicePath
@@ -140,18 +141,19 @@ describe('makeServicePlugin', function() {
140
141
assert ( Todo . store === store )
141
142
} )
142
143
143
- it ( 'allows service specific handleEvents' , async function ( ) {
144
+ it ( 'allows service specific handleEvents' , async function ( ) {
144
145
// feathers.use('todos', new TodosService())
145
- const serverAlias = 'default '
146
+ const serverAlias = 'make-service-plugin '
146
147
const { makeServicePlugin, BaseModel } = feathersVuex ( feathers , {
147
148
idField : '_id' ,
148
149
serverAlias
149
150
} )
150
151
151
- const servicePath = 'todos'
152
+ const servicePath = 'make-service-plugin- todos'
152
153
class Todo extends BaseModel {
153
154
public static modelName = 'Todo'
154
155
public static servicePath = servicePath
156
+ public static namespace = 'make-service-plugin-todos'
155
157
}
156
158
157
159
let createdCalled = false
@@ -189,7 +191,7 @@ describe('makeServicePlugin', function() {
189
191
const todo = new Todo ( )
190
192
191
193
// Fake server call
192
- feathers . service ( 'todos' ) . hooks ( {
194
+ feathers . service ( 'make-service-plugin- todos' ) . hooks ( {
193
195
before : {
194
196
create : [
195
197
context => {
@@ -235,9 +237,9 @@ describe('makeServicePlugin', function() {
235
237
assert ( removedCalled , 'removed handler called' )
236
238
} )
237
239
238
- it ( 'fall back to globalOptions handleEvents if service specific handleEvents handler is missing' , async function ( ) {
240
+ it ( 'fall back to globalOptions handleEvents if service specific handleEvents handler is missing' , async function ( ) {
239
241
// feathers.use('todos', new TodosService())
240
- const serverAlias = 'default '
242
+ const serverAlias = 'make-service-plugin '
241
243
242
244
let globalCreatedCalled = false
243
245
let globalUpdatedCalled = false
@@ -266,17 +268,19 @@ describe('makeServicePlugin', function() {
266
268
}
267
269
} )
268
270
269
- const servicePath = 'todos'
271
+ const servicePath = 'make-service-plugin- todos'
270
272
class Todo extends BaseModel {
271
273
public static modelName = 'Todo'
272
274
public static servicePath = servicePath
275
+ public static namespace = 'make-service-plugin-todos'
273
276
}
274
277
275
278
let specificUpdatedCalled = false
276
279
const todosPlugin = makeServicePlugin ( {
277
280
servicePath,
278
281
Model : Todo ,
279
282
service : feathers . service ( servicePath ) ,
283
+ namespace : 'make-service-plugin-todos' ,
280
284
handleEvents : {
281
285
updated ( ) {
282
286
specificUpdatedCalled = true
@@ -292,7 +296,7 @@ describe('makeServicePlugin', function() {
292
296
const todo = new Todo ( )
293
297
294
298
// Fake server call
295
- feathers . service ( 'todos' ) . hooks ( {
299
+ feathers . service ( 'make-service-plugin- todos' ) . hooks ( {
296
300
before : {
297
301
create : [
298
302
context => {
@@ -339,8 +343,8 @@ describe('makeServicePlugin', function() {
339
343
assert ( globalRemovedCalled , 'global removed handler called' )
340
344
} )
341
345
342
- it ( 'allow handleEvents handlers to return extracted event data' , async function ( ) {
343
- const serverAlias = 'default '
346
+ it ( 'allow handleEvents handlers to return extracted event data' , async function ( ) {
347
+ const serverAlias = 'make-service-plugin '
344
348
345
349
const { makeServicePlugin, BaseModel } = feathersVuex ( feathers , {
346
350
idField : '_id' ,
@@ -361,7 +365,7 @@ describe('makeServicePlugin', function() {
361
365
}
362
366
} )
363
367
364
- const servicePath = 'todos'
368
+ const servicePath = 'make-service-plugin- todos'
365
369
class Todo extends BaseModel {
366
370
public static modelName = 'Todo'
367
371
public static servicePath = servicePath
@@ -371,13 +375,14 @@ describe('makeServicePlugin', function() {
371
375
const todosPlugin = makeServicePlugin ( {
372
376
servicePath,
373
377
Model : Todo ,
374
- service : todosService
378
+ service : todosService ,
379
+ namespace : 'make-service-plugin-todos'
375
380
} )
376
381
377
382
const store = new Vuex . Store < { todos : ServiceState } > ( {
378
383
plugins : [ todosPlugin ]
379
384
} )
380
- const { keyedById } = store . state . todos
385
+ const { keyedById } = store . state [ 'make-service-plugin- todos' ]
381
386
382
387
let createdData = null
383
388
let updatedData = null
0 commit comments