Skip to content

Commit

Permalink
Use uuid instead of crypto for UUID generating (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
pandzicivan authored Jan 4, 2024
1 parent 289cd0f commit a2a06af
Show file tree
Hide file tree
Showing 5 changed files with 1,554 additions and 1,288 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
/dist
.idea
.DS_Store
9 changes: 3 additions & 6 deletions __tests__/phrase.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {describe, expect, test} from '@jest/globals';
import Phrase, {PHRASE_SDK_VERSION} from '../src/phrase';

Object.defineProperty(globalThis, 'crypto', {
value: {
randomUUID: () => 'MY_UUID',
}
});
const V4_UUID = "b54f7566-6d85-4d97-9960-2ad82edfe317";
jest.mock('uuid', () => ({ v4: () => V4_UUID }));

describe('requestTranslations', () => {
const phrase = new Phrase({
Expand Down Expand Up @@ -57,7 +54,7 @@ describe('requestTranslations', () => {
test('the request is executed with proper parameters', async () => {
await phrase.requestTranslations('en');
expect(fetchMock).toHaveBeenCalledWith(
new URL(`https://ota.eu.phrase.com/MY_DISTRIBUTION/MY_SECRET/en/i18next?client=i18next&sdk_version=${PHRASE_SDK_VERSION}&unique_identifier=MY_UUID`),
new URL(`https://ota.eu.phrase.com/MY_DISTRIBUTION/MY_SECRET/en/i18next?client=i18next&sdk_version=${PHRASE_SDK_VERSION}&unique_identifier=${V4_UUID}`),
expect.anything(),
);
});
Expand Down
Loading

0 comments on commit a2a06af

Please sign in to comment.