Skip to content

01 hello world 04.2 apply several classes #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc3c77b
test is now checking for color yellow on anchor
UmiKami Aug 3, 2022
8249493
added tests to check if p tag exists and it has proper styles
UmiKami Aug 3, 2022
425e2f3
added and further improved tests
UmiKami Aug 3, 2022
b91745d
improved tests using ES6, test keyword, and checking inline style of …
UmiKami Aug 3, 2022
e450b3f
upgraded tests to ES6 and changed it function foor test function
UmiKami Aug 3, 2022
0f7f2a4
removed unncessary comment in example
UmiKami Aug 3, 2022
9472335
added solution file
UmiKami Aug 3, 2022
fbc9af2
added solution file
UmiKami Aug 3, 2022
5289196
added solution file
UmiKami Aug 3, 2022
2576920
added solution file
UmiKami Aug 3, 2022
b6f1b26
added solution file
UmiKami Aug 3, 2022
12c623f
improved tests and cghecks for background color blue
UmiKami Aug 3, 2022
9710f49
added solution file
UmiKami Aug 3, 2022
708ce0d
Upgraded test to modern stanndards and made it less repetitive
UmiKami Aug 3, 2022
f6cd29a
added solution file
UmiKami Aug 3, 2022
c6107db
upgraded tests to mre modern standard
UmiKami Aug 3, 2022
2c3450b
exchanged var for let
UmiKami Aug 3, 2022
a6039f4
Added test
UmiKami Aug 3, 2022
bd04bce
added solution file
UmiKami Aug 3, 2022
a55c1f8
added solution file
UmiKami Aug 3, 2022
dcbb836
improved format and minar issue with header
UmiKami Aug 3, 2022
ada8f10
fixed titles
UmiKami Aug 3, 2022
e88ac6c
added test to check if the div exists and if it contains the proper c…
UmiKami Aug 3, 2022
201f863
added solution file
UmiKami Aug 3, 2022
91383e5
Some improvements added to the tests
tommygonzaleza Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion exercises/01-Hello-World/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Mira este ejemplo:
```HTML
<style>
a {
/* cambia este estilo a yellow */
color: pink;
}
</style>
Expand Down
1 change: 0 additions & 1 deletion exercises/01-Hello-World/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Look at this example:
```HTML
<style>
a {
/* change this style to yellow */
color: pink;
}
</style>
Expand Down
2 changes: 1 addition & 1 deletion exercises/01-Hello-World/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- your code here -->
<!-- your code here -->
7 changes: 7 additions & 0 deletions exercises/01-Hello-World/solution.hide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- your code here -->
<style>
a {
color: pink;
}
</style>
<a href="https://google.com" target="_blank">Click me to open google.com</a>
34 changes: 34 additions & 0 deletions exercises/01-Hello-World/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();

jest.dontMock('fs');

const a = document.querySelector("a");

test("There should be an anchor tag", ()=>{
expect(a).toBeTruthy()
})

test("The anchor tag should be pink", ()=>{
let styles = window.getComputedStyle(a);
expect(styles["color"]).toBe("pink");
});

test("There should be a href attribute pointing to 'https://google.com'", ()=>{
let href = a.getAttribute('href');
expect(href).toBeTruthy();
expect(href).toBe("https://google.com");
})

test("There should be a target attribute pointing to '_blank'", ()=>{
let target = a.getAttribute('target');
expect(target).toBeTruthy();
expect(target).toBe("_blank");
})

test("The anchor tag should not contains any inline style", ()=>{
let emptyBodyInlineStyle = {};
expect(a.style._values).toEqual(emptyBodyInlineStyle);
});
12 changes: 12 additions & 0 deletions exercises/01.1-The-Style-Tag/solution.hide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- add a style tag and select the p tag and make it color blue -->
<style>
/* the website CSS Styles go here */
p {
color: blue;
}
</style>
<p>
Coding is a basic literacy in the digital age, and it is important for kids to understand and be able to work with and understand the technology
around them. Having children learn coding at a young age prepares them for the future. Coding helps children with communication, creativity,
math,writing, and confidence.
</p>
22 changes: 22 additions & 0 deletions exercises/01.1-The-Style-Tag/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();

jest.dontMock('fs');

const p = document.querySelector("p");

test("There should be a p tag", ()=>{
expect(p).toBeTruthy();
})

test("The p tag color should be blue", ()=>{
let styles = window.getComputedStyle(p);
expect(styles["color"]).toBe("blue");
});

test("The p tag should not contain any inline style", ()=>{
let emptyBodyInlineStyle = {};
expect(p.style._values).toEqual(emptyBodyInlineStyle);
});
14 changes: 14 additions & 0 deletions exercises/01.2-Your-First-Style/solution.hide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<style>
a {
/* change this style to blue */
color: yellow;
}
</style>
</head>
<body>
Hello! <a href="#">I am an anchor in red, change my color to yellow</a>
</body>
</html>
39 changes: 19 additions & 20 deletions exercises/01.2-Your-First-Style/tests.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
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");
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();

jest.dontMock("fs");
jest.dontMock('fs');

