Skip to content

Commit ca17a50

Browse files
committed
Updated 4GeeksAcademy#2 and fixed issues
1 parent d904f9b commit ca17a50

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

exercises/02-Background/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# `02` Background
22

3-
The `background` CSS rule allows us to assign and work with the background of any container. The background values can be a `color` or an `image`.
3+
The `background` CSS rule allows us to assign and work with the background of any container. The background values can be a `color` or an `image`.
44

55
If it is an image you can specify if you want the image to repeat horizontally, vertically, both, or not at all, and you can also specify if you want it to resize and fit the whole container where its being applied, among other properties that can be modified.
66

77
## 📝 Instructions:
88

9-
```plain/text
9+
1010
1. Build the exercise.
1111
2. Check the Preview.
1212
3. On the styles.css file the background-size to 'contain' (check the styles.css tab).
1313
4. Build and Preview the exercise again.
1414
5. Change the background-repeat to 'inherit' to make it repeat over the x axis and y axis.
1515
6. Build and Preview the exercise again.
16-
```
16+
1717

1818
## 💡Hint:
1919

exercises/02-Background/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width" />
6-
<link rel="stylesheet" type="text/css" href="./styles.css" />
7-
<title>02 Background</title>
8-
</head>
9-
<body></body>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<link rel="stylesheet" type="text/css" href="./styles.css" />
7+
<title>02 Background</title>
8+
</head>
9+
<body></body>
1010
</html>

exercises/02-Background/tests.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ describe("All the styles should be applied", function () {
1111
document.documentElement.innerHTML=html.toString();
1212

1313
//apply the styles from the stylesheet if needed
14-
document.querySelector(
15-
"head"
16-
).innerHTML=`<style>${css.toString()}</style>`;
14+
1715

1816

1917
});
2018
afterEach(() => {
2119
jest.resetModules();
2220
});
2321
it("The body tag should not contains any inline style", function () {
22+
document.querySelector(
23+
"head"
24+
).innerHTML=`<style>${css.toString()}</style>`;
2425
let bodyInlineStyle=document.getElementsByTagName("body");
2526
let emptyBodyInlineStyle={};
2627
expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle);
@@ -30,20 +31,36 @@ describe("All the styles should be applied", function () {
3031

3132
console.log(bodyInlineStyle[0].style._values);
3233
});
33-
it("The Head tag should not includes a Style tag", function () {
34-
expect(html.toString().indexOf(`<style`)>-1).toBeFalsy();
35-
});
34+
3635
it("the background-size should be 'contain' without quotes", function () {
36+
document.querySelector(
37+
"head"
38+
).innerHTML=`<style>${css.toString()}</style>`;
3739
// get computed styles of any element you like
3840
const body=document.querySelector("body");
3941
let styles=window.getComputedStyle(body);
4042
expect(styles["background-size"]).toBe("contain");
4143
});
4244

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

4550
const body=document.querySelector("body");
4651
let styles=window.getComputedStyle(body);
4752
expect(styles["background-repeat"]).toBe("inherit");
4853
});
54+
it("You should not change the head tag", function () {
55+
56+
let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<meta c")
57+
let meta2 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<meta n")
58+
let link = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<link")
59+
let title = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<title")
60+
expect(meta1).not.toBe(-1)
61+
expect(meta2).not.toBe(-1)
62+
expect(link).not.toBe(-1)
63+
expect(title).not.toBe(-1)
64+
expect(html.toString().indexOf(`<style`)>-1).toBeFalsy();
65+
})
4966
});

0 commit comments

Comments
 (0)