Skip to content

Commit

Permalink
chore: Add support for user-type contract tests. (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Jul 6, 2023
1 parent 2578905 commit eda8371
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion contract-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ app.get('/', (req, res) => {
'all-flags-details-only-for-tracked-flags',
'all-flags-with-reasons',
'tags',
'big-segments'
'big-segments',
'user-type'
],
});
});
Expand Down
10 changes: 5 additions & 5 deletions contract-tests/sdkClientEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export async function newSdkClientEntity(options) {
case 'evaluate': {
const pe = params.evaluate;
if (pe.detail) {
return await client.variationDetail(pe.flagKey, pe.context, pe.defaultValue);
return await client.variationDetail(pe.flagKey, pe.context || pe.user, pe.defaultValue);
} else {
const value = await client.variation(pe.flagKey, pe.context, pe.defaultValue);
const value = await client.variation(pe.flagKey, pe.context || pe.user, pe.defaultValue);
return { value };
}
}
Expand All @@ -104,16 +104,16 @@ export async function newSdkClientEntity(options) {
detailsOnlyForTrackedFlags: pea.detailsOnlyForTrackedFlags,
withReasons: pea.withReasons,
};
return { state: await client.allFlagsState(pea.context, eao) };
return { state: await client.allFlagsState(pea.context || pea.user, eao) };
}

case 'identifyEvent':
client.identify(params.identifyEvent.context);
client.identify(params.identifyEvent.context || params.identifyEvent.user);
return undefined;

case 'customEvent': {
const pce = params.customEvent;
client.track(pce.eventKey, pce.context, pce.data, pce.metricValue);
client.track(pce.eventKey, pce.context || pce.user, pce.data, pce.metricValue);
return undefined;
}

Expand Down

0 comments on commit eda8371

Please sign in to comment.