@@ -24,9 +24,9 @@ import {
2424 TRANSFORMATION_KIND_REDUCED ,
2525 YAML_EXPORT_GROUP_FORMAT ,
2626} from '../src'
27- // import fs from 'fs/promises'
27+ import fs from 'fs/promises'
2828
29- // const EXPORT_RESULTS_PATH = 'test/versions/export_results'
29+ const EXPORT_RESULTS_PATH = 'test/versions/export_results'
3030
3131let pkg : LocalRegistry
3232let editor : Editor
@@ -40,7 +40,7 @@ const groupToOperationIdsMap2 = {
4040
4141const COMMON_GROUP_EXPORT_CONFIG = {
4242 packageId : 'export' ,
43- version : 'v1 ' ,
43+ version : 'regular-version ' ,
4444 groupName : GROUP_NAME ,
4545}
4646
@@ -61,18 +61,19 @@ const COMMON_MERGED_GROUP_EXPORT_CONFIG: Partial<ExportRestOperationsGroupBuildC
6161describe ( 'Export test' , ( ) => {
6262 beforeAll ( async ( ) => {
6363 pkg = LocalRegistry . openPackage ( 'export' )
64- // pkgForGroupExport = LocalRegistry.openPackage('export')
64+ await pkg . publish ( pkg . packageId , { version : 'regular-version' } )
65+ await pkg . publish ( pkg . packageId , { version : 'single-document-version' , files : [ { fileId : '1.yaml' } ] } )
66+
6567 editor = await Editor . openProject ( pkg . packageId , pkg )
66- await pkg . publish ( pkg . packageId )
6768
68- // if (!await fs.stat(EXPORT_RESULTS_PATH)) {
69- // await fs.mkdir(EXPORT_RESULTS_PATH)
70- // }
69+ if ( ! await fs . stat ( EXPORT_RESULTS_PATH ) ) {
70+ await fs . mkdir ( EXPORT_RESULTS_PATH )
71+ }
7172 } )
7273
7374 afterEach ( async ( ) => {
74- // const { packageVersion, exportFileName } = await editor.createNodeVersionPackage()
75- // await fs.writeFile(`${EXPORT_RESULTS_PATH}/${exportFileName}`, packageVersion)
75+ const { packageVersion, exportFileName } = await editor . createNodeVersionPackage ( )
76+ await fs . writeFile ( `${ EXPORT_RESULTS_PATH } /${ exportFileName } ` , packageVersion )
7677 } )
7778
7879 test ( 'should export rest document to html' , async ( ) => {
@@ -81,7 +82,7 @@ describe('Export test', () => {
8182 documentId : '1' ,
8283 format : 'html' ,
8384 } )
84- expect ( result . exportFileName ) . toEqual ( 'export_v1_1 .zip' )
85+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_1 .zip' )
8586 // todo check zip content
8687 } )
8788
@@ -91,7 +92,7 @@ describe('Export test', () => {
9192 documentId : '1' ,
9293 format : 'json' ,
9394 } )
94- expect ( result . exportFileName ) . toEqual ( 'export_v1_1 .json' )
95+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_1 .json' )
9596 // todo check zip content
9697 } )
9798
@@ -101,7 +102,7 @@ describe('Export test', () => {
101102 documentId : '1' ,
102103 format : 'yaml' ,
103104 } )
104- expect ( result . exportFileName ) . toEqual ( 'export_v1_1 .yaml' )
105+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_1 .yaml' )
105106 // todo check zip content
106107 } )
107108
@@ -111,7 +112,7 @@ describe('Export test', () => {
111112 buildType : BUILD_TYPE . EXPORT_VERSION ,
112113 format : 'html' ,
113114 } )
114- expect ( result . exportFileName ) . toEqual ( 'export_v1 .zip' )
115+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version .zip' )
115116 // todo check zip content
116117 } )
117118
@@ -121,7 +122,7 @@ describe('Export test', () => {
121122 buildType : BUILD_TYPE . EXPORT_VERSION ,
122123 format : 'json' ,
123124 } )
124- expect ( result . exportFileName ) . toEqual ( 'export_v1 .zip' )
125+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version .zip' )
125126 // todo check zip content
126127 } )
127128
@@ -131,13 +132,43 @@ describe('Export test', () => {
131132 buildType : BUILD_TYPE . EXPORT_VERSION ,
132133 format : 'yaml' ,
133134 } )
134- expect ( result . exportFileName ) . toEqual ( 'export_v1.zip' )
135+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version.zip' )
136+ // todo check zip content
137+ } )
138+
139+ test ( 'should export single document version to html' , async ( ) => {
140+ const result = await editor . run ( {
141+ version : 'single-document-version' ,
142+ buildType : BUILD_TYPE . EXPORT_VERSION ,
143+ format : 'html' ,
144+ } )
145+ expect ( result . exportFileName ) . toEqual ( 'export_single-document-version.zip' )
146+ // todo check zip content
147+ } )
148+
149+ test ( 'should export single document version to json' , async ( ) => {
150+ const result = await editor . run ( {
151+ version : 'single-document-version' ,
152+ buildType : BUILD_TYPE . EXPORT_VERSION ,
153+ format : 'json' ,
154+ } )
155+ expect ( result . exportFileName ) . toEqual ( 'export_single-document-version.zip' )
156+ // todo check zip content
157+ } )
158+
159+ test ( 'should export single document version to yaml' , async ( ) => {
160+ const result = await editor . run ( {
161+ version : 'single-document-version' ,
162+ buildType : BUILD_TYPE . EXPORT_VERSION ,
163+ format : 'yaml' ,
164+ } )
165+ expect ( result . exportFileName ) . toEqual ( 'export_single-document-version.zip' )
135166 // todo check zip content
136167 } )
137168
138- // todo check case with single file in version
169+ // todo check case with readme
139170
140- // todo same 3 tests but without extensions?
171+ // todo same 3 tests but without extensions? (excessive)
141172
142173 test ( 'should export reduced rest operations group to html' , async ( ) => {
143174 pkg = LocalRegistry . openPackage ( 'export' , groupToOperationIdsMap2 )
@@ -147,7 +178,7 @@ describe('Export test', () => {
147178 ...COMMON_REDUCED_GROUP_EXPORT_CONFIG ,
148179 format : HTML_EXPORT_GROUP_FORMAT ,
149180 } )
150- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .zip' )
181+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .zip' )
151182 // todo check zip content
152183 } )
153184
@@ -159,7 +190,7 @@ describe('Export test', () => {
159190 ...COMMON_REDUCED_GROUP_EXPORT_CONFIG ,
160191 format : JSON_EXPORT_GROUP_FORMAT ,
161192 } )
162- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .zip' )
193+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .zip' )
163194 // todo check zip content
164195 } )
165196
@@ -171,7 +202,7 @@ describe('Export test', () => {
171202 ...COMMON_REDUCED_GROUP_EXPORT_CONFIG ,
172203 format : YAML_EXPORT_GROUP_FORMAT ,
173204 } )
174- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .zip' )
205+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .zip' )
175206 // todo check zip content
176207 } )
177208
@@ -182,7 +213,7 @@ describe('Export test', () => {
182213 ...COMMON_MERGED_GROUP_EXPORT_CONFIG ,
183214 format : HTML_EXPORT_GROUP_FORMAT ,
184215 } )
185- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .zip' )
216+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .zip' )
186217 // todo check zip content
187218 } )
188219
@@ -193,7 +224,7 @@ describe('Export test', () => {
193224 ...COMMON_MERGED_GROUP_EXPORT_CONFIG ,
194225 format : JSON_EXPORT_GROUP_FORMAT ,
195226 } )
196- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .json' )
227+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .json' )
197228 // todo check zip content
198229 } )
199230
@@ -205,7 +236,7 @@ describe('Export test', () => {
205236 ...COMMON_MERGED_GROUP_EXPORT_CONFIG ,
206237 format : YAML_EXPORT_GROUP_FORMAT ,
207238 } )
208- expect ( result . exportFileName ) . toEqual ( 'export_v1_manualGroup .yaml' )
239+ expect ( result . exportFileName ) . toEqual ( 'export_regular-version_manualGroup .yaml' )
209240 // todo check zip content
210241 } )
211242} )
0 commit comments