1- import { htmlFragment } from '..' ;
1+ import { htmlFragment as html } from '..' ;
22
33const helloWorld = `<h1>Hello, World!</h1>` ;
44const peopleList = [
@@ -8,77 +8,72 @@ const peopleList = [
88 'Cash Black' ,
99] ;
1010
11- describe ( 'htmlFragment' , ( ) => {
12- const html = htmlFragment ;
13-
14- it ( `throws when error happens` , async ( ) => {
15- try {
16- const errorContent = async ( ) => { throw new Error ( 'error' ) ; } ;
17- await html `${ errorContent } ` ;
18- } catch ( e ) {
19- expect ( e ) . toStrictEqual ( new Error ( 'error' ) ) ;
20- }
21- } ) ;
22-
23- it ( `renders` , async ( ) => {
24- const d = await html `${ helloWorld } ` ;
11+ it ( `throws when error happens` , async ( ) => {
12+ try {
13+ const errorContent = async ( ) => { throw new Error ( 'error' ) ; } ;
14+ await html `${ errorContent } ` ;
15+ } catch ( e ) {
16+ expect ( e ) . toStrictEqual ( new Error ( 'error' ) ) ;
17+ }
18+ } ) ;
2519
26- expect ( d ) . toStrictEqual (
27- `<h1>Hello, World!</h1>`
28- ) ;
29- } ) ;
20+ it ( `renders` , async ( ) => {
21+ const d = await html `${ helloWorld } ` ;
3022
31- it ( `renders with sync tasks` , async ( ) => {
32- const syncTask = ( ) => helloWorld ;
33- const syncLiteral = 'John Doe' ;
34- const d = await html ` < section > ${ syncTask } < h2 > ${ syncLiteral } </ h2 > </ section > ` ;
23+ expect ( d ) . toStrictEqual (
24+ `<h1>Hello, World!</h1>`
25+ ) ;
26+ } ) ;
3527
36- expect ( d ) . toStrictEqual (
37- // tslint:disable-next-line: max-line-length
38- `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
39- ) ;
40- } ) ;
28+ it ( `renders with sync tasks` , async ( ) => {
29+ const syncTask = ( ) => helloWorld ;
30+ const syncLiteral = 'John Doe' ;
31+ const d = await html `< section > ${ syncTask } < h2 > ${ syncLiteral } </ h2 > </ section > ` ;
4132
42- it ( `renders with async tasks` , async ( ) => {
43- const asyncTask = async ( ) => helloWorld ;
44- const asyncLiteral = Promise . resolve ( 'John Doe' ) ;
45- const d = await html `< section > ${ asyncTask } < h2 > ${ asyncLiteral } </ h2 > </ section > ` ;
33+ expect ( d ) . toStrictEqual (
34+ // tslint:disable-next-line: max-line-length
35+ `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
36+ ) ;
37+ } ) ;
4638
47- expect ( d ) . toStrictEqual (
48- // tslint:disable-next-line: max-line-length
49- `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
50- ) ;
51- } ) ;
39+ it ( `renders with async tasks` , async ( ) => {
40+ const asyncTask = async ( ) => helloWorld ;
41+ const asyncLiteral = Promise . resolve ( 'John Doe' ) ;
42+ const d = await html `< section > ${ asyncTask } < h2 > ${ asyncLiteral } </ h2 > </ section > ` ;
5243
53- it ( `renders with a mixture of sync + async tasks` , async ( ) => {
54- const asyncTask = async ( ) => helloWorld ;
55- const syncLiteral = await 'John Doe' ;
56- const d = await html `< section > ${ asyncTask } < h2 > ${ syncLiteral } </ h2 > </ section > ` ;
44+ expect ( d ) . toStrictEqual (
45+ // tslint:disable-next-line: max-line-length
46+ `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
47+ ) ;
48+ } ) ;
5749
58- expect ( d ) . toStrictEqual (
59- // tslint:disable-next-line: max-line-length
60- `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
61- ) ;
62- } ) ;
50+ it ( `renders with a mixture of sync + async tasks` , async ( ) => {
51+ const asyncTask = async ( ) => helloWorld ;
52+ const syncLiteral = await 'John Doe' ;
53+ const d = await html `< section > ${ asyncTask } < h2 > ${ syncLiteral } </ h2 > </ section > ` ;
6354
64- it ( `renders a list of sync tasks` , async ( ) => {
65- const d = await html `${ helloWorld } < ul > ${ peopleList . map ( n => `<li>${ n } </li>` ) } </ ul > ` ;
55+ expect ( d ) . toStrictEqual (
56+ // tslint:disable-next-line: max-line-length
57+ `<section><h1>Hello, World!</h1><h2>John Doe</h2></section>`
58+ ) ;
59+ } ) ;
6660
67- expect ( d ) . toStrictEqual (
68- // tslint:disable-next-line: max-line-length
69- `<h1>Hello, World!</h1><ul><li>John Doe</li><li>Michael CEO</li><li>Vict Fisherman</li><li>Cash Black</li></ul>`
70- ) ;
71- } ) ;
61+ it ( `renders a list of sync tasks` , async ( ) => {
62+ const d = await html `${ helloWorld } < ul > ${ peopleList . map ( n => `<li>${ n } </li>` ) } </ ul > ` ;
7263
73- it ( `renders external style` , async ( ) => {
64+ expect ( d ) . toStrictEqual (
7465 // tslint:disable-next-line: max-line-length
75- const asyncExternalStyleTask = async ( ) => html /* css */ `body { margin: 0; padding: 0; box-sizing: border-box; }` ;
76- const d = await html `< style > ${ asyncExternalStyleTask } </ style > ${ helloWorld } ` ;
66+ `<h1>Hello, World!</h1><ul><li>John Doe</li><li>Michael CEO</li><li>Vict Fisherman</li><li>Cash Black</li></ul>`
67+ ) ;
68+ } ) ;
7769
78- expect ( d ) . toStrictEqual (
79- // tslint:disable-next-line: max-line-length
80- `<style>body { margin: 0; padding: 0; box-sizing: border-box; }</style><h1>Hello, World!</h1>`
81- ) ;
82- } ) ;
70+ it ( `renders external style` , async ( ) => {
71+ // tslint:disable-next-line: max-line-length
72+ const asyncExternalStyleTask = async ( ) => html /* css */ `body { margin: 0; padding: 0; box-sizing: border-box; }` ;
73+ const d = await html `< style > ${ asyncExternalStyleTask } </ style > ${ helloWorld } ` ;
8374
75+ expect ( d ) . toStrictEqual (
76+ // tslint:disable-next-line: max-line-length
77+ `<style>body { margin: 0; padding: 0; box-sizing: border-box; }</style><h1>Hello, World!</h1>`
78+ ) ;
8479} ) ;
0 commit comments