Skip to content

Commit c438912

Browse files
authored
fix!: set isLoading to false when id is undefined (#53)
1 parent f28832e commit c438912

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/useGet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export default <CustomApplication extends Application>(feathers: CustomApplicati
8484
isLoading.value = true;
8585
if (!_id.value) {
8686
data.value = undefined;
87+
isLoading.value = false;
8788
return;
8889
}
8990
// TODO: the typecast below is necessary due to the prerelease state of feathers v5. The problem there is

test/useGet.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('Get composition', () => {
179179
});
180180

181181
it('should un-load data after id changes to undefined', async () => {
182-
expect.assertions(4);
182+
expect.assertions(5);
183183

184184
// given
185185
const testModelId = ref<TestModel['_id'] | undefined>(testModel._id);
@@ -215,10 +215,11 @@ describe('Get composition', () => {
215215
// then
216216
expect(serviceGet).toHaveBeenCalledTimes(1);
217217
expect(getComposition).toBeTruthy();
218+
expect(getComposition && getComposition.isLoading.value).toBeFalsy();
218219
expect(getComposition && getComposition.data.value).toBeUndefined();
219220
});
220221

221-
it('should indicate loading when id is undefined and load data after changing to a valid id', async () => {
222+
it('should return undefined when id is undefined and load data after changing to a valid id', async () => {
222223
expect.assertions(5);
223224

224225
// given
@@ -246,7 +247,7 @@ describe('Get composition', () => {
246247

247248
// before then to ensure that the previous loading procedure is completed
248249
await nextTick();
249-
expect(getComposition && getComposition.isLoading).toBeTruthy();
250+
expect(getComposition && getComposition.isLoading.value).toBeFalsy();
250251
expect(getComposition && getComposition.data.value).toBeUndefined();
251252

252253
// when

0 commit comments

Comments
 (0)