+ *
+ * Project: Nord Docs
+ * Repository: https://github.com/arcticicestudio/nord-docs
+ * License: MIT
+ */
+
+import React, { Fragment } from "react";
+import { stripUnit } from "polished";
+
+import { renderWithTheme } from "nord-docs-test-utils";
+import { H1, H2, H3, H4, H5, H6 } from "atoms/core/HTMLElements";
+
+describe("theme styles", () => {
+ test("matches the snapshot", () => {
+ const { container } = renderWithTheme(
+
+ Heading Level 1
+ Heading Level 2
+ Heading Level 3
+ Heading Level 4
+ Heading Level 5
+ Heading Level 6
+
+ );
+ expect(container).toMatchSnapshot();
+ });
+
+ test("matches the snapshot with adjusted margin", () => {
+ const { container } = renderWithTheme(
+
+ Heading Level 1
+ Heading Level 2
+ Heading Level 3
+ Heading Level 4
+ Heading Level 5
+ Heading Level 6
+
+ );
+ expect(container).toMatchSnapshot();
+ });
+
+ test("has explicit font size definitions", () => {
+ const { container } = renderWithTheme(
+
+ Heading Level 1
+ Heading Level 2
+ Heading Level 3
+ Heading Level 4
+ Heading Level 5
+ Heading Level 6
+
+ );
+ expect(
+ Object.values(container.children)
+ .map(headingElement => getComputedStyle(headingElement).fontSize)
+ .filter(Boolean).length
+ ).toEqual(container.children.length);
+ });
+
+ test("has no top margin", () => {
+ const { container } = renderWithTheme(Nord
);
+ expect(container.firstChild).toHaveStyleRule("margin-top", "0");
+ });
+
+ test("adjusts bottom margin based on passed props", () => {
+ const { container } = renderWithTheme(Nord
);
+ expect(container.firstChild).toHaveStyleRule("margin-bottom", "0");
+ });
+
+ test("Ensure descending font sizes between all heading levels", () => {
+ const { container } = renderWithTheme(
+
+ Heading Level 1
+ Heading Level 2
+ Heading Level 3
+ Heading Level 4
+ Heading Level 5
+ Heading Level 6
+
+ );
+
+ expect(
+ /* Get the font sizes as numbers of all heading components in rendered order. */
+ Object.values(container.children)
+ .map(headingElement => stripUnit(getComputedStyle(headingElement).fontSize))
+ /* Ensure descending font sizes by comparing a higher level heading with the next lower one. */
+ .reduce((acc, cur) => (acc > cur ? cur : 0))
+ ).toBeGreaterThan(0);
+ });
+});
diff --git a/test/components/atoms/core/HTMLElements/sectioning/__snapshots__/Heading.test.jsx.snap b/test/components/atoms/core/HTMLElements/sectioning/__snapshots__/Heading.test.jsx.snap
new file mode 100644
index 00000000..d7582830
--- /dev/null
+++ b/test/components/atoms/core/HTMLElements/sectioning/__snapshots__/Heading.test.jsx.snap
@@ -0,0 +1,155 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`theme styles matches the snapshot 1`] = `
+.c0 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 2.0272865295410156em;
+}
+
+.c1 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 1.802032470703125em;
+}
+
+.c2 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 1.601806640625em;
+}
+
+.c3 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 1.423828125em;
+}
+
+.c4 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 1.265625em;
+}
+
+.c5 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ font-size: 1.125em;
+}
+
+
+
+ Heading Level 1
+
+
+ Heading Level 2
+
+
+ Heading Level 3
+
+
+ Heading Level 4
+
+
+ Heading Level 5
+
+
+ Heading Level 6
+
+
+`;
+
+exports[`theme styles matches the snapshot with adjusted margin 1`] = `
+.c0 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 2.0272865295410156em;
+}
+
+.c1 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 1.802032470703125em;
+}
+
+.c2 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 1.601806640625em;
+}
+
+.c3 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 1.423828125em;
+}
+
+.c4 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 1.265625em;
+}
+
+.c5 {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-weight: 500;
+ font-size: 1.125em;
+}
+
+
+
+ Heading Level 1
+
+
+ Heading Level 2
+
+
+ Heading Level 3
+
+
+ Heading Level 4
+
+
+ Heading Level 5
+
+
+ Heading Level 6
+
+
+`;
diff --git a/test/components/atoms/core/HTMLElements/text-content/P.test.jsx b/test/components/atoms/core/HTMLElements/text/P.test.jsx
similarity index 100%
rename from test/components/atoms/core/HTMLElements/text-content/P.test.jsx
rename to test/components/atoms/core/HTMLElements/text/P.test.jsx
diff --git a/test/components/atoms/core/HTMLElements/text-content/__snapshots__/P.test.jsx.snap b/test/components/atoms/core/HTMLElements/text/__snapshots__/P.test.jsx.snap
similarity index 100%
rename from test/components/atoms/core/HTMLElements/text-content/__snapshots__/P.test.jsx.snap
rename to test/components/atoms/core/HTMLElements/text/__snapshots__/P.test.jsx.snap