44import { cssString } from "../__fixtures__/curriculum-helper-css" ;
55import { CSSHelp } from "../index" ;
66
7- describe ( ' css-help' , ( ) => {
7+ describe ( " css-help" , ( ) => {
88 const doc = document ;
99 let t : CSSHelp ;
1010 beforeEach ( ( ) => {
11- const style = doc . createElement ( ' style' ) ;
11+ const style = doc . createElement ( " style" ) ;
1212 style . innerHTML = cssString as string ;
1313 doc . head . appendChild ( style ) ;
1414 t = new CSSHelp ( doc ) ;
1515 // JSDOM does not implement latest CSSOM spec. As such,
1616 // conditionText property needs to be manually added.
1717 // REF: https://github.com/freeCodeCamp/freeCodeCamp/pull/42148#issuecomment-847291137
18- const mediaRule = t . getCSSRules ( ' media' ) ?. [ 0 ] as CSSMediaRule ;
18+ const mediaRule = t . getCSSRules ( " media" ) ?. [ 0 ] as CSSMediaRule ;
1919 const conditionText = mediaRule . media [ 0 ] ;
2020 mediaRule . conditionText = conditionText ;
2121 } ) ;
22- describe ( ' getStyle' , ( ) => {
23- it ( ' should return an ExtendedCSSStyleDeclartion object of length 1' , ( ) => {
24- expect ( t . getStyle ( '*' ) ?. length ) . toEqual ( 1 ) ;
22+ describe ( " getStyle" , ( ) => {
23+ it ( " should return an ExtendedCSSStyleDeclartion object of length 1" , ( ) => {
24+ expect ( t . getStyle ( "*" ) ?. length ) . toEqual ( 1 ) ;
2525 } ) ;
26- it ( ' should return a non-empty ExtendedCSSStyleDeclaration object' , ( ) => {
27- expect ( t . getStyle ( ' .bb1' ) ) . toBeTruthy ( ) ;
26+ it ( " should return a non-empty ExtendedCSSStyleDeclaration object" , ( ) => {
27+ expect ( t . getStyle ( " .bb1" ) ) . toBeTruthy ( ) ;
2828 } ) ;
29- it ( ' should return a whitespaceless string' , ( ) => {
30- expect ( t . getStyle ( ' .bb1d' ) ?. getPropVal ( ' background' , true ) ) . toEqual (
31- ' linear-gradient(var(--building-color1)50%,var(--window-color1))'
29+ it ( " should return a whitespaceless string" , ( ) => {
30+ expect ( t . getStyle ( " .bb1d" ) ?. getPropVal ( " background" , true ) ) . toEqual (
31+ " linear-gradient(var(--building-color1)50%,var(--window-color1))"
3232 ) ;
3333 } ) ;
3434 } ) ;
35- describe ( ' getStyleAny' , ( ) => {
36- it ( ' should return an ExtendedCSSStyleDeclartion object of length 1' , ( ) => {
37- expect ( t . getStyleAny ( [ ' .earth' , ' .sky' ] ) ?. length ) . toEqual ( 1 ) ;
35+ describe ( " getStyleAny" , ( ) => {
36+ it ( " should return an ExtendedCSSStyleDeclartion object of length 1" , ( ) => {
37+ expect ( t . getStyleAny ( [ " .earth" , " .sky" ] ) ?. length ) . toEqual ( 1 ) ;
3838 } ) ;
39- it ( ' should return null' , ( ) => {
40- expect ( t . getStyleAny ( [ ' .sun' , ' .earth' , ' .moon' ] ) ) . toBeNull ( ) ;
39+ it ( " should return null" , ( ) => {
40+ expect ( t . getStyleAny ( [ " .sun" , " .earth" , " .moon" ] ) ) . toBeNull ( ) ;
4141 } ) ;
4242 } ) ;
43- describe ( ' isPropertyUsed' , ( ) => {
44- it ( ' should return true on existing properties' , ( ) => {
45- expect ( t . isPropertyUsed ( ' height' ) ) . toBeTruthy ( ) ;
43+ describe ( " isPropertyUsed" , ( ) => {
44+ it ( " should return true on existing properties" , ( ) => {
45+ expect ( t . isPropertyUsed ( " height" ) ) . toBeTruthy ( ) ;
4646 } ) ;
47- it ( ' should return true on existing custom properties' , ( ) => {
48- expect ( t . isPropertyUsed ( ' --building-color1' ) ) . toBeTruthy ( ) ;
47+ it ( " should return true on existing custom properties" , ( ) => {
48+ expect ( t . isPropertyUsed ( " --building-color1" ) ) . toBeTruthy ( ) ;
4949 } ) ;
5050 } ) ;
51- describe ( ' isDeclaredAfter' , ( ) => {
52- it ( ' should return true if existing style is declared after another' , ( ) => {
53- expect ( t . getStyleRule ( ' .bb1a' ) ?. isDeclaredAfter ( ' .bb1' ) ) . toBeTruthy ( ) ;
51+ describe ( " isDeclaredAfter" , ( ) => {
52+ it ( " should return true if existing style is declared after another" , ( ) => {
53+ expect ( t . getStyleRule ( " .bb1a" ) ?. isDeclaredAfter ( " .bb1" ) ) . toBeTruthy ( ) ;
5454 } ) ;
5555 } ) ;
56- describe ( ' getPropertyValue' , ( ) => {
57- it ( ' should return custom property value needing trim' , ( ) => {
56+ describe ( " getPropertyValue" , ( ) => {
57+ it ( " should return custom property value needing trim" , ( ) => {
5858 expect (
59- t . getStyle ( ' :root' ) ?. getPropertyValue ( ' --building-color1' ) ?. trim ( )
60- ) . toEqual ( ' #aa80ff' ) ;
59+ t . getStyle ( " :root" ) ?. getPropertyValue ( " --building-color1" ) ?. trim ( )
60+ ) . toEqual ( " #aa80ff" ) ;
6161 } ) ;
62- it ( ' should return value to existing property' , ( ) => {
62+ it ( " should return value to existing property" , ( ) => {
6363 expect (
64- t . getStyle ( ' .bb4a' ) ?. getPropertyValue ( ' background-color' )
64+ t . getStyle ( " .bb4a" ) ?. getPropertyValue ( " background-color" )
6565 ) . toBeTruthy ( ) ;
6666 } ) ;
67- it ( ' should return property value without evaluating result' , ( ) => {
68- expect ( t . getStyle ( ' .bb4a' ) ?. getPropertyValue ( ' background-color' ) ) . toEqual (
69- ' var(--building-color4)'
67+ it ( " should return property value without evaluating result" , ( ) => {
68+ expect ( t . getStyle ( " .bb4a" ) ?. getPropertyValue ( " background-color" ) ) . toEqual (
69+ " var(--building-color4)"
7070 ) ;
7171 } ) ;
7272 } ) ;
73- describe ( ' getCSSRules' , ( ) => {
74- it ( ' should return a CSSRules array of length 1' , ( ) => {
75- expect ( t . getCSSRules ( ' media' ) ?. length ) . toEqual ( 1 ) ;
73+ describe ( " getCSSRules" , ( ) => {
74+ it ( " should return a CSSRules array of length 1" , ( ) => {
75+ expect ( t . getCSSRules ( " media" ) ?. length ) . toEqual ( 1 ) ;
7676 } ) ;
7777 } ) ;
78- describe ( ' getRuleListsWithinMedia' , ( ) => {
79- it ( ' should return a CSSMediaRule array with a selectable CSSStyleRule' , ( ) => {
78+ describe ( " getRuleListsWithinMedia" , ( ) => {
79+ it ( " should return a CSSMediaRule array with a selectable CSSStyleRule" , ( ) => {
8080 expect (
8181 t
82- . getRuleListsWithinMedia ( ' (max-width: 1000px)' )
83- . find ( x => x . selectorText === ' .sky' )
82+ . getRuleListsWithinMedia ( " (max-width: 1000px)" )
83+ . find ( ( x ) => x . selectorText === " .sky" )
8484 ) . toBeTruthy ( ) ;
8585 } ) ;
86- it ( ' should return CSSStyleDeclaration property with complex value' , ( ) => {
86+ it ( " should return CSSStyleDeclaration property with complex value" , ( ) => {
8787 // NOTE: JSDOM causes value to have tabbed characters, DOM has single-line values.
8888 expect (
8989 t
90- . getRuleListsWithinMedia ( ' (max-width: 1000px)' )
91- . find ( x => x . selectorText === ' .sky' ) ?. style ?. background
90+ . getRuleListsWithinMedia ( " (max-width: 1000px)" )
91+ . find ( ( x ) => x . selectorText === " .sky" ) ?. style ?. background
9292 ) . toEqual (
9393 `radial-gradient(
9494 closest-corner circle at 15% 15%,
@@ -100,28 +100,28 @@ describe('css-help', () => {
100100 ) ;
101101 } ) ;
102102 } ) ;
103- describe ( ' selectorsFromSelector' , ( ) => {
104- it ( ' should return an empty array' , ( ) => {
103+ describe ( " selectorsFromSelector" , ( ) => {
104+ it ( " should return an empty array" , ( ) => {
105105 setupDocument ( ) ;
106- expect ( t . selectorsFromSelector ( ' .void' ) ) . toEqual ( [ ] ) ;
106+ expect ( t . selectorsFromSelector ( " .void" ) ) . toEqual ( [ ] ) ;
107107 } ) ;
108- it ( ' should return an array with 9 members' , ( ) => {
108+ it ( " should return an array with 9 members" , ( ) => {
109109 setupDocument ( ) ;
110- expect ( t . selectorsFromSelector ( 'a' ) ) . toEqual ( [
111- 'a' ,
112- ' label > a' ,
113- ' label a' ,
114- ' form > label > a' ,
115- ' form label a' ,
116- ' body > form > label > a' ,
117- ' body form label a' ,
118- ' html > body > form > label > a' ,
119- ' html body form label a' ,
110+ expect ( t . selectorsFromSelector ( "a" ) ) . toEqual ( [
111+ "a" ,
112+ " label > a" ,
113+ " label a" ,
114+ " form > label > a" ,
115+ " form label a" ,
116+ " body > form > label > a" ,
117+ " body form label a" ,
118+ " html > body > form > label > a" ,
119+ " html body form label a" ,
120120 ] ) ;
121121 } ) ;
122122
123123 function setupDocument ( ) {
124- const form = doc . createElement ( ' form' ) ;
124+ const form = doc . createElement ( " form" ) ;
125125 form . innerHTML = `
126126 <label>
127127 <input type="checkbox" /> I accept the <a href="#">terms and conditions</a>
@@ -132,7 +132,7 @@ describe('css-help', () => {
132132 }
133133 } ) ;
134134 afterEach ( ( ) => {
135- document . body . innerHTML = '' ;
136- document . head . innerHTML = '' ;
135+ document . body . innerHTML = "" ;
136+ document . head . innerHTML = "" ;
137137 } ) ;
138138} ) ;
0 commit comments