Skip to content

Commit

Permalink
improve format
Browse files Browse the repository at this point in the history
  • Loading branch information
novakzaballa committed Jul 26, 2024
1 parent 5ab64ce commit a8e8b95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class Flagsmith {
* @param {string} identifier a unique identifier for the identity in the current
environment, e.g. email address, username, uuid
* @param {{[key:string]:any | ITraitConfig}} traits? a dictionary of traits to add / update on the identity in
Flagsmith, e.g. {"num_orders": 10} or {"age": {value: 30, transient: true}}
Flagsmith, e.g. {"num_orders": 10} or {age: {value: 30, transient: true}}
* @returns Flags object holding all the flags for the given identity.
*/
async getIdentityFlags(identifier: string, traits?: { [key: string]: any | ITraitConfig }, transient: boolean = false): Promise<Flags> {
Expand Down
6 changes: 6 additions & 0 deletions tests/sdk/data/identity-with-transient-traits.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"id": 1,
"trait_key": "some_trait",
"trait_value": "some_value"
},
{
"id": 2,
"trait_key": "transient_key",
"trait_value": "transient_value",
"transient": true
}
],
"flags": [
Expand Down
12 changes: 5 additions & 7 deletions tests/sdk/flagsmith-identity-flags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ test('test_transient_identity', async () => {
const identifier = 'transient_identifier';
const traits = { some_trait: 'some_value' };
const transient = true;

const flg = flagsmith();
const identityFlags = (await flg.getIdentityFlags(identifier, traits, transient)).allFlags();
expect(identityFlags[0].enabled).toBe(false);
Expand All @@ -175,13 +174,12 @@ test('test_transient_identity', async () => {
test('test_identity_with_transient_traits', async () => {
// @ts-ignore
fetch.mockReturnValue(Promise.resolve(new Response(identityWithTransientTraitsJSON())));
const identifier = 'identifier';
const identifier = 'transient_trait_identifier';
const traits = { some_trait: 'some_value', another_trait: {value: 'another_value', transient: true} };

const flg = flagsmith();

const identityFlags = (await flg.getIdentityFlags(identifier, traits)).allFlags();
expect(identityFlags[0].enabled).toBe(true);
expect(identityFlags[0].value).toBe('some-identity-with-transient-trait-value');
expect(identityFlags[0].featureName).toBe('some_feature');
const identityFlags = (await flg.getIdentityFlags(identifier, traits)).allFlags();
expect(identityFlags[0].enabled).toBe(true);
expect(identityFlags[0].value).toBe('some-identity-with-transient-trait-value');
expect(identityFlags[0].featureName).toBe('some_feature');
});

0 comments on commit a8e8b95

Please sign in to comment.