Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi committed Nov 18, 2023
1 parent dc8816b commit 1503cef
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# NPM
node_modules/
package-lock.json
node_modules
dist

# Output
dist/
out/

# Misc
.DS_Store
*.log
.yalc
yalc.lock
test/**/*.js.map
.DS_Store
test/**/*.js.map
34 changes: 34 additions & 0 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,40 @@ const testCases: {
}
},
},
{
name: 'bin/nested-path',
args: [],
async expected(dir) {
const distFiles = [
join(dir, './dist/a/b/c.js'),
join(dir, './dist/a/b/c/d.js'),
]

for (const distFile of distFiles) {
expect(await fs.readFile(distFile, 'utf-8')).toContain(
'#!/usr/bin/env node',
)
}
},
},
{
name: 'bin/cts',
args: [],
async expected(dir) {
const distFiles = [
join(dir, './dist/bin.cjs'),
join(dir, './dist/bin.d.cts'),
]

for (const distFile of distFiles) {
expect(await existsFile(distFile)).toBe(true)
}

expect(await fs.readFile(distFiles[0], 'utf-8')).toContain(
'#!/usr/bin/env node',
)
},
},
]

async function runBundle(
Expand Down
3 changes: 3 additions & 0 deletions test/integration/bin/cts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bin": "./dist/bin.cjs"
}
3 changes: 3 additions & 0 deletions test/integration/bin/cts/src/bin.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
const path = require('path')
console.log(path.basename(__filename))
1 change: 1 addition & 0 deletions test/integration/bin/cts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 0 additions & 2 deletions test/integration/bin/multi-outdir/.gitignore

This file was deleted.

6 changes: 6 additions & 0 deletions test/integration/bin/nested-path/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bin": {
"c": "./dist/a/b/c.js",
"d": "./dist/a/b/c/d.js"
}
}
2 changes: 2 additions & 0 deletions test/integration/bin/nested-path/src/a/b/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
console.log('c')
2 changes: 2 additions & 0 deletions test/integration/bin/nested-path/src/a/b/c/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
console.log('d')

0 comments on commit 1503cef

Please sign in to comment.