-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: chenqun1 <[email protected]>
- Loading branch information
1 parent
c1480a7
commit fd6f58e
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
rootDir: path.resolve(__dirname, './'), | ||
transform: { | ||
'^.+\\.[t|j]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ViteCertPlugin from '../index' | ||
import Mkcert from '../mkcert/index' | ||
|
||
|
||
const install = jest.fn() | ||
|
||
jest.mock('../mkcert/index', () => { | ||
return class { | ||
static create() { | ||
return new this() | ||
} | ||
install(...args: any[]) { | ||
install(...args) | ||
} | ||
public async init() {} | ||
} | ||
}) | ||
|
||
describe('custom hostnames', () => { | ||
test('should install with custom hostnames', async () => { | ||
|
||
const plugin = ViteCertPlugin({ | ||
hostnames: ['www.test.com'] | ||
}) | ||
|
||
await (plugin as any).config({ | ||
server: { | ||
https: true | ||
} | ||
}) | ||
|
||
expect(install).toHaveBeenCalledTimes(1) | ||
|
||
const args = install.mock.calls[0][0] | ||
expect(JSON.stringify(args)).toMatch('www.test.com') | ||
// expect((args as string[]).includes('www.test.com')).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters