-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to sign up through UI (#30)
closes #28
- Loading branch information
Showing
8 changed files
with
453 additions
and
15 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
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 |
---|---|---|
@@ -1,27 +1,56 @@ | ||
import { spy, stub } from "sinon"; | ||
import { spy, stub, mock, restore } from "sinon"; | ||
import { fixture, expect } from "@open-wc/testing"; | ||
// import { expect } from "@esm-bundle/chai"; | ||
|
||
import { App } from "./index"; | ||
|
||
describe("browsertrix-app", () => { | ||
beforeEach(() => { | ||
stub(App.prototype, "getUserInfo").callsFake(() => | ||
Promise.resolve({ | ||
email: "test-user@example.com", | ||
is_verified: false, | ||
}) | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
restore(); | ||
}); | ||
|
||
it("is defined", async () => { | ||
const el = await fixture("<browsertrix-app></browsertrix-app>"); | ||
expect(el).instanceOf(App); | ||
}); | ||
|
||
it("gets auth state from local storage", async () => { | ||
it("sets auth state from local storage", async () => { | ||
stub(window.localStorage, "getItem").callsFake((key) => { | ||
if (key === "authState") | ||
return JSON.stringify({ | ||
username: "test@example.com", | ||
username: "test-auth@example.com", | ||
}); | ||
return null; | ||
}); | ||
const el = (await fixture("<browsertrix-app></browsertrix-app>")) as App; | ||
|
||
expect(el.authState).to.eql({ | ||
username: "test@example.com", | ||
username: "test-auth@example.com", | ||
}); | ||
}); | ||
|
||
it("sets user info", async () => { | ||
stub(window.localStorage, "getItem").callsFake((key) => { | ||
if (key === "authState") | ||
return JSON.stringify({ | ||
username: "test-auth@example.com", | ||
}); | ||
return null; | ||
}); | ||
const el = (await fixture("<browsertrix-app></browsertrix-app>")) as App; | ||
|
||
expect(el.userInfo).to.eql({ | ||
email: "test-user@example.com", | ||
isVerified: false, | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.