describe("All the styles should be applied", function() {
beforeEach(() => {
//here I import the HTML into the document
document.documentElement.innerHTML = html.toString();
});
afterEach(() => {
jest.resetModules();
});
describe("All the styles should be applied", ()=>{
const a = document.querySelector("a");

it("The background should be blue", function() {
const body = document.querySelector("body");
var styles = window.getComputedStyle(body);
expect(styles["background"]).toBe("blue");
test("The anchor tag should be yellow", ()=>{
let styles = window.getComputedStyle(a);
expect(styles["color"]).toBe("yellow");
});
it("The body tag should not contains any inline style", function() {

test("The body tag should not contain any inline style", ()=>{
let bodyInlineStyle = document.getElementsByTagName("body");
let emptyBodyInlineStyle = {};
expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle);
// console.log(bodyInlineStyle[0].style._values.background);
});
it("You should not change the existing head tag elements", function () {

test("The anchor tag should not contain any inline style", ()=>{
let emptyBodyInlineStyle = {};
expect(a.style._values).toEqual(emptyBodyInlineStyle);
});

test("You should not change the existing head tag elements", ()=>{
let head = document.querySelector('head')
expect(head).toBeTruthy()

Expand Down
3 changes: 3 additions & 0 deletions exercises/01.3-Your-Second-Style/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<head>
<style>
/* Your code here */
body {
background-color: blue;
}
</style>
</head>
<body>
Expand Down
14 changes: 14 additions & 0 deletions exercises/01.3-Your-Second-Style/solution.hide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<style>
/* Your code here */
body {
background: blue;
}
</style>
</head>
<body>
Hello! My background should be blue!
</body>
</html>
36 changes: 15 additions & 21 deletions exercises/01.3-Your-Second-Style/tests.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
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");
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();

jest.dontMock("fs");
jest.dontMock('fs');

describe("All the styles should be applied", function() {
beforeEach(() => {
//here I import the HTML into the document
document.documentElement.innerHTML = html.toString();
});
afterEach(() => {
jest.resetModules();
});
describe("All the styles should be applied", ()=>{
const body = document.querySelector("body");

it("The background should be blue", function() {
const body = document.querySelector("body");
var styles = window.getComputedStyle(body);
test("The background should be blue", ()=>{
let styles = window.getComputedStyle(body);
expect(styles["background"]).toBe("blue");
});
it("The body tag should not contains any inline style", function() {
let bodyInlineStyle = document.getElementsByTagName("body");

test("The body tag should not contains any inline style", ()=>{
let emptyBodyInlineStyle = {};
expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle);
// console.log(bodyInlineStyle[0].style._values.background);
expect(body.style._values).toEqual(emptyBodyInlineStyle);
});
it("You should not change the existing head tag elements", function () {

test("You should not change the existing head tag elements", ()=>{
let head = document.querySelector('head')
expect(head).toBeTruthy()

let meta = head.querySelector("meta")
expect(meta).toBe(null)
})
Expand Down
7 changes: 7 additions & 0 deletions exercises/02-Separate-Stylesheet/solution.hide.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* your styles here:
1. Select the body tag.
2. Add the background rule equal to blue.
*/
body {
background: blue;
}
62 changes: 16 additions & 46 deletions exercises/02-Separate-Stylesheet/tests.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,34 @@
const fs=require("fs");
const path=require("path");
const html=fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8");
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
const css=fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8");
document.documentElement.innerHTML = html.toString();

jest.dontMock("fs");

describe("All the styles should be applied", function () {
beforeEach(() => {
//here I import the HTML into the document
document.documentElement.innerHTML=html.toString();
describe("All the styles should be applied", ()=>{
const link = document.querySelector("link");
const body = document.querySelector("body");

//apply the styles from the stylesheet if needed



});
afterEach(() => {
jest.resetModules();
});
it("The body tag should not contains any inline style", function () {
document.querySelector(
"head"
).innerHTML=`<style>${css.toString()}</style>`;
let bodyInlineStyle=document.getElementsByTagName("body");
test("The body tag should not contains any inline style", ()=>{
document.querySelector("head").innerHTML = `<style>${css.toString()}</style>`;
let emptyBodyInlineStyle={};
expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle);
// expect(bodyInlineStyle[0].style._values.background - repeat).toBe(
// undefined
// );

console.log(bodyInlineStyle[0].style._values);
expect(body.style._values).toEqual(emptyBodyInlineStyle)
});

it("the background-size should be 'contain' without quotes", function () {
document.querySelector(
"head"
).innerHTML=`<style>${css.toString()}</style>`;
// get computed styles of any element you like
const body=document.querySelector("body");
let styles=window.getComputedStyle(body);
expect(styles["background-size"]).toBe("contain");
});

it("the background-repeat should be 'inherit' without quotes", function () {
document.querySelector(
"head"
).innerHTML=`<style>${css.toString()}</style>`;

const body=document.querySelector("body");
let styles=window.getComputedStyle(body);
expect(styles["background-repeat"]).toBe("inherit");
});
it("You should not change the existing head tag elements", function () {
test("You should not change the existing head tag elements", ()=>{
let head = document.querySelector('head')
expect(head).toBeTruthy()

let meta = head.querySelector("meta")
expect(meta).toBe(null)

const pathname = new URL(document.querySelector('link').href).pathname
expect(pathname).toBe('/styles.css')
let href = link.getAttribute("href")
expect(href).toEqual('./styles.css')
});

test("Your body tag background color should be blue", ()=>{
let styles = window.getComputedStyle(body)
expect(styles["background-color"]).toBe("blue")
})
});
5 changes: 5 additions & 0 deletions exercises/02.1-Background/solution.hide.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
background-image: url(https://4geeksacademy.github.io/exercise-assets/img/bg/small-mosaic.jpg);
background-size: contain;
background-repeat: inherit;
}
Loading