1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Use browser default time and number formatting with polyfills if needed (#9481)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Bram Kragten
2021-09-30 01:34:52 +02:00
committed by GitHub
parent d7f00df391
commit 1bccbd4173
91 changed files with 952 additions and 974 deletions

View File

@@ -0,0 +1,56 @@
import { assert } from "chai";
import { createHassioSession } from "../../src/data/hassio/ingress";
describe("Create hassio session", function () {
const hass = {
config: { version: "1.0.0" },
callApi: async function () {
return { data: { session: "fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh" } };
},
};
it("Test create session without HTTPS", async function () {
// @ts-ignore
global.document = {};
// @ts-ignore
global.location = {};
// @ts-ignore
await createHassioSession(hass);
assert.strictEqual(
// @ts-ignore
global.document.cookie,
"ingress_session=fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh;path=/api/hassio_ingress/;SameSite=Strict"
);
});
it("Test create session with HTTPS", async function () {
// @ts-ignore
global.document = {};
// @ts-ignore
global.location = { protocol: "https:" };
// @ts-ignore
await createHassioSession(hass);
assert.strictEqual(
// @ts-ignore
global.document.cookie,
"ingress_session=fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh;path=/api/hassio_ingress/;SameSite=Strict;Secure"
);
// Clean up in case they will be used in other tests
// @ts-ignore
global.document = {};
// @ts-ignore
global.location = {};
});
it("Test fail to create", async function () {
const createSessionPromise = createHassioSession({
// @ts-ignore
callApi: async function () {
// noop
},
}).then(
() => true,
() => false
);
assert.strictEqual(await createSessionPromise, false);
});
});