11const utils = require ( './utils' ) ;
2- const { COLORS , onBeforeAll, assert} = utils ;
2+ const { COLORS , onBeforeAll, onBeforeEach , assert} = utils ;
33
4- describe ( 'Selectors' , ( ) => {
5- beforeAll ( onBeforeAll ) ;
4+ module . exports = describe ( 'Selectors' , ( ) => {
5+ beforeAll ( async ( ) => {
6+ await onBeforeAll ( ) ;
7+ } ) ;
8+
9+ beforeEach ( async ( ) => {
10+ await onBeforeEach ( ) ;
11+ } ) ;
612
713 it ( 'Simple selector with simple class' , async ( ) => {
8- assert ( '#example' , '[ul]:background-[red]' , { } ) ;
9- const children = await page . $$ ( '#example ul' ) ;
14+ await assert ( '#example-second' , '[ul]:background-[red]' , { } ) ;
15+ const children = await page . $$ ( '#example-second ul' ) ;
16+ for ( const child of children ) {
17+ await assert ( child , null , { backgroundColor : COLORS . red } ) ;
18+ }
19+ } ) ;
20+
21+ it ( 'Simple selector with multiple classes' , async ( ) => {
22+ await assert ( '#example-second' , '[ul]:background-[red] color-[white]' , { } ) ;
23+ const children = await page . $$ ( '#example-second ul' ) ;
24+ for ( const child of children ) {
25+ await assert ( child , null , {
26+ backgroundColor : COLORS . red ,
27+ color : COLORS . white
28+ } ) ;
29+ }
30+ } ) ;
31+
32+ it ( 'Selector ">" with simple class' , async ( ) => {
33+ await assert ( '#example-second' , '[> ul]:display-[flex]' , { } ) ;
34+ const children = await page . $$ ( '#example-second > ul' ) ;
35+ for ( const child of children ) {
36+ await assert ( child , null , { display : 'flex' } ) ;
37+ }
38+ } ) ;
39+
40+ it ( 'Selector ">" with multiple classes' , async ( ) => {
41+ await assert ( '#example-second' , '[> ul]:{display-[flex] flex-direction-[row]}' , { } ) ;
42+ const children = await page . $$ ( '#example-second > ul' ) ;
43+ for ( const child of children ) {
44+ await assert ( child , null , {
45+ display : 'flex' ,
46+ flexDirection : 'row'
47+ } ) ;
48+ }
49+ } ) ;
50+
51+ it ( 'Selector "+" with simple class' , async ( ) => {
52+ await assert ( '#example' , '[+ div]:justify-content-[space-between]' , { } ) ;
53+ const element = await page . $ ( '#example + div' ) ;
54+ await assert ( element , null , { justifyContent : 'space-between' } ) ;
55+ } ) ;
56+
57+ it ( 'Selector "+" with multiple classes' , async ( ) => {
58+ await assert ( '#example' , '[+ div]:{justify-content-[space-between] align-items-[center]}' , { } ) ;
59+ const element = await page . $ ( '#example + div' ) ;
60+ await assert ( element , null , {
61+ justifyContent : 'space-between' ,
62+ alignItems : 'center'
63+ } ) ;
64+ } ) ;
65+
66+ it ( 'Selector "~" with simple class' , async ( ) => {
67+ await assert ( '#example' , '[~ div]:align-items-[center]' , { } ) ;
68+ const children = await page . $$ ( '#example ~ div' ) ;
69+ for ( const child of children ) {
70+ await assert ( child , null , { alignItems : 'center' } ) ;
71+ }
72+ } ) ;
73+
74+ it ( 'Selector "~" with multiple classes' , async ( ) => {
75+ await assert ( '#example' , '[~ div]:{align-items-[center] flex-direction-[row]}' , { } ) ;
76+ const children = await page . $$ ( '#example ~ div' ) ;
1077 for ( const child of children ) {
11- assert ( child , null , { backgroundColor : COLORS . red } ) ;
78+ await assert ( child , null , {
79+ alignItems : 'center' ,
80+ flexDirection : 'row'
81+ } ) ;
1282 }
1383 } ) ;
84+
1485} ) ;
0 commit comments