Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed May 31, 2024
1 parent 1906b5a commit 9826a7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion playground/spa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig(() => ({
plugins: [
react(),
publicTypescript({
outputDir: '/out',
outputDir: 'out',
destination: 'memory',
babel: true,
}),
Expand Down
22 changes: 9 additions & 13 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,29 @@ import { eq, extractHashFromFileName, getContentHash, isPublicTypescript, linebr

describe('unit test', () => {
test('should return true when filePath is a public typescript file', () => {
const filePath = 'src/foo/bar.ts'
const root = 'src'
const inputDir = 'foo'
expect(isPublicTypescript({ filePath, inputDir, root })).toBe(true)
const filePath = '/src/foo/bar.ts'
const inputDir = '/src/foo'
expect(isPublicTypescript({ filePath, inputDir })).toBe(true)
})

test('should return false when filePath is not a public typescript file', () => {
const filePath = 'src/foo/bar.js'
const root = 'src'
const inputDir = 'foo'
expect(isPublicTypescript({ filePath, inputDir, root })).toBe(false)
const filePath = '/src/foo/bar.js'
const inputDir = '/src/foo'
expect(isPublicTypescript({ filePath, inputDir })).toBe(false)
})

test('should be typescript file', () => {
const root = process.cwd()
const tsFile = 'hello.ts'
const otherFile = 'hello.js'
const res1 = isPublicTypescript({
filePath: path.resolve(root, `public-typescript/${tsFile}`),
inputDir: 'public-typescript',
root,
filePath: path.join(root, `public-typescript/${tsFile}`),
inputDir: path.join(root, 'public-typescript'),
})

const res2 = isPublicTypescript({
filePath: path.resolve(root, `public-typescript/${otherFile}`),
inputDir: 'public-typescript',
root,
inputDir: path.join(root, 'public-typescript'),
})

expect(res1).toBe(true)
Expand Down

0 comments on commit 9826a7a

Please sign in to comment.