Skip to content

Commit 41f849e

Browse files
kai687shortcutsmillotp
authoredAug 28, 2024··
fix(specs): partial update operation (#3486)
Co-authored-by: shortcuts <vannicattec@gmail.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent a278d2f commit 41f849e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+460
-665
lines changed
 

‎clients/algoliasearch-client-javascript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build:many": "lerna run build --skip-nx-cache --include-dependencies --scope ${0:-'{@algolia/*,algoliasearch}'}",
1111
"clean": "lerna run clean --include-dependencies",
1212
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
13-
"release:publish": "tsc --project tsconfig.script.json && node dist/scripts/publish.js",
13+
"release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/scripts/publish.js",
1414
"test": "lerna run test $*",
1515
"test:size": "bundlesize"
1616
},

‎clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/cache/browser-local-storage-cache.test.ts

+14-31
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@ describe('browser local storage cache', () => {
2626
const cache = createBrowserLocalStorageCache({ key: version });
2727
const defaultValue = (): DefaultValue => Promise.resolve({ bar: 1 });
2828

29-
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject(
30-
{ bar: 1 }
31-
);
29+
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject({ bar: 1 });
3230
expect(missMock.mock.calls.length).toBe(1);
3331

3432
await cache.set({ key: 'foo' }, { foo: 2 });
3533

36-
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject(
37-
{ foo: 2 }
38-
);
34+
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject({ foo: 2 });
3935
expect(missMock.mock.calls.length).toBe(1);
4036
});
4137

@@ -51,7 +47,7 @@ describe('browser local storage cache', () => {
5147
expect(
5248
await cache.get({ key: 'foo' }, defaultValue, {
5349
miss: () => Promise.resolve(missMock()),
54-
})
50+
}),
5551
).toMatchObject({ bar: 1 });
5652

5753
expect(missMock.mock.calls.length).toBe(0);
@@ -65,9 +61,7 @@ describe('browser local storage cache', () => {
6561

6662
const defaultValue = (): DefaultValue => Promise.resolve({ bar: 2 });
6763

68-
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject(
69-
{ bar: 2 }
70-
);
64+
expect(await cache.get({ key: 'foo' }, defaultValue, events)).toMatchObject({ bar: 2 });
7165
expect(missMock.mock.calls.length).toBe(1);
7266
});
7367

@@ -83,7 +77,7 @@ describe('browser local storage cache', () => {
8377
expect(
8478
await cache.get({ key: 'foo' }, defaultValue, {
8579
miss: () => Promise.resolve(missMock()),
86-
})
80+
}),
8781
).toMatchObject({ bar: 2 });
8882

8983
expect(missMock.mock.calls.length).toBe(1);
@@ -102,7 +96,7 @@ describe('browser local storage cache', () => {
10296
expect(
10397
await cache.get({ key: 'foo' }, defaultValue, {
10498
miss: () => Promise.resolve(missMock()),
105-
})
99+
}),
106100
).toMatchObject({ bar: 2 });
107101

108102
expect(missMock.mock.calls.length).toBe(1);
@@ -111,8 +105,7 @@ describe('browser local storage cache', () => {
111105
});
112106

113107
it('do throws localstorage exceptions on access', async () => {
114-
const message =
115-
"Failed to read the 'localStorage' property from 'Window': Access is denied for this document.";
108+
const message = "Failed to read the 'localStorage' property from 'Window': Access is denied for this document.";
116109
const cache = createBrowserLocalStorageCache(
117110
new Proxy(
118111
{ key: 'foo' },
@@ -125,20 +118,16 @@ describe('browser local storage cache', () => {
125118
// Simulates a window.localStorage access.
126119
throw new DOMException(message);
127120
},
128-
}
129-
)
121+
},
122+
),
130123
);
131124
const key = { foo: 'bar' };
132125
const value = 'foo';
133126
const fallback = 'bar';
134127

135128
await expect(cache.delete(key)).rejects.toEqual(new DOMException(message));
136-
await expect(cache.set(key, value)).rejects.toEqual(
137-
new DOMException(message)
138-
);
139-
await expect(
140-
cache.get(key, () => Promise.resolve(fallback))
141-
).rejects.toEqual(new DOMException(message));
129+
await expect(cache.set(key, value)).rejects.toEqual(new DOMException(message));
130+
await expect(cache.get(key, () => Promise.resolve(fallback))).rejects.toEqual(new DOMException(message));
142131
});
143132

144133
it('do throws localstorage exceptions after access', async () => {
@@ -153,9 +142,7 @@ describe('browser local storage cache', () => {
153142

154143
await expect(cache.delete(key)).rejects.toEqual(new Error(message));
155144
await expect(cache.set(key, value)).rejects.toEqual(new Error(message));
156-
await expect(
157-
cache.get(key, () => Promise.resolve(fallback))
158-
).rejects.toEqual(new Error(message));
145+
await expect(cache.get(key, () => Promise.resolve(fallback))).rejects.toEqual(new Error(message));
159146
});
160147

161148
it('creates a namespace within local storage', async () => {
@@ -175,12 +162,8 @@ describe('browser local storage cache', () => {
175162
},
176163
});
177164

178-
const localStorageValue = localStorage.getItem(
179-
`algolia-client-js-${version}`
180-
);
165+
const localStorageValue = localStorage.getItem(`algolia-client-js-${version}`);
181166

182-
expect(JSON.parse(localStorageValue ? localStorageValue : '{}')).toEqual(
183-
expectedValue
184-
);
167+
expect(JSON.parse(localStorageValue ? localStorageValue : '{}')).toEqual(expectedValue);
185168
});
186169
});

0 commit comments

Comments
 (0)
Please sign in to comment.