@verdaccio/web 6.0.0-6-next.26 → 6.0.0-6-next.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/build/api/readme.js +2 -3
- package/build/api/readme.js.map +1 -1
- package/build/api/search.js +64 -61
- package/build/api/search.js.map +1 -1
- package/build/middleware/render-web.d.ts +1 -1
- package/build/middleware/render-web.js +1 -6
- package/build/middleware/render-web.js.map +1 -1
- package/build/middleware/web-api.js +1 -6
- package/build/middleware/web-api.js.map +1 -1
- package/build/renderHTML.js +30 -14
- package/build/renderHTML.js.map +1 -1
- package/build/utils/web-utils.js +1 -1
- package/build/utils/web-utils.js.map +1 -1
- package/build/web-middleware.js +1 -1
- package/build/web-middleware.js.map +1 -1
- package/package.json +70 -65
- package/src/api/readme.ts +2 -3
- package/src/api/search.ts +64 -55
- package/src/middleware/render-web.ts +1 -3
- package/src/middleware/web-api.ts +0 -2
- package/src/renderHTML.ts +31 -9
- package/src/utils/web-utils.ts +1 -1
- package/src/web-middleware.ts +1 -1
- package/test/api.readme.test.ts +29 -27
- package/test/api.search.test.ts +18 -45
- package/test/api.sidebar.test.ts +22 -36
- package/test/api.user.test.ts +1 -1
- package/test/config/default-test.yaml +1 -5
- package/test/config/login-disabled.yaml +1 -5
- package/test/config/web.yaml +46 -0
- package/test/helper.ts +7 -23
- package/test/partials/search/search-v1.json +157 -0
- package/test/render.test.ts +71 -24
- package/test/utils.spec.ts +10 -1
- package/tsconfig.json +6 -0
package/test/api.sidebar.test.ts
CHANGED
|
@@ -3,9 +3,8 @@ import supertest from 'supertest';
|
|
|
3
3
|
|
|
4
4
|
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
5
5
|
import { setup } from '@verdaccio/logger';
|
|
6
|
-
import {
|
|
6
|
+
import { publishVersion } from '@verdaccio/test-helper';
|
|
7
7
|
|
|
8
|
-
import { NOT_README_FOUND } from '../src/api/readme';
|
|
9
8
|
import { initializeServer } from './helper';
|
|
10
9
|
|
|
11
10
|
setup([]);
|
|
@@ -13,36 +12,15 @@ setup([]);
|
|
|
13
12
|
const mockManifest = jest.fn();
|
|
14
13
|
jest.mock('@verdaccio/ui-theme', () => mockManifest());
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
Storage: class {
|
|
18
|
-
public init() {
|
|
19
|
-
return Promise.resolve();
|
|
20
|
-
}
|
|
21
|
-
public getPackage({ name, callback }: IGetPackageOptions) {
|
|
22
|
-
callback(null, {
|
|
23
|
-
name,
|
|
24
|
-
['dist-tags']: {
|
|
25
|
-
latest: '1.0.0',
|
|
26
|
-
},
|
|
27
|
-
versions: {
|
|
28
|
-
['1.0.0']: {
|
|
29
|
-
name,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
SearchInstance: {
|
|
36
|
-
configureStorage: () => {},
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
describe.skip('sidebar api', () => {
|
|
15
|
+
describe('sidebar api', () => {
|
|
41
16
|
beforeAll(() => {
|
|
42
|
-
mockManifest.mockReturnValue({
|
|
17
|
+
mockManifest.mockReturnValue(() => ({
|
|
43
18
|
staticPath: path.join(__dirname, 'static'),
|
|
19
|
+
manifestFiles: {
|
|
20
|
+
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
21
|
+
},
|
|
44
22
|
manifest: require('./partials/manifest/manifest.json'),
|
|
45
|
-
});
|
|
23
|
+
}));
|
|
46
24
|
});
|
|
47
25
|
|
|
48
26
|
afterEach(() => {
|
|
@@ -50,15 +28,23 @@ describe.skip('sidebar api', () => {
|
|
|
50
28
|
mockManifest.mockClear();
|
|
51
29
|
});
|
|
52
30
|
|
|
53
|
-
test('should display sidebar info', async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const response = await supertest(await initializeServer('default-test.yaml'))
|
|
31
|
+
test('should display sidebar info scoped package', async () => {
|
|
32
|
+
const app = await initializeServer('default-test.yaml');
|
|
33
|
+
await publishVersion(app, '@scope/pk1-test', '1.0.0', { readme: 'my readme scoped' });
|
|
34
|
+
const response = await supertest(app)
|
|
58
35
|
.get('/-/verdaccio/data/sidebar/@scope/pk1-test')
|
|
59
|
-
.set('Accept', HEADERS.TEXT_PLAIN)
|
|
60
36
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
61
37
|
.expect(HTTP_STATUS.OK);
|
|
62
|
-
expect(response.text).toMatch(
|
|
38
|
+
expect(response.text).toMatch('@scope/pk1-test');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('should display sidebar info package', async () => {
|
|
42
|
+
const app = await initializeServer('default-test.yaml');
|
|
43
|
+
await publishVersion(app, 'pk2-test', '1.0.0', { readme: 'my readme scoped' });
|
|
44
|
+
const response = await supertest(app)
|
|
45
|
+
.get('/-/verdaccio/data/sidebar/pk2-test')
|
|
46
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
47
|
+
.expect(HTTP_STATUS.OK);
|
|
48
|
+
expect(response.text).toMatch('pk2-test');
|
|
63
49
|
});
|
|
64
50
|
});
|
package/test/api.user.test.ts
CHANGED
|
@@ -64,7 +64,7 @@ describe('test web server', () => {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
test('log in should be disabled', async () => {
|
|
67
|
+
test.skip('log in should be disabled', async () => {
|
|
68
68
|
return supertest(await initializeServer('login-disabled.yaml'))
|
|
69
69
|
.post('/-/verdaccio/sec/login')
|
|
70
70
|
.send(
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
store:
|
|
2
|
-
memory:
|
|
3
|
-
limit: 1000
|
|
4
|
-
|
|
5
1
|
auth:
|
|
6
2
|
auth-memory:
|
|
7
3
|
users:
|
|
@@ -17,7 +13,7 @@ publish:
|
|
|
17
13
|
|
|
18
14
|
uplinks:
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
log: { type: stdout, format: pretty, level: trace }
|
|
21
17
|
|
|
22
18
|
packages:
|
|
23
19
|
'@*/*':
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
store:
|
|
2
|
-
memory:
|
|
3
|
-
limit: 1000
|
|
4
|
-
|
|
5
1
|
auth:
|
|
6
2
|
auth-memory:
|
|
7
3
|
users:
|
|
@@ -18,7 +14,7 @@ publish:
|
|
|
18
14
|
|
|
19
15
|
uplinks:
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
log: { type: stdout, format: pretty, level: trace }
|
|
22
18
|
|
|
23
19
|
packages:
|
|
24
20
|
'@*/*':
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
auth:
|
|
2
|
+
auth-memory:
|
|
3
|
+
users:
|
|
4
|
+
test:
|
|
5
|
+
name: test
|
|
6
|
+
password: test
|
|
7
|
+
|
|
8
|
+
web:
|
|
9
|
+
title: verdaccio web
|
|
10
|
+
login: true
|
|
11
|
+
scope: '@scope'
|
|
12
|
+
pkgManagers:
|
|
13
|
+
- pnpm
|
|
14
|
+
- yarn
|
|
15
|
+
showInfo: true
|
|
16
|
+
showSettings: true
|
|
17
|
+
showSearch: true
|
|
18
|
+
showFooter: true
|
|
19
|
+
showThemeSwitch: true
|
|
20
|
+
showDownloadTarball: true
|
|
21
|
+
showRaw: true
|
|
22
|
+
primary_color: '#ffffff'
|
|
23
|
+
logoURI: 'http://logo.org/logo.png'
|
|
24
|
+
flags:
|
|
25
|
+
- something: false
|
|
26
|
+
|
|
27
|
+
url_prefix: /prefix
|
|
28
|
+
|
|
29
|
+
publish:
|
|
30
|
+
allow_offline: false
|
|
31
|
+
|
|
32
|
+
uplinks:
|
|
33
|
+
|
|
34
|
+
log: { type: stdout, format: pretty, level: trace }
|
|
35
|
+
|
|
36
|
+
packages:
|
|
37
|
+
'@*/*':
|
|
38
|
+
access: $anonymous
|
|
39
|
+
publish: $anonymous
|
|
40
|
+
'**':
|
|
41
|
+
access: $anonymous
|
|
42
|
+
publish: $anonymous
|
|
43
|
+
_debug: true
|
|
44
|
+
|
|
45
|
+
flags:
|
|
46
|
+
changePassword: true
|
package/test/helper.ts
CHANGED
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
import bodyParser from 'body-parser';
|
|
2
|
-
import express from 'express';
|
|
3
1
|
import { Application } from 'express';
|
|
4
2
|
import path from 'path';
|
|
5
3
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import apiMiddleware from '@verdaccio/api';
|
|
5
|
+
import { parseConfigFile } from '@verdaccio/config';
|
|
8
6
|
import { setup } from '@verdaccio/logger';
|
|
9
|
-
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
|
|
10
7
|
import { Storage } from '@verdaccio/store';
|
|
8
|
+
import { initializeServer as initializeServerHelper } from '@verdaccio/test-helper';
|
|
11
9
|
|
|
12
10
|
import routes from '../src';
|
|
13
11
|
|
|
14
12
|
setup([]);
|
|
15
13
|
|
|
16
|
-
const getConf = (configName: string) => {
|
|
14
|
+
export const getConf = (configName: string) => {
|
|
17
15
|
const configPath = path.join(__dirname, 'config', configName);
|
|
18
16
|
return parseConfigFile(configPath);
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
config.checkSecretKey('12345');
|
|
25
|
-
const storage = new Storage(config);
|
|
26
|
-
await storage.init(config, []);
|
|
27
|
-
const auth: IAuth = new Auth(config);
|
|
28
|
-
// for parsing the body (login api)
|
|
29
|
-
app.use(bodyParser.json({ strict: false, limit: '10mb' }));
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
app.use(errorReportingMiddleware);
|
|
32
|
-
app.use(routes(config, auth, storage));
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
app.use(handleError);
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
app.use(final);
|
|
37
|
-
return app;
|
|
19
|
+
// @deprecated
|
|
20
|
+
export async function initializeServer(configName): Promise<Application> {
|
|
21
|
+
return initializeServerHelper(getConf(configName), [apiMiddleware, routes], Storage);
|
|
38
22
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{
|
|
2
|
+
"objects": [
|
|
3
|
+
{
|
|
4
|
+
"package": {
|
|
5
|
+
"name": "verdaccio",
|
|
6
|
+
"scope": "unscoped",
|
|
7
|
+
"version": "5.1.2",
|
|
8
|
+
"description": "A lightweight private npm proxy registry",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"private",
|
|
11
|
+
"package",
|
|
12
|
+
"repository",
|
|
13
|
+
"registry",
|
|
14
|
+
"enterprise",
|
|
15
|
+
"modules",
|
|
16
|
+
"proxy",
|
|
17
|
+
"server",
|
|
18
|
+
"verdaccio"
|
|
19
|
+
],
|
|
20
|
+
"date": "2021-07-14T18:26:48.823Z",
|
|
21
|
+
"links": {
|
|
22
|
+
"npm": "https://www.npmjs.com/package/verdaccio",
|
|
23
|
+
"homepage": "https://verdaccio.org",
|
|
24
|
+
"repository": "https://github.com/verdaccio/verdaccio",
|
|
25
|
+
"bugs": "https://github.com/verdaccio/verdaccio/issues"
|
|
26
|
+
},
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "Verdaccio Maintainers",
|
|
29
|
+
"email": "verdaccio.npm@gmail.com",
|
|
30
|
+
"username": "verdaccio.npm"
|
|
31
|
+
},
|
|
32
|
+
"publisher": { "username": "verdaccio.npm", "email": "verdaccio.npm@gmail.com" },
|
|
33
|
+
"maintainers": [
|
|
34
|
+
{ "username": "jotadeveloper", "email": "juanpicado19@gmail.com" },
|
|
35
|
+
{ "username": "ayusharma", "email": "ayush.aceit@gmail.com" },
|
|
36
|
+
{ "username": "trentearl", "email": "trent@trentearl.com" },
|
|
37
|
+
{ "username": "jmwilkinson", "email": "J.Wilkinson@f5.com" },
|
|
38
|
+
{ "username": "sergiohgz", "email": "sergio@sergiohgz.eu" },
|
|
39
|
+
{ "username": "verdaccio.npm", "email": "verdaccio.npm@gmail.com" }
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"score": {
|
|
43
|
+
"final": 0.38839042352668346,
|
|
44
|
+
"detail": {
|
|
45
|
+
"quality": 0.6389690936404147,
|
|
46
|
+
"popularity": 0.22866579647969262,
|
|
47
|
+
"maintenance": 0.3333333333333333
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"searchScore": 100000.375
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"package": {
|
|
54
|
+
"name": "verdaccio-bitbucket",
|
|
55
|
+
"scope": "unscoped",
|
|
56
|
+
"version": "3.0.1",
|
|
57
|
+
"description": "Verdaccio module to authenticate users via Bitbucket",
|
|
58
|
+
"keywords": [
|
|
59
|
+
"sinopia",
|
|
60
|
+
"verdaccio",
|
|
61
|
+
"bitbucket",
|
|
62
|
+
"atlassian",
|
|
63
|
+
"auth",
|
|
64
|
+
"node",
|
|
65
|
+
"nodejs",
|
|
66
|
+
"js",
|
|
67
|
+
"javascript"
|
|
68
|
+
],
|
|
69
|
+
"date": "2020-11-17T18:31:50.893Z",
|
|
70
|
+
"links": { "npm": "https://www.npmjs.com/package/verdaccio-bitbucket" },
|
|
71
|
+
"author": {
|
|
72
|
+
"name": "Idan Gozlan",
|
|
73
|
+
"email": "idangozlan@gmail.com",
|
|
74
|
+
"username": "idangozlan"
|
|
75
|
+
},
|
|
76
|
+
"publisher": { "username": "idangozlan", "email": "idangozlan@gmail.com" },
|
|
77
|
+
"maintainers": [{ "username": "idangozlan", "email": "idangozlan@gmail.com" }]
|
|
78
|
+
},
|
|
79
|
+
"score": {
|
|
80
|
+
"final": 0.3676150990565089,
|
|
81
|
+
"detail": {
|
|
82
|
+
"quality": 0.9333033508158308,
|
|
83
|
+
"popularity": 0.005251300076726234,
|
|
84
|
+
"maintenance": 0.2451032536711585
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"searchScore": 0.00029462433
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"package": {
|
|
91
|
+
"name": "verdaccio-badger",
|
|
92
|
+
"scope": "unscoped",
|
|
93
|
+
"version": "1.0.0",
|
|
94
|
+
"description": "verdaccio middleware plugin to serve svg badges",
|
|
95
|
+
"keywords": ["verdaccio", "plugin", "middleware", "badge", "badges"],
|
|
96
|
+
"date": "2020-08-02T18:08:10.321Z",
|
|
97
|
+
"links": {
|
|
98
|
+
"npm": "https://www.npmjs.com/package/verdaccio-badger",
|
|
99
|
+
"homepage": "https://github.com/PaddeK/verdaccio-badger",
|
|
100
|
+
"repository": "https://github.com/PaddeK/verdaccio-badger",
|
|
101
|
+
"bugs": "https://github.com/PaddeK/verdaccio-badger/issues"
|
|
102
|
+
},
|
|
103
|
+
"author": { "name": "Patrick Klös", "email": "pkloes@web.de", "username": "paddek" },
|
|
104
|
+
"publisher": { "username": "paddek", "email": "pkloes@web.de" },
|
|
105
|
+
"maintainers": [{ "username": "paddek", "email": "pkloes@web.de" }]
|
|
106
|
+
},
|
|
107
|
+
"score": {
|
|
108
|
+
"final": 0.3595405976501428,
|
|
109
|
+
"detail": {
|
|
110
|
+
"quality": 0.920245406776651,
|
|
111
|
+
"popularity": 0.0027140305161327217,
|
|
112
|
+
"maintenance": 0.23576304267571743
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"searchScore": 0.00022687363
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"package": {
|
|
119
|
+
"name": "@verdaccio/streams",
|
|
120
|
+
"scope": "verdaccio",
|
|
121
|
+
"version": "10.0.0",
|
|
122
|
+
"description": "Stream extension for Verdaccio",
|
|
123
|
+
"keywords": ["verdaccio", "streams"],
|
|
124
|
+
"date": "2021-03-29T13:01:49.263Z",
|
|
125
|
+
"links": {
|
|
126
|
+
"npm": "https://www.npmjs.com/package/%40verdaccio%2Fstreams",
|
|
127
|
+
"homepage": "https://verdaccio.org",
|
|
128
|
+
"repository": "https://github.com/verdaccio/monorepo",
|
|
129
|
+
"bugs": "https://github.com/verdaccio/monorepo/issues"
|
|
130
|
+
},
|
|
131
|
+
"author": {
|
|
132
|
+
"name": "Juan Picado",
|
|
133
|
+
"email": "juanpicado19@gmail.com",
|
|
134
|
+
"username": "jotadeveloper"
|
|
135
|
+
},
|
|
136
|
+
"publisher": { "username": "verdaccio.npm", "email": "verdaccio.npm@gmail.com" },
|
|
137
|
+
"maintainers": [
|
|
138
|
+
{ "username": "sergiohgz", "email": "sergio@sergiohgz.eu" },
|
|
139
|
+
{ "username": "verdaccio.npm", "email": "verdaccio.npm@gmail.com" },
|
|
140
|
+
{ "username": "jotadeveloper", "email": "juanpicado19@gmail.com" },
|
|
141
|
+
{ "username": "ayusharma", "email": "ayush.aceit@gmail.com" }
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"score": {
|
|
145
|
+
"final": 0.34805712275547446,
|
|
146
|
+
"detail": {
|
|
147
|
+
"quality": 0.6324693223008875,
|
|
148
|
+
"popularity": 0.11950424927689082,
|
|
149
|
+
"maintenance": 0.3328281109094184
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"searchScore": 0.00015023774
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"total": 218,
|
|
156
|
+
"time": "Sun Jul 25 2021 14:11:11 GMT+0000 (Coordinated Universal Time)"
|
|
157
|
+
}
|
package/test/render.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSDOM } from 'jsdom';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import supertest from 'supertest';
|
|
3
4
|
|
|
@@ -28,34 +29,80 @@ describe('test web server', () => {
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
describe('render', () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
describe('output', () => {
|
|
33
|
+
const render = async (config = 'default-test.yaml') => {
|
|
34
|
+
const response = await supertest(await initializeServer(config))
|
|
35
|
+
.get('/')
|
|
36
|
+
.set('Accept', HEADERS.TEXT_HTML)
|
|
37
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
38
|
+
.expect(HTTP_STATUS.OK);
|
|
39
|
+
return new JSDOM(response.text, { runScripts: 'dangerously' });
|
|
40
|
+
};
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
test('should match render set ui properties', async () => {
|
|
43
|
+
const {
|
|
44
|
+
window: { __VERDACCIO_BASENAME_UI_OPTIONS },
|
|
45
|
+
} = await render('web.yaml');
|
|
46
|
+
expect(__VERDACCIO_BASENAME_UI_OPTIONS).toEqual(
|
|
47
|
+
expect.objectContaining({
|
|
48
|
+
showInfo: true,
|
|
49
|
+
showSettings: true,
|
|
50
|
+
showThemeSwitch: true,
|
|
51
|
+
showFooter: true,
|
|
52
|
+
showSearch: true,
|
|
53
|
+
showDownloadTarball: true,
|
|
54
|
+
darkMode: false,
|
|
55
|
+
url_prefix: '/prefix',
|
|
56
|
+
basename: '/prefix/',
|
|
57
|
+
primaryColor: '#ffffff',
|
|
58
|
+
// FIXME: mock these values, avoid random
|
|
59
|
+
// base: 'http://127.0.0.1:60864/prefix/',
|
|
60
|
+
// version: '6.0.0-6-next.28',
|
|
61
|
+
logoURI: '',
|
|
62
|
+
flags: { searchRemote: true },
|
|
63
|
+
login: true,
|
|
64
|
+
pkgManagers: ['pnpm', 'yarn'],
|
|
65
|
+
title: 'verdaccio web',
|
|
66
|
+
scope: '@scope',
|
|
67
|
+
language: 'es-US',
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
});
|
|
46
71
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.get('/-/static/not-found.js')
|
|
50
|
-
.set('Accept', HEADERS.TEXT_HTML)
|
|
51
|
-
.expect(HTTP_STATUS.NOT_FOUND);
|
|
72
|
+
test.todo('test default title');
|
|
73
|
+
test.todo('test need html cache');
|
|
52
74
|
});
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
describe('status', () => {
|
|
77
|
+
test('should return the http status 200 for root', async () => {
|
|
78
|
+
return supertest(await initializeServer('default-test.yaml'))
|
|
79
|
+
.get('/')
|
|
80
|
+
.set('Accept', HEADERS.TEXT_HTML)
|
|
81
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
82
|
+
.expect(HTTP_STATUS.OK);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should return the body for a package detail page', async () => {
|
|
86
|
+
return supertest(await initializeServer('default-test.yaml'))
|
|
87
|
+
.get('/-/web/section/some-package')
|
|
88
|
+
.set('Accept', HEADERS.TEXT_HTML)
|
|
89
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
90
|
+
.expect(HTTP_STATUS.OK);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('should static file not found', async () => {
|
|
94
|
+
return supertest(await initializeServer('default-test.yaml'))
|
|
95
|
+
.get('/-/static/not-found.js')
|
|
96
|
+
.set('Accept', HEADERS.TEXT_HTML)
|
|
97
|
+
.expect(HTTP_STATUS.NOT_FOUND);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('should static file found', async () => {
|
|
101
|
+
return supertest(await initializeServer('default-test.yaml'))
|
|
102
|
+
.get('/-/static/main.js')
|
|
103
|
+
.set('Accept', HEADERS.TEXT_HTML)
|
|
104
|
+
.expect(HTTP_STATUS.OK);
|
|
105
|
+
});
|
|
59
106
|
});
|
|
60
107
|
});
|
|
61
108
|
});
|
package/test/utils.spec.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
-
import { parseReadme } from '../src/utils/web-utils';
|
|
4
|
+
import { parseReadme, validatePrimaryColor } from '../src/utils/web-utils';
|
|
5
5
|
|
|
6
6
|
const readmeFile = (fileName = 'markdown.md') => {
|
|
7
7
|
return fs.readFileSync(path.join(__dirname, `./partials/readme/${fileName}`));
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
describe('Utilities', () => {
|
|
11
|
+
describe('validatePrimaryColor', () => {
|
|
12
|
+
test('is valid', () => {
|
|
13
|
+
expect(validatePrimaryColor('#222222')).toEqual('#222222');
|
|
14
|
+
expect(validatePrimaryColor('#222fff')).toEqual('#222fff');
|
|
15
|
+
});
|
|
16
|
+
test('is invalid', () => {
|
|
17
|
+
expect(validatePrimaryColor('fff')).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
11
20
|
describe('parseReadme', () => {
|
|
12
21
|
test('should parse makrdown text to html template', () => {
|
|
13
22
|
const markdown = '# markdown';
|
package/tsconfig.json
CHANGED