Skip to content

Commit 5ae7627

Browse files
committed
Add a test for plain object params
1 parent 3e8e0b0 commit 5ae7627

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

test/use/find.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,65 @@ describe('use/find', function() {
106106
assert(qid.value === 'default')
107107
})
108108

109+
it('returns correct default data even when params is not reactive', function() {
110+
const { Instrument } = makeContext()
111+
112+
const instrumentsData = useFind({
113+
model: Instrument,
114+
params: {
115+
query: {},
116+
paginate: false
117+
}
118+
})
119+
120+
const {
121+
debounceTime,
122+
error,
123+
haveBeenRequested,
124+
haveLoaded,
125+
isPending,
126+
isLocal,
127+
items,
128+
latestQuery,
129+
paginationData,
130+
qid
131+
} = instrumentsData
132+
133+
assert(isRef(debounceTime))
134+
assert(debounceTime.value === null)
135+
136+
assert(isRef(error))
137+
assert(error.value === null)
138+
139+
assert(isRef(haveBeenRequested))
140+
assert(haveBeenRequested.value === true)
141+
142+
assert(isRef(haveLoaded))
143+
assert(haveLoaded.value === false)
144+
145+
assert(isRef(isPending))
146+
assert(isPending.value === true)
147+
148+
assert(isRef(isLocal))
149+
assert(isLocal.value === false)
150+
151+
assert(isRef(items))
152+
assert(Array.isArray(items.value))
153+
assert(items.value.length === 0)
154+
155+
assert(isRef(latestQuery))
156+
assert(latestQuery.value === null)
157+
158+
assert(isRef(paginationData))
159+
assert.deepStrictEqual(paginationData.value, {
160+
defaultLimit: null,
161+
defaultSkip: null
162+
})
163+
164+
assert(isRef(qid))
165+
assert(qid.value === 'default')
166+
})
167+
109168
it('allows passing {lazy:true} to not query immediately', function() {
110169
const { Instrument } = makeContext()
111170

0 commit comments

Comments
 (0)