|
1 | | -const fs = require("fs"); |
2 | | -const path = require("path"); |
3 | | -const html = fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8"); |
4 | | -// const css = fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8"); |
| 1 | +const fs = require('fs'); |
| 2 | +const path = require('path'); |
| 3 | +const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8'); |
| 4 | +document.documentElement.innerHTML = html.toString(); |
5 | 5 |
|
6 | | -jest.dontMock("fs"); |
| 6 | +jest.dontMock('fs'); |
7 | 7 |
|
8 | | -describe("All the styles should be applied", function() { |
9 | | - beforeEach(() => { |
10 | | - //here I import the HTML into the document |
11 | | - document.documentElement.innerHTML = html.toString(); |
12 | | - }); |
13 | | - afterEach(() => { |
14 | | - jest.resetModules(); |
15 | | - }); |
| 8 | +describe("All the styles should be applied", ()=>{ |
| 9 | + const a = document.querySelector("a"); |
16 | 10 |
|
17 | | - it("The background should be blue", function() { |
18 | | - const body = document.querySelector("body"); |
19 | | - var styles = window.getComputedStyle(body); |
20 | | - expect(styles["background"]).toBe("blue"); |
| 11 | + test("The anchor tag should be yellow", ()=>{ |
| 12 | + let styles = window.getComputedStyle(a); |
| 13 | + expect(styles["color"]).toBe("yellow"); |
21 | 14 | }); |
22 | | - it("The body tag should not contains any inline style", function() { |
| 15 | + |
| 16 | + test("The body tag should not contain any inline style", ()=>{ |
23 | 17 | let bodyInlineStyle = document.getElementsByTagName("body"); |
24 | 18 | let emptyBodyInlineStyle = {}; |
25 | 19 | expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); |
26 | | - // console.log(bodyInlineStyle[0].style._values.background); |
27 | 20 | }); |
28 | | - it("You should not change the existing head tag elements", function () { |
| 21 | + |
| 22 | + test("The anchor tag should not contain any inline style", ()=>{ |
| 23 | + let emptyBodyInlineStyle = {}; |
| 24 | + expect(a.style._values).toEqual(emptyBodyInlineStyle); |
| 25 | + }); |
| 26 | + |
| 27 | + test("You should not change the existing head tag elements", ()=>{ |
29 | 28 | let head = document.querySelector('head') |
30 | 29 | expect(head).toBeTruthy() |
31 | 30 |
|
|
0 commit comments