1
- import { describe , it , expect } from 'vitest' ;
1
+ import path from "path" ;
2
2
3
- import { getZipFileContent } from '../../../playgrounds/utils' ;
4
- import path from 'path' ;
3
+ import { describe , expect , it } from "vitest" ;
5
4
6
- describe ( 'build-frontend' , ( ) => {
5
+ import { getZipFileContent } from "../../../playgrounds/utils" ;
6
+
7
+ describe ( "build-frontend" , ( ) => {
7
8
it ( "should have manifest.json file" , async ( ) => {
8
- const zipPath = path . resolve ( __dirname , '../dist/plugin_package.zip' ) ;
9
-
10
- const manifestJsonContent = await getZipFileContent ( zipPath , 'manifest.json' ) ;
11
-
12
- expect ( manifestJsonContent ) . toEqual ( JSON . stringify ( {
13
- "id" : "build-frontend" ,
14
- "name" : "Frontend" ,
15
- "version" : "1.0.0" ,
16
- "description" : "Frontend plugin" ,
17
- "author" : {
18
- "name" : "John Doe" ,
19
-
20
- "url" : "https://example.com"
21
- } ,
22
- "plugins" : [
9
+ const zipPath = path . resolve ( __dirname , "../dist/plugin_package.zip" ) ;
10
+
11
+ const manifestJsonContent = await getZipFileContent (
12
+ zipPath ,
13
+ "manifest.json" ,
14
+ ) ;
15
+
16
+ expect ( manifestJsonContent ) . toEqual (
17
+ JSON . stringify (
23
18
{
24
- "id" : "frontend" ,
25
- "kind" : "frontend" ,
26
- "name" : "frontend" ,
27
- "entrypoint" : "frontend/index.js" ,
28
- "style" : "frontend/index.css" ,
29
- "backend" : null
30
- }
31
- ]
32
- } , undefined , 2 ) ) ;
19
+ id : "build-frontend" ,
20
+ name : "Frontend" ,
21
+ version : "1.0.0" ,
22
+ description : "Frontend plugin" ,
23
+ author : {
24
+ name : "John Doe" ,
25
+
26
+ url : "https://example.com" ,
27
+ } ,
28
+ plugins : [
29
+ {
30
+ id : "frontend" ,
31
+ kind : "frontend" ,
32
+ name : "frontend" ,
33
+ entrypoint : "frontend/index.js" ,
34
+ style : "frontend/index.css" ,
35
+ backend : null ,
36
+ } ,
37
+ ] ,
38
+ } ,
39
+ undefined ,
40
+ 2 ,
41
+ ) ,
42
+ ) ;
33
43
} ) ;
34
44
35
45
it ( "should have index.js file" , async ( ) => {
36
- const zipPath = path . resolve ( __dirname , ' ../dist/plugin_package.zip' ) ;
46
+ const zipPath = path . resolve ( __dirname , " ../dist/plugin_package.zip" ) ;
37
47
38
- const indexJsContent = ( await getZipFileContent ( zipPath , 'frontend/index.js' ) ) ?. replace ( / \s + / g, '' ) ;
48
+ const indexJsContent = (
49
+ await getZipFileContent ( zipPath , "frontend/index.js" )
50
+ ) ?. replace ( / \s + / g, "" ) ;
39
51
40
52
const expectedContent = `
41
53
const o = () => {
@@ -44,16 +56,19 @@ describe('build-frontend', () => {
44
56
export {
45
57
o as init
46
58
};
47
- ` . replace ( / \s + / g, '' ) ;
59
+ ` . replace ( / \s + / g, "" ) ;
48
60
49
61
expect ( indexJsContent ) . toEqual ( expectedContent ) ;
50
62
} ) ;
51
63
52
64
it ( "should have index.css file" , async ( ) => {
53
- const zipPath = path . resolve ( __dirname , ' ../dist/plugin_package.zip' ) ;
65
+ const zipPath = path . resolve ( __dirname , " ../dist/plugin_package.zip" ) ;
54
66
55
- const indexCssContent = await getZipFileContent ( zipPath , 'frontend/index.css' ) ;
67
+ const indexCssContent = await getZipFileContent (
68
+ zipPath ,
69
+ "frontend/index.css" ,
70
+ ) ;
56
71
57
- expect ( indexCssContent ) . toEqual ( ' body{background-color:red}\n' ) ;
72
+ expect ( indexCssContent ) . toEqual ( " body{background-color:red}\n" ) ;
58
73
} ) ;
59
74
} ) ;
0 commit comments