Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Completed 03
  • Loading branch information
plucodev committed Aug 4, 2019
commit 23e91a362cde212049fb69bc464e217e43b49e53
1 change: 1 addition & 0 deletions exercises/02-Background/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe("All the styles should be applied", function() {
it("the background-size should be 'contain'", function() {
// get computed styles of any element you like
const body = document.querySelector("table");
console.log("Body: " + body);
var styles = window.getComputedStyle(body);
expect(styles["background-size"]).toBe("contain");
});
Expand Down
2 changes: 1 addition & 1 deletion exercises/03-Inline-Styles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>03 Inline Styles</title>
</head>
<body>
<table style="background: green">
<table>
<tr>
<td>Hello</td>
</tr>
Expand Down
61 changes: 45 additions & 16 deletions exercises/03-Inline-Styles/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const fs = require("fs");
const path = require("path");
const html = fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8");
const css = fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8");
console.log(css);

jest.dontMock("fs");

describe("All the html should match", function() {
describe("The Table tag should contain inline style background: green", function() {
beforeEach(() => {
//here I import the HTML into the document
document.documentElement.innerHTML = html.toString();
Expand All @@ -16,20 +16,49 @@ describe("All the html should match", function() {
afterEach(() => {
jest.resetModules();
});

it("the html code should contain a table tag", function() {
// we can read from the source code
console.log(html.toString());
expect(html.toString().indexOf(`table`)).toBeTruthy();

//or use query selector to compare hoy mane scriptags do we have
// const pTags = document.querySelectorAll("p");
// expect(pTags.length).toBe(1);
it("The styles.css file should be empty", function() {
console.log(css);
expect(css.toString() === "").toBeTruthy();
});
it("the background should be green", function() {
// get computed styles of any element you like
const body = document.querySelector("body");
var styles = window.getComputedStyle(body);
expect(styles["background"]).toBe("green");

it("The background should be green", function() {
const table = document.querySelector("table");
expect(table.style.background === "green").toBeTruthy();
});
});

// describe("The Table tag should contain inline style background:green", function() {
// beforeEach(() => {
// //here I import the HTML into the document
// document.documentElement.innerHTML = html.toString();
// document.querySelector(
// "head"
// ).innerHTML = `<style>${css.toString()}</style>`;
// });
// afterEach(() => {
// jest.resetModules();
// });

// // it("the html code should contain a table tag", function() {
// // we can read from the source code
// // console.log("HTML: " + html.toString());
// // console.log("CSS " + css.toString());
// // expect(css.toString().toBeFalsy());
// // expect(html.toString().indexOf(`table`)).toBeTruthy();

// //or use query selector to compare hoy mane scriptags do we have
// // const pTags = document.querySelectorAll("p");
// // expect(pTags.length).toBe(1);
// // });
// it("the background should be green", function() {

// const table = document.querySelector("table");
// expect(css.toString().toBeFalsy());
// expect(table.style.background === "green").toBeTruthy();
// // expect(table.contains("styles"));
// // var styles = window.getComputedStyle("table");
// // console.log("Styles: " + styles);
// // expect(styles["background"]).toBe("green");
// // console.log("Styles: " + table);
// });
// });