44 LDSingleKindContext ,
55} from '@launchdarkly/js-client-sdk-common' ;
66
7- import { BrowserClient } from '../src/BrowserClient' ;
7+ import { makeClient } from '../src/BrowserClient' ;
88import { makeBasicPlatform } from './BrowserClient.mocks' ;
99import { goodBootstrapDataWithReasons } from './testBootstrapData' ;
1010
@@ -27,7 +27,7 @@ describe('given a mock platform for a BrowserClient', () => {
2727 } ) ;
2828
2929 it ( 'includes urls in custom events' , async ( ) => {
30- const client = new BrowserClient (
30+ const client = makeClient (
3131 'client-side-id' ,
3232 AutoEnvAttributes . Disabled ,
3333 {
@@ -56,7 +56,7 @@ describe('given a mock platform for a BrowserClient', () => {
5656 } ) ;
5757
5858 it ( 'can filter URLs in custom events' , async ( ) => {
59- const client = new BrowserClient (
59+ const client = makeClient (
6060 'client-side-id' ,
6161 AutoEnvAttributes . Disabled ,
6262 {
@@ -90,7 +90,7 @@ describe('given a mock platform for a BrowserClient', () => {
9090 } ) ;
9191
9292 it ( 'can filter URLs in click events' , async ( ) => {
93- const client = new BrowserClient (
93+ const client = makeClient (
9494 'client-side-id' ,
9595 AutoEnvAttributes . Disabled ,
9696 {
@@ -133,7 +133,7 @@ describe('given a mock platform for a BrowserClient', () => {
133133 } ) ;
134134
135135 it ( 'can filter URLs in pageview events' , async ( ) => {
136- const client = new BrowserClient (
136+ const client = makeClient (
137137 'client-side-id' ,
138138 AutoEnvAttributes . Disabled ,
139139 {
@@ -163,7 +163,7 @@ describe('given a mock platform for a BrowserClient', () => {
163163 } ) ;
164164
165165 it ( 'can use bootstrap data' , async ( ) => {
166- const client = new BrowserClient (
166+ const client = makeClient (
167167 'client-side-id' ,
168168 AutoEnvAttributes . Disabled ,
169169 {
@@ -189,17 +189,17 @@ describe('given a mock platform for a BrowserClient', () => {
189189 } ) ;
190190 } ) ;
191191
192- it ( 'can shed intermediate identifyResult calls' , async ( ) => {
193- const client = new BrowserClient (
192+ it ( 'can shed intermediate identify calls' , async ( ) => {
193+ const client = makeClient (
194194 'client-side-id' ,
195195 AutoEnvAttributes . Disabled ,
196196 { streaming : false , logger, diagnosticOptOut : true , sendEvents : false , fetchGoals : false } ,
197197 platform ,
198198 ) ;
199199
200- const promise1 = client . identifyResult ( { key : 'user-key-1' , kind : 'user' } ) ;
201- const promise2 = client . identifyResult ( { key : 'user-key-2' , kind : 'user' } ) ;
202- const promise3 = client . identifyResult ( { key : 'user-key-3' , kind : 'user' } ) ;
200+ const promise1 = client . identify ( { key : 'user-key-1' , kind : 'user' } ) ;
201+ const promise2 = client . identify ( { key : 'user-key-2' , kind : 'user' } ) ;
202+ const promise3 = client . identify ( { key : 'user-key-3' , kind : 'user' } ) ;
203203
204204 const [ result1 , result2 , result3 ] = await Promise . all ( [ promise1 , promise2 , promise3 ] ) ;
205205
@@ -212,7 +212,7 @@ describe('given a mock platform for a BrowserClient', () => {
212212
213213 it ( 'calls beforeIdentify in order' , async ( ) => {
214214 const order : string [ ] = [ ] ;
215- const client = new BrowserClient (
215+ const client = makeClient (
216216 'client-side-id' ,
217217 AutoEnvAttributes . Disabled ,
218218 {
@@ -250,7 +250,7 @@ describe('given a mock platform for a BrowserClient', () => {
250250
251251 it ( 'completes identify calls in order' , async ( ) => {
252252 const order : string [ ] = [ ] ;
253- const client = new BrowserClient (
253+ const client = makeClient (
254254 'client-side-id' ,
255255 AutoEnvAttributes . Disabled ,
256256 {
@@ -292,7 +292,7 @@ describe('given a mock platform for a BrowserClient', () => {
292292
293293 it ( 'completes awaited identify calls in order without shedding' , async ( ) => {
294294 const order : string [ ] = [ ] ;
295- const client = new BrowserClient (
295+ const client = makeClient (
296296 'client-side-id' ,
297297 AutoEnvAttributes . Disabled ,
298298 {
@@ -323,9 +323,9 @@ describe('given a mock platform for a BrowserClient', () => {
323323 platform ,
324324 ) ;
325325
326- const result1 = await client . identifyResult ( { key : 'user-key-1' , kind : 'user' } ) ;
327- const result2 = await client . identifyResult ( { key : 'user-key-2' , kind : 'user' } ) ;
328- const result3 = await client . identifyResult ( { key : 'user-key-3' , kind : 'user' } ) ;
326+ const result1 = await client . identify ( { key : 'user-key-1' , kind : 'user' } ) ;
327+ const result2 = await client . identify ( { key : 'user-key-2' , kind : 'user' } ) ;
328+ const result3 = await client . identify ( { key : 'user-key-3' , kind : 'user' } ) ;
329329
330330 expect ( result1 . status ) . toEqual ( 'completed' ) ;
331331 expect ( result2 . status ) . toEqual ( 'completed' ) ;
@@ -335,8 +335,8 @@ describe('given a mock platform for a BrowserClient', () => {
335335 expect ( order ) . toEqual ( [ 'user-key-1' , 'user-key-2' , 'user-key-3' ] ) ;
336336 } ) ;
337337
338- it ( 'can shed intermediate identify calls' , async ( ) => {
339- const client = new BrowserClient (
338+ it ( 'can shed intermediate identify calls without waiting for results ' , async ( ) => {
339+ const client = makeClient (
340340 'client-side-id' ,
341341 AutoEnvAttributes . Disabled ,
342342 { streaming : false , logger, diagnosticOptOut : true , sendEvents : false , fetchGoals : false } ,
@@ -354,25 +354,16 @@ describe('given a mock platform for a BrowserClient', () => {
354354 } ) ;
355355
356356 it ( 'it does not shed non-shedable identify calls' , async ( ) => {
357- const client = new BrowserClient (
357+ const client = makeClient (
358358 'client-side-id' ,
359359 AutoEnvAttributes . Disabled ,
360360 { streaming : false , logger, diagnosticOptOut : true , sendEvents : false , fetchGoals : false } ,
361361 platform ,
362362 ) ;
363363
364- const promise1 = client . identifyResult (
365- { key : 'user-key-1' , kind : 'user' } ,
366- { sheddable : false } ,
367- ) ;
368- const promise2 = client . identifyResult (
369- { key : 'user-key-2' , kind : 'user' } ,
370- { sheddable : false } ,
371- ) ;
372- const promise3 = client . identifyResult (
373- { key : 'user-key-3' , kind : 'user' } ,
374- { sheddable : false } ,
375- ) ;
364+ const promise1 = client . identify ( { key : 'user-key-1' , kind : 'user' } , { sheddable : false } ) ;
365+ const promise2 = client . identify ( { key : 'user-key-2' , kind : 'user' } , { sheddable : false } ) ;
366+ const promise3 = client . identify ( { key : 'user-key-3' , kind : 'user' } , { sheddable : false } ) ;
376367
377368 const [ result1 , result2 , result3 ] = await Promise . all ( [ promise1 , promise2 , promise3 ] ) ;
378369
0 commit comments