Skip to content

Commit

Permalink
Update ts-test
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Dec 11, 2024
1 parent d257562 commit f4c2de6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/__tests__/nodeSuites/lazy-init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ export default function (settings, fetchMock, t) {
fetchMock.getOnce('https://not-called/api/splitChanges?s=1.1&since=1457552620999', { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.postOnce('https://not-called/api/testImpressions/bulk', 200);
fetchMock.postOnce('https://not-called/api/events/bulk', 200);
fetchMock.get('https://not-called/api/v2/auth?s=1.1', 200);

// Validate that init and destroy are idempotent
for (let i = 0; i < 3; i++) { splitio.init(); splitio.init(); splitio.destroy(); splitio.destroy(); }

splitio.init();
await splitio.client().ready();
assert.true(splitio.client().__getStatus().isReady, 'Split SDK is ready');

assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: false, isOperational: true, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

await splitio.destroy();
assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: true, isOperational: false, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

splitio.init();

assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: false, isOperational: true, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

await splitio.destroy();

assert.end();
Expand Down Expand Up @@ -81,13 +91,23 @@ export default function (settings, fetchMock, t) {
fetchMock.getOnce('https://not-called/api/memberships/other-user', { status: 200, body: {} });
fetchMock.postOnce('https://not-called/api/testImpressions/bulk', 200);
fetchMock.postOnce('https://not-called/api/events/bulk', 200);
fetchMock.get('https://not-called/api/v2/auth?s=1.2&users=user-99', 200);

// Validate that init and destroy are idempotent
for (let i = 0; i < 3; i++) { splitio.init(); splitio.init(); splitio.destroy(); splitio.destroy(); }

splitio.init();
await splitio.client().ready();
assert.true(splitio.client().__getStatus().isReady, 'Split SDK is ready');

assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: false, isOperational: true, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

await splitio.destroy();
assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: true, isOperational: false, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

splitio.init();

assert.deepEqual(splitio.client().__getStatus(), { isReady: true, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: false, isOperational: true, lastUpdate: splitio.client().__getStatus().lastUpdate }, 'Status');

await splitio.destroy();

assert.end();
Expand Down
3 changes: 2 additions & 1 deletion ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ splitView = {
off: '{"dimensions":"{\"height\":20,\"width\":40}"}'
},
sets: ['set_a', 'set_b'],
defaultTreatment: 'off'
defaultTreatment: 'off',
trackImpressions: true
};
splitViews = [splitView];

Expand Down

0 comments on commit f4c2de6

Please sign in to comment.