Skip to content

Commit

Permalink
✅ [RUMF-911] test to clear a previously set user
Browse files Browse the repository at this point in the history
  • Loading branch information
amortemousque committed May 11, 2021
1 parent 7a3c802 commit 18a6922
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/rum-core/src/boot/rumPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ describe('rum public api', () => {
})
})

describe('setUser', () => {
fdescribe('setUser', () => {
let addActionSpy: jasmine.Spy<ReturnType<StartRum>['addAction']>
let errorSpy: jasmine.Spy<() => void>
let rumPublicApi: RumPublicApi
Expand Down Expand Up @@ -381,11 +381,18 @@ describe('rum public api', () => {
expect(errorSpy).not.toHaveBeenCalled()
})

it('should clear a previously set user', () => {
const user = { id: 'foo', name: 'bar', email: 'qux', foo: { bar: 'qux' } }
rumPublicApi.setUser(user)
rumPublicApi.setUser(undefined)
rumPublicApi.addAction('message')
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(addActionSpy.calls.argsFor(0)[1]!.user).toEqual({})
})

it('should reject non object input', () => {
rumPublicApi.setUser(2 as any)
rumPublicApi.setUser(null as any)
rumPublicApi.setUser(undefined as any)
expect(errorSpy).toHaveBeenCalledTimes(3)
expect(errorSpy).toHaveBeenCalled()
})
})

Expand Down

0 comments on commit 18a6922

Please sign in to comment.