From 5bc02eeca4bedace0f6a8285e7d040ecef1b2b3f Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 3 May 2019 19:38:13 -0700 Subject: [PATCH] Add LayoutApplier tests Signed-off-by: Mcat12 --- .../common/__tests__/LayoutApplier.test.tsx | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/components/common/__tests__/LayoutApplier.test.tsx diff --git a/src/components/common/__tests__/LayoutApplier.test.tsx b/src/components/common/__tests__/LayoutApplier.test.tsx new file mode 100644 index 0000000..61e906d --- /dev/null +++ b/src/components/common/__tests__/LayoutApplier.test.tsx @@ -0,0 +1,63 @@ +/* Pi-hole: A black hole for Internet advertisements + * (c) 2019 Pi-hole, LLC (https://pi-hole.net) + * Network-wide ad blocking via your own hardware. + * + * Web Interface + * LayoutApplier component test + * + * This file is copyright under the latest version of the EUPL. + * Please see LICENSE file for your rights under this license. */ + +import React from "react"; +import { mount } from "enzyme"; +import LayoutApplier from "../LayoutApplier"; +import { + PreferencesContext, + PreferencesContextType +} from "../context/PreferencesContext"; + +it("adds box layout CSS when the layout is box", () => { + const settings: PreferencesContextType = { + settings: { + language: "en", + layout: "boxed" + }, + refresh: () => {} + }; + + expect(document.body.classList).not.toContain("boxcontainer"); + expect(document.body.classList).not.toContain("background-image"); + + mount( + + + + ); + + expect(document.body.classList).toContain("boxcontainer"); + expect(document.body.classList).toContain("background-image"); +}); + +it("removes box layout CSS when the layout is traditional", () => { + const settings: PreferencesContextType = { + settings: { + language: "en", + layout: "traditional" + }, + refresh: () => {} + }; + + document.body.classList.add("boxcontainer", "background-image"); + + expect(document.body.classList).toContain("boxcontainer"); + expect(document.body.classList).toContain("background-image"); + + mount( + + + + ); + + expect(document.body.classList).not.toContain("boxcontainer"); + expect(document.body.classList).not.toContain("background-image"); +});