@@ -11,19 +11,24 @@ describe("All the styles should be applied", ()=>{
11
11
const title = document . querySelector ( 'title' )
12
12
const link = document . querySelector ( 'link' )
13
13
14
- test ( "The ul li color has to be red" , ( ) => {
14
+ test ( "The ul li color has to be red using !important " , ( ) => {
15
15
document . querySelector (
16
16
"head"
17
17
) . innerHTML = `<style>${ css . toString ( ) } </style>` ;
18
+
18
19
let cssArray = document . styleSheets [ 0 ] . cssRules ;
19
- let orangeHoverSelector = "" ;
20
+ let color = ""
21
+
20
22
for ( let i = 0 ; i < cssArray . length ; i ++ ) {
21
23
if ( cssArray [ i ] . selectorText === "ul li" || cssArray [ i ] . selectorText === "ul > li" ) {
22
- orangeHoverSelector = cssArray [ i ] . style [ "color" ] ;
24
+ color = cssArray [ i ] . cssText ;
23
25
}
24
26
}
25
- expect ( orangeHoverSelector ) . toBe ( "red" ) ;
27
+ let reg = new RegExp ( / \s * c o l o r : \s * r e d \s * ! i m p o r t a n t \s * ; \s * / gm)
28
+
29
+ expect ( reg . test ( color ) ) . toBeTruthy ( ) ;
26
30
} ) ;
31
+
27
32
test ( "The ul second element background should be green" , ( ) => {
28
33
document . querySelector (
29
34
"head"
@@ -39,6 +44,7 @@ describe("All the styles should be applied", ()=>{
39
44
40
45
} expect ( orangeHoverSelector ) . toBe ( "green" ) ;
41
46
} )
47
+
42
48
test ( "The odd rows of the table should have yellow background" , ( ) => {
43
49
document . querySelector (
44
50
"head"
@@ -63,8 +69,8 @@ describe("All the styles should be applied", ()=>{
63
69
let cssArray = document . styleSheets [ 0 ] . cssRules [ 4 ] . selectorText ;
64
70
expect ( cssArray ) . toBe ( "ul li,\nol li" ) ;
65
71
expect ( cssBody ) . toBe ( "body" ) ;
66
- }
67
- )
72
+ } )
73
+
68
74
test ( "You should not change the existing head tag elements" , ( ) => {
69
75
let head = document . querySelector ( 'head' )
70
76
expect ( head ) . toBeTruthy ( )
@@ -76,4 +82,5 @@ describe("All the styles should be applied", ()=>{
76
82
77
83
expect ( title ) . toBeTruthy ( )
78
84
} )
85
+
79
86
} ) ;
0 commit comments