Skip to content

Commit 9a1415c

Browse files
committed
test: basic create cert test
1 parent 03eee6e commit 9a1415c

File tree

4 files changed

+9
-164
lines changed

4 files changed

+9
-164
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"minimist": "^1.2.6",
5151
"picocolors": "^1.0.0",
5252
"prettier": "^2.7.1",
53-
"puppeteer": "^14.4.0",
5453
"rollup": "^2.75.6",
5554
"semver": "^7.3.7",
5655
"slash": "^3.0.0",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function viteBasicSslPlugin(): Plugin {
2121
}
2222
}
2323

24-
async function getCertificate(cacheDir: string) {
24+
export async function getCertificate(cacheDir: string) {
2525
console.log(cacheDir)
2626
const cachePath = path.join(cacheDir, '_cert.pem')
2727

test/test.spec.ts

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,8 @@
1-
import type puppeteer from 'puppeteer'
2-
import { beforeAll, afterAll, describe, test, expect } from 'vitest'
3-
import {
4-
expectByPolling,
5-
getComputedColor,
6-
getEl,
7-
getText,
8-
killServer,
9-
postTest,
10-
preTest,
11-
startServer,
12-
updateFile
13-
} from './util'
14-
15-
beforeAll(async () => {
16-
await preTest()
17-
})
18-
19-
afterAll(postTest)
20-
21-
describe('vite-plugin-basic-ssl', () => {
22-
describe('dev', () => {
23-
declareTests(false)
24-
})
25-
26-
describe('build', () => {
27-
declareTests(true)
28-
})
29-
})
30-
31-
export function declareTests(isBuild: boolean) {
32-
let page: puppeteer.Page = undefined!
33-
34-
beforeAll(async () => {
35-
page = await startServer(isBuild)
36-
})
37-
38-
afterAll(async () => {
39-
await killServer()
40-
})
41-
42-
test('smoke dev test', async () => {
43-
const el = await page.$('.script-setup')
44-
expect(el).not.toBeNull()
45-
})
46-
}
1+
import { test, expect } from 'vitest'
2+
import { createCertificate } from '../src/certificate'
3+
4+
test('create certificate', () => {
5+
const content = createCertificate()
6+
expect(content).toMatch(/-----BEGIN RSA PRIVATE KEY-----(\n|\r|.)*-----END RSA PRIVATE KEY-----/)
7+
expect(content).toMatch(/-----BEGIN CERTIFICATE-----(\n|\r|.)*-----END CERTIFICATE-----/)
8+
})

test/util.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)