1- import dedent from 'dedent' ;
21import { assert } from 'chai' ;
32
43import { from } from '../../../src/index.ts' ;
@@ -10,44 +9,34 @@ describe('serializers', function () {
109 specify ( 'should serialize to YAML 1.2' , function ( ) {
1110 const apidom = from ( true ) ! ;
1211 const serialized = serialize ( apidom ) ;
13- const expected = dedent `
14- true
15- ` ;
1612
17- assert . strictEqual ( serialized , expected ) ;
13+ assert . strictEqual ( serialized , 'true\n' ) ;
1814 } ) ;
1915 } ) ;
2016
2117 context ( 'given NumberElement' , function ( ) {
2218 specify ( 'should serialize to YAML 1.2' , function ( ) {
2319 const apidom = from ( 1 ) ! ;
2420 const serialized = serialize ( apidom ) ;
25- const expected = dedent `
26- 1
27- ` ;
2821
29- assert . strictEqual ( serialized , expected ) ;
22+ assert . strictEqual ( serialized , '1\n' ) ;
3023 } ) ;
3124 } ) ;
3225
3326 context ( 'given StringElement' , function ( ) {
3427 specify ( 'should serialize to YAML 1.2' , function ( ) {
3528 const apidom = from ( 'test' ) ! ;
3629 const serialized = serialize ( apidom ) ;
37- const expected = dedent `
38- "test"
39- ` ;
4030
41- assert . strictEqual ( serialized , expected ) ;
31+ assert . strictEqual ( serialized , 'test\n' ) ;
4232 } ) ;
4333
4434 context ( 'and is multiline' , function ( ) {
4535 specify ( 'should serialize to YAML 1.2' , function ( ) {
4636 const apidom = from ( 'test\n\ntest\n' ) ! ;
4737 const serialized = serialize ( apidom ) ;
48- const expected = String . raw `"test\n\ntest\n"` ;
4938
50- assert . strictEqual ( serialized , expected ) ;
39+ assert . strictEqual ( serialized , '|\ntest\n\ntest\n' ) ;
5140 } ) ;
5241 } ) ;
5342 } ) ;
@@ -56,137 +45,80 @@ describe('serializers', function () {
5645 specify ( 'should serialize to YAML 1.2' , function ( ) {
5746 const apidom = from ( null ) ! ;
5847 const serialized = serialize ( apidom ) ;
59- const expected = dedent `
60- null
61- ` ;
6248
63- assert . strictEqual ( serialized , expected ) ;
49+ assert . strictEqual ( serialized , 'null\n' ) ;
6450 } ) ;
6551 } ) ;
6652
6753 context ( 'given empty ArrayElement' , function ( ) {
6854 specify ( 'should serialize to YAML 1.2' , function ( ) {
6955 const apidom = from ( [ ] ) ! ;
7056 const serialized = serialize ( apidom ) ;
71- const expected = dedent `
72- []
73- ` ;
7457
75- assert . strictEqual ( serialized , expected ) ;
58+ assert . strictEqual ( serialized , '[]\n' ) ;
7659 } ) ;
7760 } ) ;
7861
7962 context ( 'given simple ArrayElement' , function ( ) {
8063 specify ( 'should serialize to YAML 1.2' , function ( ) {
8164 const apidom = from ( [ 1 , true , 'test' , null ] ) ! ;
8265 const serialized = serialize ( apidom , { directive : true } ) ;
83- const expected = dedent `
84- %YAML 1.2
85- ---
8666
87- - 1
88- - true
89- - "test"
90- - null
91- ` ;
92-
93- assert . strictEqual ( serialized , expected ) ;
67+ assert . strictEqual ( serialized , '%YAML 1.2\n---\n- 1\n- true\n- test\n- null\n' ) ;
9468 } ) ;
9569 } ) ;
9670
9771 context ( 'given nested ArrayElement' , function ( ) {
9872 specify ( 'should serialize to YAML 1.2' , function ( ) {
9973 const apidom = from ( [ 1 , [ true , 'test' , null ] ] ) ! ;
10074 const serialized = serialize ( apidom , { directive : true } ) ;
101- const expected = dedent `
102- %YAML 1.2
103- ---
104-
105- - 1
106- -
107- - true
108- - "test"
109- - null
110- ` ;
111-
112- assert . strictEqual ( serialized , expected ) ;
75+
76+ assert . strictEqual ( serialized , '%YAML 1.2\n---\n- 1\n- - true\n - test\n - null\n' ) ;
11377 } ) ;
11478 } ) ;
11579
11680 context ( 'given ArrayElement in ObjectElement' , function ( ) {
11781 specify ( 'should serialize to YAML 1.2' , function ( ) {
11882 const apidom = from ( { a : [ 1 ] } ) ! ;
11983 const serialized = serialize ( apidom , { directive : true } ) ;
120- const expected = dedent `
121- %YAML 1.2
122- ---
123-
124- "a":
125- - 1
126- ` ;
12784
128- assert . strictEqual ( serialized , expected ) ;
85+ assert . strictEqual ( serialized , '%YAML 1.2\n---\na:\n - 1\n' ) ;
12986 } ) ;
13087 } ) ;
13188
13289 context ( 'given empty ObjectElement' , function ( ) {
13390 specify ( 'should serialize to YAML 1.2' , function ( ) {
13491 const apidom = from ( { } ) ! ;
13592 const serialized = serialize ( apidom ) ;
136- const expected = dedent `
137- {}
138- ` ;
13993
140- assert . strictEqual ( serialized , expected ) ;
94+ assert . strictEqual ( serialized , '{}\n' ) ;
14195 } ) ;
14296 } ) ;
14397
14498 context ( 'given simple ObjectElement' , function ( ) {
14599 specify ( 'should serialize to YAML 1.2' , function ( ) {
146100 const apidom = from ( { a : 1 , b : true } ) ! ;
147101 const serialized = serialize ( apidom , { directive : true } ) ;
148- const expected = dedent `
149- %YAML 1.2
150- ---
151102
152- "a": 1
153- "b": true
154- ` ;
155-
156- assert . strictEqual ( serialized , expected ) ;
103+ assert . strictEqual ( serialized , '%YAML 1.2\n---\na: 1\nb: true\n' ) ;
157104 } ) ;
158105 } ) ;
159106
160107 context ( 'given nested ObjectElement' , function ( ) {
161108 specify ( 'should serialize to YAML 1.2' , function ( ) {
162109 const apidom = from ( { a : 1 , b : { c : true } } ) ! ;
163110 const serialized = serialize ( apidom , { directive : true } ) ;
164- const expected = dedent `
165- %YAML 1.2
166- ---
167-
168- "a": 1
169- "b":
170- "c": true
171- ` ;
172111
173- assert . strictEqual ( serialized , expected ) ;
112+ assert . strictEqual ( serialized , '%YAML 1.2\n---\na: 1\nb:\n c: true\n' ) ;
174113 } ) ;
175114 } ) ;
176115
177116 context ( 'given ObjectElement in ArrayElement' , function ( ) {
178117 specify ( 'should serialize to YAML 1.2' , function ( ) {
179118 const apidom = from ( [ { a : true } ] ) ! ;
180119 const serialized = serialize ( apidom , { directive : true } ) ;
181- const expected = dedent `
182- %YAML 1.2
183- ---
184-
185- -
186- "a": true
187- ` ;
188120
189- assert . strictEqual ( serialized , expected ) ;
121+ assert . strictEqual ( serialized , '%YAML 1.2\n---\n- a: true\n' ) ;
190122 } ) ;
191123 } ) ;
192124 } ) ;
0 commit comments