3
3
@typescript -eslint/explicit-function-return-type: 0,
4
4
@typescript -eslint/no-explicit-any: 0
5
5
*/
6
- import jsdom from 'jsdom-global'
7
6
import { assert } from 'chai'
8
- import feathersVuex , { FeathersVuex } from '../src/index'
9
- import { feathersRestClient as feathersClient } from './fixtures/feathers-client'
10
- import makeFindMixin from '../src/make-find-mixin'
7
+ import jsdom from 'jsdom-global'
11
8
import Vue from 'vue/dist/vue'
12
9
import Vuex from 'vuex'
10
+ import feathersVuex , { FeathersVuex } from '../src/index'
11
+ import makeFindMixin from '../src/make-find-mixin'
12
+ import { feathersRestClient as feathersClient } from './fixtures/feathers-client'
13
13
14
14
jsdom ( )
15
15
require ( 'events' ) . EventEmitter . prototype . _maxListeners = 100
@@ -44,7 +44,7 @@ describe('Find Mixin', function() {
44
44
45
45
it ( 'correctly forms mixin data' , function ( ) {
46
46
const todosMixin = makeFindMixin ( { service : 'todos' } )
47
-
47
+ // todosMixin.
48
48
interface TodosComponent {
49
49
todos : [ ]
50
50
todosServiceName : string
@@ -80,6 +80,10 @@ describe('Find Mixin', function() {
80
80
assert ( vm . haveTodosLoadedOnce === false , 'loaded once boolean is in place' )
81
81
assert ( typeof vm . findTodos === 'function' , 'the find action is in place' )
82
82
assert ( vm . todosLocal === false , 'local boolean is false by default' )
83
+ assert (
84
+ typeof vm . $options . created [ 0 ] === 'function' ,
85
+ 'created lifecycle hook function is in place given that local is false'
86
+ )
83
87
assert (
84
88
vm . todosQid === 'default' ,
85
89
'the default query identifier is in place'
@@ -96,11 +100,12 @@ describe('Find Mixin', function() {
96
100
)
97
101
} )
98
102
99
- it . skip ( 'correctly forms mixin data for dynamic service' , function ( ) {
103
+ it ( 'correctly forms mixin data for dynamic service' , function ( ) {
100
104
const tasksMixin = makeFindMixin ( {
101
105
service ( ) {
102
106
return this . serviceName
103
- }
107
+ } ,
108
+ local : true
104
109
} )
105
110
106
111
interface TasksComponent {
@@ -116,7 +121,7 @@ describe('Find Mixin', function() {
116
121
}
117
122
118
123
const vm = new Vue ( {
119
- name : 'tasls -component' ,
124
+ name : 'tasks -component' ,
120
125
data : ( ) => ( {
121
126
serviceName : 'tasks'
122
127
} ) ,
@@ -125,27 +130,31 @@ describe('Find Mixin', function() {
125
130
template : `<div></div>`
126
131
} ) . $mount ( )
127
132
128
- assert . deepEqual ( vm . tasks , [ ] , 'tasks prop was empty array' )
133
+ assert . deepEqual ( vm . items , [ ] , 'items prop was empty array' )
129
134
assert (
130
- vm . hasOwnProperty ( 'tasksPaginationData ' ) ,
135
+ vm . hasOwnProperty ( 'servicePaginationData ' ) ,
131
136
'pagination data prop was present, even if undefined'
132
137
)
133
- assert ( vm . tasksServiceName === 'tasks' , 'service name was correct' )
134
- assert ( vm . isFindTasksPending === false , 'loading boolean is in place' )
135
- assert ( typeof vm . findTasks === 'function' , 'the find action is in place' )
136
- assert ( vm . tasksLocal === false , 'local boolean is false by default' )
138
+ assert ( vm . serviceServiceName === 'tasks' , 'service name was correct' )
139
+ assert ( vm . isFindServicePending === false , 'loading boolean is in place' )
140
+ assert ( typeof vm . findService === 'function' , 'the find action is in place' )
141
+ assert ( vm . serviceLocal === true , 'local boolean is set to true' )
142
+ assert (
143
+ typeof vm . $options . created === 'undefined' ,
144
+ 'created lifecycle hook function is NOT in place given that local is true'
145
+ )
137
146
assert (
138
- vm . tasksQid === 'default' ,
147
+ vm . serviceQid === 'default' ,
139
148
'the default query identifier is in place'
140
149
)
141
- assert ( vm . tasksQueryWhen ( ) === true , 'the default queryWhen is true' )
150
+ assert ( vm . serviceQueryWhen === true , 'the default queryWhen is true' )
142
151
// assert(vm.tasksWatch.length === 0, 'the default watch is an empty array')
143
152
assert (
144
- vm . tasksParams === undefined ,
153
+ vm . serviceParams === undefined ,
145
154
'no params are in place by default, must be specified by the user'
146
155
)
147
156
assert (
148
- vm . tasksFetchParams === undefined ,
157
+ vm . serviceFetchParams === undefined ,
149
158
'no fetch params are in place by default, must be specified by the user'
150
159
)
151
160
} )
0 commit comments