@@ -43,15 +43,46 @@ function attrValue(element, name) {
4343describe ( 'Parse result namespace' , ( ) => {
4444 context ( 'parse result element' , ( ) => {
4545 let parseResult ;
46+ let refracted ;
4647
4748 beforeEach ( ( ) => {
48- parseResult = ( new ParseResult ( ) ) . fromCompactRefract ( [
49- 'parseResult' , { } , { } , [
50- [ 'annotation' , { classes : [ 'warning' ] } , { } , [ ] ] ,
51- [ 'annotation' , { classes : [ 'error' ] } , { } , [ ] ] ,
52- [ 'category' , { classes : [ 'api' ] } , { } , [ ] ] ,
49+ refracted = {
50+ element : 'parseResult' ,
51+ meta : { } ,
52+ attributes : { } ,
53+ content : [
54+ {
55+ element : 'annotation' ,
56+ meta : {
57+ classes : [ 'warning' ] ,
58+ } ,
59+ attributes : { } ,
60+ content : [ ] ,
61+ } ,
62+ {
63+ element : 'annotation' ,
64+ meta : {
65+ classes : [ 'error' ] ,
66+ } ,
67+ attributes : { } ,
68+ content : [ ] ,
69+ } ,
70+ {
71+ element : 'category' ,
72+ meta : {
73+ classes : [ 'api' ] ,
74+ } ,
75+ attributes : { } ,
76+ content : [ ] ,
77+ } ,
5378 ] ,
54- ] ) ;
79+ } ;
80+
81+ parseResult = ( new ParseResult ( ) ) . fromRefract ( refracted ) ;
82+ } ) ;
83+
84+ it ( 'should round-trip correctly' , ( ) => {
85+ expect ( parseResult . toRefract ( ) ) . to . deep . equal ( refracted ) ;
5586 } ) ;
5687
5788 it ( 'should have element name parseResult' , ( ) => {
@@ -93,11 +124,23 @@ describe('Parse result namespace', () => {
93124
94125 context ( 'annotation element' , ( ) => {
95126 let annotation ;
127+ let refracted ;
96128
97129 beforeEach ( ( ) => {
98- annotation = ( new Annotation ( ) ) . fromCompactRefract ( [
99- 'annotation' , { } , { code : 123 } , 'Missing argument description' ,
100- ] ) ;
130+ refracted = {
131+ element : 'annotation' ,
132+ meta : { } ,
133+ attributes : {
134+ code : 123 ,
135+ } ,
136+ content : 'Missing argument description' ,
137+ } ;
138+
139+ annotation = ( new Annotation ( ) ) . fromRefract ( refracted ) ;
140+ } ) ;
141+
142+ it ( 'should round-trip correctly' , ( ) => {
143+ expect ( annotation . toRefract ( ) ) . to . deep . equal ( refracted ) ;
101144 } ) ;
102145
103146 it ( 'should have element name annotation' , ( ) => {
@@ -122,9 +165,12 @@ describe('Parse result namespace', () => {
122165 let sourceMap ;
123166
124167 beforeEach ( ( ) => {
125- sourceMap = ( new SourceMap ( ) ) . fromCompactRefract ( [
126- 'sourceMap' , { } , { } , [ ] ,
127- ] ) ;
168+ sourceMap = ( new SourceMap ( ) ) . fromRefract ( {
169+ element : 'sourceMap' ,
170+ meta : { } ,
171+ attributes : { } ,
172+ content : [ ] ,
173+ } ) ;
128174 } ) ;
129175
130176 it ( 'should have element name sourceMap' , ( ) => {
@@ -135,18 +181,33 @@ describe('Parse result namespace', () => {
135181 context ( 'source maps' , ( ) => {
136182 let element ;
137183 let sourceMaps ;
184+ let refracted ;
138185
139186 beforeEach ( ( ) => {
140- element = ( new StringElement ( ) ) . fromCompactRefract ( [
141- 'string' , { } , {
187+ refracted = {
188+ element : 'string' ,
189+ meta : { } ,
190+ attributes : {
142191 sourceMap : [
143- [ 'sourceMap' , { } , { } , [ [ 1 , 2 ] ] ] ,
192+ {
193+ element : 'sourceMap' ,
194+ meta : { } ,
195+ attributes : { } ,
196+ content : [ [ 1 , 2 ] ] ,
197+ } ,
144198 ] ,
145- } , [ ] ,
146- ] ) ;
199+ } ,
200+ content : [ ] ,
201+ } ;
202+
203+ element = ( new StringElement ( ) ) . fromRefract ( refracted ) ;
147204 sourceMaps = element . attributes . get ( 'sourceMap' ) ;
148205 } ) ;
149206
207+ it ( 'should round-trip correctly' , ( ) => {
208+ expect ( element . toRefract ( ) ) . to . deep . equal ( refracted ) ;
209+ } ) ;
210+
150211 it ( 'should contain a sourceMap attribute with one item' , ( ) => {
151212 expect ( sourceMaps ) . to . exist ;
152213 expect ( sourceMaps ) . to . have . length ( 1 ) ;
@@ -166,9 +227,7 @@ describe('Parse result namespace', () => {
166227 element : 'sourceMap' ,
167228 meta : { } ,
168229 attributes : { } ,
169- content : [
170- [ 1 , 2 ] ,
171- ] ,
230+ content : [ [ 1 , 2 ] ] ,
172231 } ,
173232 ] ,
174233 } ,
0 commit comments