Skip to content

Commit

Permalink
Merge pull request #1223 from OneSignal/fg/sync-fix
Browse files Browse the repository at this point in the history
Fix Sync Call
  • Loading branch information
fadi-george authored Feb 15, 2025
2 parents 385e37d + 4349444 commit 376bccb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module.exports = async () => {
forceExit: true,
bail: true,
testEnvironment: 'jsdom',
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
'^__test__/(.*)$': '<rootDir>/__test__/$1',
},
// Run these files after jest has been
// installed in the environment
setupFilesAfterEnv: ['<rootDir>/__test__/jest/jest.setup.ts'], // use .js if you prefer JavaScript,
Expand Down
6 changes: 6 additions & 0 deletions src/shared/api/OneSignalApiBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ export class OneSignalApiBase {
return isValidUuid(parts[1]);
}

// special case for sync
if (url.startsWith('sync/')) {
const parts = url.split('/');
return isValidUuid(parts[1]);
}

if (body && typeof body['app_id'] === 'string') {
return isValidUuid(body['app_id']);
}
Expand Down
11 changes: 11 additions & 0 deletions src/shared/api/OneSignalApiSW.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { APP_ID } from '__test__/support/constants';
import { OneSignalApiSW } from './OneSignalApiSW';

// Temporary, can remove when adding new tests to ServiceWorker.test.ts
describe('OneSignalApiSW', () => {
test('downloadServerAppConfig', async () => {
test.nock({});
const appConfig = await OneSignalApiSW.downloadServerAppConfig(APP_ID);
expect(appConfig).toBeDefined();
});
});

0 comments on commit 376bccb

Please sign in to comment.