Skip to content

Commit ae372fa

Browse files
aarsilvclaude
andcommitted
Refactor offlineInit tests for clarity
- Rename "makes client available via getInstance()" to "can request assignment" - Move "no network requests" test into "basic initialization" section - Add assignment verification to "empty flags configuration" test Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1cf2815 commit ae372fa

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

src/index.spec.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ describe('offlineInit', () => {
10231023
expect(assignment).toEqual('default-value');
10241024
});
10251025

1026-
it('makes client available via getInstance()', () => {
1026+
it('can request assignment', () => {
10271027
offlineInit({
10281028
flagsConfiguration: createFlagsConfigJson({ [flagKey]: mockUfcFlagConfig }),
10291029
});
@@ -1032,6 +1032,16 @@ describe('offlineInit', () => {
10321032
const assignment = client.getStringAssignment(flagKey, 'subject-10', {}, 'default-value');
10331033
expect(assignment).toEqual('variant-1');
10341034
});
1035+
1036+
it('does not have configurationRequestParameters (no polling)', () => {
1037+
const client = offlineInit({
1038+
flagsConfiguration: createFlagsConfigJson({ [flagKey]: mockUfcFlagConfig }),
1039+
});
1040+
1041+
// Access the internal configurationRequestParameters - should be undefined for offline mode
1042+
const configurationRequestParameters = client['configurationRequestParameters'];
1043+
expect(configurationRequestParameters).toBeUndefined();
1044+
});
10351045
});
10361046

10371047
describe('assignment logging', () => {
@@ -1101,23 +1111,12 @@ describe('offlineInit', () => {
11011111
});
11021112

11031113
it('does not throw with valid empty flags configuration', () => {
1104-
expect(() => {
1105-
offlineInit({
1106-
flagsConfiguration: createFlagsConfigJson({}),
1107-
});
1108-
}).not.toThrow();
1109-
});
1110-
});
1111-
1112-
describe('no network requests', () => {
1113-
it('does not have configurationRequestParameters (no polling)', () => {
11141114
const client = offlineInit({
1115-
flagsConfiguration: createFlagsConfigJson({ [flagKey]: mockUfcFlagConfig }),
1115+
flagsConfiguration: createFlagsConfigJson({}),
11161116
});
11171117

1118-
// Access the internal configurationRequestParameters - should be undefined for offline mode
1119-
const configurationRequestParameters = client['configurationRequestParameters'];
1120-
expect(configurationRequestParameters).toBeUndefined();
1118+
const assignment = client.getStringAssignment(flagKey, 'subject-1', {}, 'default-value');
1119+
expect(assignment).toEqual('default-value');
11211120
});
11221121
});
11231122

0 commit comments

Comments
 (0)