1
- const fs = require ( "fs" ) ;
2
- const path = require ( "path" ) ;
3
- const html = fs . readFileSync ( path . resolve ( __dirname , "./index.html" ) , "utf8" ) ;
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" ) ;
5
+ document . documentElement . innerHTML = html . toString ( ) ;
4
6
5
7
jest . dontMock ( "fs" ) ;
6
8
7
- describe ( "The lists should be modified accordingly" , function ( ) {
8
- beforeEach ( ( ) => {
9
- //here I import the HTML into the document
10
- document . documentElement . innerHTML = html . toString ( ) ;
9
+ describe ( "All the styles should be applied" , ( ) => {
10
+ const ols = document . querySelectorAll ( "ol" ) ;
11
+ const uls = document . querySelectorAll ( "ul" ) ;
12
+
13
+ test ( "There should be two <ol> tags" , ( ) => {
14
+ expect ( ols . length ) . toBe ( 2 )
11
15
} ) ;
12
- afterEach ( ( ) => {
13
- jest . resetModules ( ) ;
16
+ test ( "There should be two <ul> tags" , ( ) => {
17
+ expect ( uls . length ) . toBe ( 2 )
14
18
} ) ;
15
-
16
- it ( "You should not change the existing head tag elements" , function ( ) {
17
- let head = document . querySelector ( 'head' ) ;
18
- let title = head . querySelector ( 'title' ) . innerHTML ;
19
-
20
- expect ( title ) . toBe ( '03 List styling' )
21
- } )
22
-
23
- // Test in progress:
24
- // it("The lists should be correctly styled", function() {
25
- // const uls = document.querySelectorAll("ul");
26
- // const ols = document.querySelectorAll("ol");
27
- // console.log(uls);
28
- // console.log(ols);
29
-
30
- // var style1 = window.getComputedStyle(ols[0]);
31
- // var style2 = window.getComputedStyle(uls[0]);
32
- // var style3 = window.getComputedStyle(ols[1]);
33
- // var style4 = window.getComputedStyle(uls[1]);
34
-
35
-
36
- // expect(style1["listStyleType"]).toBe("lower-alpha");
37
- // expect(style2["listStyleType"]).toBe("square");
38
- // expect(style3["listStyleType"]).toBe("armenian");
39
- // expect(style4["listStyleType"]).toBe("none");
40
-
41
- // });
42
- } ) ;
19
+ test ( "The first Ol must have a list-style-type = lower-alpha " , ( ) => {
20
+ document . querySelector (
21
+ "head"
22
+ ) . innerHTML = `<style>${ css . toString ( ) } </style>` ;
23
+ let firstOl = window . getComputedStyle ( ols [ 0 ] ) ;
24
+ expect ( firstOl [ "list-style-type" ] ) . toBe ( "lower-alpha" ) ;
25
+ } ) ;
26
+ test ( "The second Ol must have a list-style-type = square " , ( ) => {
27
+ document . querySelector (
28
+ "head"
29
+ ) . innerHTML = `<style>${ css . toString ( ) } </style>` ;
30
+ let secondOl = window . getComputedStyle ( ols [ 1 ] ) ;
31
+ expect ( secondOl [ "list-style-type" ] ) . toBe ( "square" ) ;
32
+ } ) ;
33
+ test ( "The first Ul must have a list-style-type = armenian " , ( ) => {
34
+ document . querySelector (
35
+ "head"
36
+ ) . innerHTML = `<style>${ css . toString ( ) } </style>` ;
37
+ let firstUl = window . getComputedStyle ( uls [ 0 ] ) ;
38
+ expect ( firstUl [ "list-style-type" ] ) . toBe ( "armenian" ) ;
39
+ } ) ;
40
+ test ( "The second Ul must have a list-style-type = none " , ( ) => {
41
+ document . querySelector (
42
+ "head"
43
+ ) . innerHTML = `<style>${ css . toString ( ) } </style>` ;
44
+ let secondUl = window . getComputedStyle ( uls [ 1 ] ) ;
45
+ expect ( secondUl [ "list-style-type" ] ) . toBe ( "none" ) ;
46
+ expect ( secondUl [ "margin" ] ) . toBe ( "0px" ) ;
47
+ expect ( secondUl [ "padding" ] ) . toBe ( "0px" ) ;
48
+ } ) ;
49
+ } )
0 commit comments