Skip to content

Commit dc8c749

Browse files
committed
Remove dependency on uuid package
1 parent 88ad2e7 commit dc8c749

File tree

5 files changed

+9
-30
lines changed

5 files changed

+9
-30
lines changed

package-lock.json

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"react-router-dom": "^6.27.0",
5050
"reactstrap": "^9.2.3",
5151
"redux-localstorage-simple": "^2.5.1",
52-
"uuid": "^10.0.0",
5352
"workbox-core": "^7.1.0",
5453
"workbox-expiration": "^7.1.0",
5554
"workbox-precaching": "^7.1.0",

src/utils/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { SyntheticEvent } from 'react';
2-
import { v4 } from 'uuid';
32

43
export const handleEventPreventingDefault = <T>(handler: () => T) => (e: SyntheticEvent) => {
54
e.preventDefault();
65
handler();
76
};
8-
9-
export const randomUUID = () => v4();

test/servers/helpers/ImportServersBtn.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@ describe('<ImportServersBtn />', () => {
6868
{ btnName: 'Save anyway',savesDuplicatedServers: true },
6969
{ btnName: 'Discard', savesDuplicatedServers: false },
7070
])('creates expected servers depending on selected option in modal', async ({ btnName, savesDuplicatedServers }) => {
71-
const existingServer: ServerWithId = {
71+
const existingServerData: ServerData = {
7272
name: 'existingServer',
73-
id: 'existingserver-s.test',
7473
url: 'http://s.test/existingUrl',
7574
apiKey: 'existingApiKey',
7675
};
76+
const existingServer: ServerWithId = {
77+
...existingServerData,
78+
id: 'existingserver-s.test',
79+
};
7780
const newServer: ServerData = { name: 'newServer', url: 'http://s.test/newUrl', apiKey: 'newApiKey' };
7881
const { user } = setUp({}, { [existingServer.id]: existingServer });
7982

@@ -86,7 +89,7 @@ describe('<ImportServersBtn />', () => {
8689

8790
expect(createServersMock).toHaveBeenCalledWith(
8891
savesDuplicatedServers
89-
? [existingServer, expect.objectContaining(newServer)]
92+
? [expect.objectContaining(existingServerData), expect.objectContaining(newServer)]
9093
: [expect.objectContaining(newServer)],
9194
);
9295
expect(onImportMock).toHaveBeenCalledTimes(1);

test/servers/reducers/selectedServer.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
selectedServerReducerCreator,
1010
selectServer as selectServerCreator,
1111
} from '../../../src/servers/reducers/selectedServer';
12-
import { randomUUID } from '../../../src/utils/utils';
1312

1413
describe('selectedServerReducer', () => {
1514
const dispatch = vi.fn();
@@ -41,7 +40,7 @@ describe('selectedServerReducer', () => {
4140
['latest', MAX_FALLBACK_VERSION, 'latest'],
4241
['%invalid_semver%', MIN_FALLBACK_VERSION, '%invalid_semver%'],
4342
])('dispatches proper actions', async (serverVersion, expectedVersion, expectedPrintableVersion) => {
44-
const id = randomUUID();
43+
const id = crypto.randomUUID();
4544
const getState = createGetStateMock(id);
4645
const expectedSelectedServer = {
4746
id,
@@ -60,7 +59,7 @@ describe('selectedServerReducer', () => {
6059
});
6160

6261
it('dispatches error when health endpoint fails', async () => {
63-
const id = randomUUID();
62+
const id = crypto.randomUUID();
6463
const getState = createGetStateMock(id);
6564
const expectedSelectedServer = fromPartial<NonReachableServer>({ id, serverNotReachable: true });
6665

@@ -73,7 +72,7 @@ describe('selectedServerReducer', () => {
7372
});
7473

7574
it('dispatches error when server is not found', async () => {
76-
const id = randomUUID();
75+
const id = crypto.randomUUID();
7776
const getState = vi.fn(() => fromPartial<ShlinkState>({ servers: {} }));
7877
const expectedSelectedServer: NotFoundServer = { serverNotFound: true };
7978

0 commit comments

Comments
 (0)