@@ -3,13 +3,16 @@ import { CustomTutorialEntity } from 'src/modules/custom-tutorial/entities/custo
3
3
import { CustomTutorialManifestType } from 'src/modules/custom-tutorial/models/custom-tutorial.manifest' ;
4
4
import { MemoryStoredFile } from 'nestjs-form-data' ;
5
5
import { UploadCustomTutorialDto } from 'src/modules/custom-tutorial/dto/upload.custom-tutorial.dto' ;
6
+ import AdmZip from 'adm-zip' ;
6
7
7
8
export const mockCustomTutorialId = 'a77b23c1-7816-4ea4-b61f-d37795a0f805-ct-id' ;
8
9
9
10
export const mockCustomTutorialId2 = 'a77b23c1-7816-4ea4-b61f-d37795a0f805-ct-id-2' ;
10
11
11
12
export const mockCustomTutorialTmpPath = '/tmp/path' ;
12
13
14
+ export const mockCustomTutorialsHttpLink = 'https://somesime.com/archive.zip' ;
15
+
13
16
export const mockCustomTutorial = Object . assign ( new CustomTutorial ( ) , {
14
17
id : mockCustomTutorialId ,
15
18
name : 'custom tutorial' ,
@@ -23,6 +26,7 @@ export const mockCustomTutorialEntity = Object.assign(new CustomTutorialEntity()
23
26
export const mockCustomTutorial2 = Object . assign ( new CustomTutorial ( ) , {
24
27
id : mockCustomTutorialId2 ,
25
28
name : 'custom tutorial 2' ,
29
+ link : mockCustomTutorialsHttpLink ,
26
30
createdAt : new Date ( ) ,
27
31
} ) ;
28
32
@@ -31,77 +35,94 @@ export const mockCustomTutorialZipFile = Object.assign(new MemoryStoredFile(), {
31
35
buffer : Buffer . from ( 'zip-content' , 'utf8' ) ,
32
36
} ) ;
33
37
38
+ export const mockCustomTutorialZipFileAxiosResponse = {
39
+ data : mockCustomTutorialZipFile . buffer ,
40
+ } ;
41
+
42
+ export const mockCustomTutorialAdmZipEntry = {
43
+ entryName : 'somefolder/info.md' ,
44
+ } as AdmZip . IZipEntry ;
45
+
46
+ export const mockCustomTutorialMacosxAdmZipEntry = {
47
+ entryName : '__MACOSX/info.md' ,
48
+ } as AdmZip . IZipEntry ;
49
+
34
50
export const mockUploadCustomTutorialDto = Object . assign ( new UploadCustomTutorialDto ( ) , {
35
51
name : mockCustomTutorial . name ,
36
52
file : mockCustomTutorialZipFile ,
37
53
} ) ;
38
54
39
- export const mockCustomTutorialManifestManifestJson = {
40
- 'ct-folder-1' : {
55
+ export const mockUploadCustomTutorialExternalLinkDto = Object . assign ( new UploadCustomTutorialDto ( ) , {
56
+ name : mockCustomTutorial . name ,
57
+ link : mockCustomTutorialsHttpLink ,
58
+ } ) ;
59
+
60
+ export const mockCustomTutorialManifestManifestJson = [
61
+ {
41
62
type : 'group' ,
42
63
id : 'ct-folder-1' ,
43
64
label : 'ct-folder-1' ,
44
65
// args: {
45
66
// withBorder: true,
46
67
// initialIsOpen: true,
47
68
// },
48
- children : {
49
- 'ct-sub-folder-1' : {
69
+ children : [
70
+ {
50
71
type : CustomTutorialManifestType . Group ,
51
72
id : 'ct-sub-folder-1' ,
52
73
label : 'ct-sub-folder-1' ,
53
74
// args: {
54
75
// initialIsOpen: false,
55
76
// },
56
- children : {
57
- introduction : {
77
+ children : [
78
+ {
58
79
type : CustomTutorialManifestType . InternalLink ,
59
80
id : 'introduction' ,
60
81
label : 'introduction' ,
61
82
args : {
62
83
path : '/ct-folder-1/ct-sub-folder-1/introduction.md' ,
63
84
} ,
64
85
} ,
65
- 'working-with-hashes' : {
86
+ {
66
87
type : CustomTutorialManifestType . InternalLink ,
67
88
id : 'working-with-hashes' ,
68
89
label : 'working-with-hashes' ,
69
90
args : {
70
91
path : '/ct-folder-1/ct-sub-folder-1/working-with-hashes.md' ,
71
92
} ,
72
93
} ,
73
- } ,
94
+ ] ,
74
95
} ,
75
- 'ct-sub-folder-2' : {
96
+ {
76
97
type : CustomTutorialManifestType . Group ,
77
98
id : 'ct-sub-folder-2' ,
78
99
label : 'ct-sub-folder-2' ,
79
100
// args: {
80
101
// withBorder: true,
81
102
// initialIsOpen: false,
82
103
// },
83
- children : {
84
- introduction : {
104
+ children : [
105
+ {
85
106
type : CustomTutorialManifestType . InternalLink ,
86
107
id : 'introduction' ,
87
108
label : 'introduction' ,
88
109
args : {
89
110
path : '/ct-folder-1/ct-sub-folder-2/introduction.md' ,
90
111
} ,
91
112
} ,
92
- 'working-with-graphs' : {
113
+ {
93
114
type : CustomTutorialManifestType . InternalLink ,
94
115
id : 'working-with-graphs' ,
95
116
label : 'working-with-graphs' ,
96
117
args : {
97
118
path : '/ct-folder-1/ct-sub-folder-2/working-with-graphs.md' ,
98
119
} ,
99
120
} ,
100
- } ,
121
+ ] ,
101
122
} ,
102
- } ,
123
+ ] ,
103
124
} ,
104
- } ;
125
+ ] ;
105
126
106
127
export const mockCustomTutorialManifestManifest = {
107
128
type : CustomTutorialManifestType . Group ,
@@ -121,24 +142,26 @@ export const mockCustomTutorialManifestManifest2 = {
121
142
children : mockCustomTutorialManifestManifestJson ,
122
143
} ;
123
144
124
- export const globalCustomTutorialManifest = {
125
- 'custom-tutorials' : {
145
+ export const globalCustomTutorialManifest = [
146
+ {
126
147
type : CustomTutorialManifestType . Group ,
127
148
id : 'custom-tutorials' ,
128
- label : 'My Tutorials ' ,
149
+ label : 'MY TUTORIALS ' ,
129
150
_actions : [ CustomTutorialActions . CREATE ] ,
130
151
args : {
131
152
withBorder : true ,
132
153
initialIsOpen : true ,
133
154
} ,
134
- children : {
135
- [ mockCustomTutorialManifestManifest . id ] : mockCustomTutorialManifestManifest ,
136
- [ mockCustomTutorialManifestManifest2 . id ] : mockCustomTutorialManifestManifest2 ,
137
- } ,
155
+ children : [
156
+ mockCustomTutorialManifestManifest ,
157
+ mockCustomTutorialManifestManifest2 ,
158
+ ] ,
138
159
} ,
139
- } ;
160
+ ] ;
140
161
141
162
export const mockCustomTutorialFsProvider = jest . fn ( ( ) => ( {
163
+ unzipFromMemoryStoredFile : jest . fn ( ) . mockResolvedValue ( mockCustomTutorialTmpPath ) ,
164
+ unzipFromExternalLink : jest . fn ( ) . mockResolvedValue ( mockCustomTutorialTmpPath ) ,
142
165
unzipToTmpFolder : jest . fn ( ) . mockResolvedValue ( mockCustomTutorialTmpPath ) ,
143
166
moveFolder : jest . fn ( ) ,
144
167
removeFolder : jest . fn ( ) ,
0 commit comments