Skip to content

Commit

Permalink
Merge pull request #23 from chengpeiquan/develop
Browse files Browse the repository at this point in the history
test: add test case
  • Loading branch information
chengpeiquan authored Oct 31, 2022
2 parents ca7e360 + 0c22456 commit 7841a41
Show file tree
Hide file tree
Showing 2 changed files with 642 additions and 833 deletions.
31 changes: 20 additions & 11 deletions test/formatConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import formatConfig from '../src/libs/formatConfig'

function callback(fileName: string) {
return fileName.endsWith('.js')
? 'This message will inject into `js` files.'
: 'This message will inject into other files.'
}

describe('formatConfig.ts', () => {
test('Illegal options type', () => {
expect(() => {
Expand Down Expand Up @@ -38,18 +44,21 @@ describe('formatConfig.ts', () => {
})

describe('formatConfig.ts', () => {
test('Illegal options type', () => {
function callback(fileName: string) {
return fileName.endsWith('.js')
? 'This message will inject into `js` files.'
: 'This message will inject into other files.'
}
test('Functional content', () => {
expect(formatConfig(callback)).toStrictEqual({
content: callback,
outDir: 'dist',
debug: false,
verify: true,
})
})
})

expect(() => {
formatConfig(callback)
}).toStrictEqual({
content: expect.any(Function),
outDir: '',
describe('formatConfig.ts', () => {
test('The `content` option use `function` type', () => {
expect(formatConfig(callback)).toStrictEqual({
content: callback,
outDir: 'dist',
debug: false,
verify: true,
})
Expand Down
Loading

0 comments on commit 7841a41

Please sign in to comment.