11import assert from 'assert' ;
2- import { before } from 'mocha' ;
3- import { v4 as uuidv4 } from 'uuid' ;
42
53import StorageController , {
64 StorageVariables ,
@@ -45,7 +43,7 @@ suite('Storage Controller Test Suite', () => {
4543 ) ;
4644 } ) ;
4745
48- suite ( 'for a new user that does not have anonymousId or userId ' , ( ) => {
46+ suite ( 'for a new user that does not have anonymousId' , ( ) => {
4947 const extensionContextStub = new ExtensionContextStub ( ) ;
5048 extensionContextStub . _globalState = { } ;
5149 const testStorageController = new StorageController ( extensionContextStub ) ;
@@ -55,34 +53,7 @@ suite('Storage Controller Test Suite', () => {
5553 const anonymousId = testStorageController . get (
5654 StorageVariables . GLOBAL_ANONYMOUS_ID
5755 ) ;
58- const userId = testStorageController . get ( StorageVariables . GLOBAL_USER_ID ) ;
5956 assert . deepStrictEqual ( userIdentity , { anonymousId } ) ;
60- assert ( ! userId ) ;
61- } ) ;
62- } ) ;
63-
64- suite ( 'for an old user that does not have anonymousId but has userId' , ( ) => {
65- const extensionContextStub = new ExtensionContextStub ( ) ;
66- extensionContextStub . _globalState = { } ;
67- const testStorageController = new StorageController ( extensionContextStub ) ;
68- const id = uuidv4 ( ) ;
69-
70- before ( async ( ) => {
71- await testStorageController . update (
72- StorageVariables . GLOBAL_USER_ID ,
73- id ,
74- StorageLocation . GLOBAL
75- ) ;
76- } ) ;
77-
78- test ( 'getUserIdentity returns userId from the global storage and returns it to telemetry' , ( ) => {
79- const userIdentity = testStorageController . getUserIdentity ( ) ;
80- const anonymousId = testStorageController . get (
81- StorageVariables . GLOBAL_ANONYMOUS_ID
82- ) ;
83- const userId = testStorageController . get ( StorageVariables . GLOBAL_USER_ID ) ;
84- assert ( userId === id ) ;
85- assert . deepStrictEqual ( userIdentity , { userId, anonymousId } ) ;
8657 } ) ;
8758 } ) ;
8859} ) ;
0 commit comments