File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Verify that styles and content will cascade.
3+ */
4+
5+ import { test , expect } from '@playwright/test' ;
6+ import { cssToHtml } from '../src/index' ;
7+
8+ const css = `
9+ a {
10+ content: 'https://example.com/';
11+ border-radius: 5px;
12+ }
13+ a {
14+ content: 'https://example.com/page';
15+ border-radius: 10px;
16+ }
17+ ` ;
18+
19+ test ( 'Cascading' , async ( { page } ) => {
20+ await page . addScriptTag ( { path : './tests/GeneratorScript.js' } ) ;
21+
22+ const result = await page . evaluate ( async ( css ) => {
23+ document . body = cssToHtml ( css ) ;
24+ const styleElement = document . createElement ( 'style' ) ;
25+ styleElement . innerText = css ;
26+ document . head . append ( styleElement ) ;
27+
28+ const element = document . body . querySelector ( 'a' ) ;
29+ return element
30+ && element . href === 'https://example.com/page'
31+ && element . innerHTML === ''
32+ && window . getComputedStyle ( element ) . borderRadius === '10px' ;
33+ } , css ) ;
34+
35+ expect ( result ) . toBeDefined ( ) ;
36+ expect ( result ) . toBe ( true ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments