Skip to content

Commit b55da03

Browse files
committed
fix:fix test case
1 parent a1aa672 commit b55da03

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/create.spec.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { template } from '#resources/template/template.js'
66

77
vi.mock('fs/promises', () => {
88
return {
9-
writeFile: vi.fn(),
9+
writeFile: vi.fn()
1010
}
1111
})
1212
const funRegex = /var\s+(\w+)\s*=\s*function\s*\(([^)]*)\)\s*{\s*([^}]*)\s*}/
13-
const isContainJsCode = input => funRegex.test(input)
14-
const isContainTestCase = input => input.includes('showLogs(')
13+
const isContainJsCode = (input) => funRegex.test(input)
14+
const isContainTestCase = (input) => input.includes('showLogs(')
1515

1616
function handleText(input) {
1717
return input.replace(/\n+/g, '\n').replaceAll('\n', '\n * ')
@@ -20,7 +20,7 @@ const mockKeys = ['id', 'slug', 'title', 'detail', 'lang', 'code', 'date']
2020
const oneDay = 24 * 60 * 60 * 1000
2121

2222
function isValidQuestion(res) {
23-
const content = generateTemplateContent(fileContent, res)
23+
const content = generateTemplateContent(res)
2424
// 是否含有函数
2525
expect(isContainJsCode(content)).toBeTruthy()
2626
// 是否含有测试用例
@@ -41,8 +41,6 @@ describe('lc', () => {
4141

4242
it('是否正确获取了今天的题目', () => {
4343
expect(Object.keys(res)).toEqual(mockKeys)
44-
// 比较日期是否相等
45-
// expect(Math.trunc(new Date(res.date).valueOf()/oneDay)).toEqual(Math.trunc(new Date().valueOf()/oneDay));
4644
})
4745
it('是否正确的填充了今天的题目', async () => {
4846
isValidQuestion(res)

0 commit comments

Comments
 (0)