This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #72 add unit tests fr connected header
- Loading branch information
Showing
4 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { expect } from "chai"; | ||
import sinon from "sinon"; | ||
|
||
import "test/unit/mocks/browser"; | ||
|
||
import { | ||
updateProfileInfo, | ||
initializeProfileInfo, | ||
getProfileInfo, | ||
} from "src/background/profile"; | ||
|
||
describe("background > profile", () => { | ||
const mockProfile = { | ||
id: "8675309", | ||
avatar: "https://example.com/avatar", | ||
displayName: "John Doe", | ||
email: "john.doe@example.com", | ||
}; | ||
|
||
it("manages a cached profile data object", () => { | ||
updateProfileInfo(mockProfile); | ||
expect(getProfileInfo()).to.deep.equal(mockProfile); | ||
}); | ||
|
||
it("listens for profile changes on initialization", async () => { | ||
sinon.stub(browser.experiments.sync, "getUserProfileInfo").resolves(mockProfile); | ||
await initializeProfileInfo(); | ||
expect(getProfileInfo()).to.deep.equal(mockProfile); | ||
const updatedProfile = { ...mockProfile, displayName: "Jane Doe" }; | ||
browser.experiments.sync.onUserProfileChanged.getListener()(updatedProfile); | ||
expect(getProfileInfo()).to.deep.equal(updatedProfile); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters