-
Notifications
You must be signed in to change notification settings - Fork 1
[PB-6386] Fix display name #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5b21288
1a70b88
ef5cfaf
c6050e2
8581d10
1f40dae
e39cb32
2faf66d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend you to use When..., then... to describe the tests and avoiding using technical words so if a variable changes, you don't need to change the test description. It would be better if you describes the functionality rather than the expected behavior of a variable/function. You know what I mean?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xabg2 Fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use test instead of it. it is for should... and test to describe when..., then...
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xabg2 Done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { beforeEach, describe, expect, test, vi } from "vitest"; | ||
| import { LocalStorageManager } from "./LocalStorageManager"; | ||
|
|
||
| const MOCK_DISPlAY_NAME = "mock-display-name"; | ||
| const key = (LocalStorageManager as any)['KEYS']?.DISPLAY_NAME; | ||
|
|
||
| describe("LocalStorageManager tests", () => { | ||
| beforeEach(() => { | ||
| localStorage.clear(); | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| test("when local storage is called repeatedly, then the same instance is returned", () => { | ||
| const a = LocalStorageManager.instance; | ||
| const b = LocalStorageManager.instance; | ||
| expect(a).toBe(b); | ||
| }); | ||
|
|
||
| test("when no display name is stored, then returns underfined", () => { | ||
| expect(LocalStorageManager.instance.getDisplayName()).toBeUndefined(); | ||
| }); | ||
|
|
||
| test("when display name is stored, then returns it", () => { | ||
| LocalStorageManager.instance.setDisplayName(MOCK_DISPlAY_NAME); | ||
| expect(LocalStorageManager.instance.getDisplayName()).toBe(MOCK_DISPlAY_NAME); | ||
| }); | ||
|
|
||
| test("when the stored display name was modified, then returns the last modification", () => { | ||
| LocalStorageManager.instance.setDisplayName(MOCK_DISPlAY_NAME); | ||
| const modifiedName = 'new-display-name'; | ||
| localStorage.setItem(key, modifiedName); | ||
| expect(LocalStorageManager.instance.getDisplayName()).toBe(modifiedName); | ||
| }); | ||
|
|
||
| test("when display name is saved in the local storage, then it does not bleed into the session storage", () => { | ||
| LocalStorageManager.instance.setDisplayName(MOCK_DISPlAY_NAME); | ||
| expect(sessionStorage.getItem(key)).toBeNull(); | ||
| }); | ||
|
|
||
| test("when local storage is cleaned, then display name becomes underfined", () => { | ||
| LocalStorageManager.instance.setDisplayName(MOCK_DISPlAY_NAME); | ||
| LocalStorageManager.instance.clearCredentials(); | ||
| expect(LocalStorageManager.instance.getDisplayName()).toBeUndefined(); | ||
| }); | ||
|
|
||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in prod, we (Jitsi) build in chunks for performance. Now in prod, there are a bunch of errors because of chunks not being found (because the chunks folder is not copied). All works, because it falls back to serving the entier file I think, but still complains a lot:
