From a8e8b95241df039689534495dba5816559c24c6a Mon Sep 17 00:00:00 2001 From: Novak Zaballa Date: Fri, 26 Jul 2024 14:36:11 -0400 Subject: [PATCH] improve format --- sdk/index.ts | 2 +- tests/sdk/data/identity-with-transient-traits.json | 6 ++++++ tests/sdk/flagsmith-identity-flags.test.ts | 12 +++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sdk/index.ts b/sdk/index.ts index 9d1a5bb..8f96eec 100644 --- a/sdk/index.ts +++ b/sdk/index.ts @@ -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 { diff --git a/tests/sdk/data/identity-with-transient-traits.json b/tests/sdk/data/identity-with-transient-traits.json index 2db739f..de74da1 100644 --- a/tests/sdk/data/identity-with-transient-traits.json +++ b/tests/sdk/data/identity-with-transient-traits.json @@ -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": [ diff --git a/tests/sdk/flagsmith-identity-flags.test.ts b/tests/sdk/flagsmith-identity-flags.test.ts index 197f4c8..e062381 100644 --- a/tests/sdk/flagsmith-identity-flags.test.ts +++ b/tests/sdk/flagsmith-identity-flags.test.ts @@ -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); @@ -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'); });