Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Feb 21, 2020
1 parent 2093308 commit 32fa4f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/fixtures/bar.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {basename} from 'path'

export const filename = basename(import.meta.url)
3 changes: 3 additions & 0 deletions tests/fixtures/foo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {basename} from 'path'

export const filename = basename(import.meta.url)
13 changes: 11 additions & 2 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ function testLoad() {
})
importEsm('./fixtures/commonjs-package/index.mjs').then(function(module) {
equal(module.packageName, 'commonjs-package')
})
}, throwNotFoundModuleError)
importEsm('./fixtures/module-package/index.mjs').then(function(module) {
equal(module.packageName, 'module-package')
})
}, throwNotFoundModuleError)
require('./fixtures/import-from-directory').then(function(module) {
equal(module.filename, 'bar.mjs')
}, throwNotFoundModuleError)
importEsm('./fixtures/non-exists-file.mjs').then(null, function(error) {
equal(/Cannot find module/.test(error.message), true)
})
} else {
promise.then(null, function(error) {
Expand All @@ -99,6 +102,12 @@ function testLoad() {
}
}

function throwNotFoundModuleError(error) {
console.log('Should find module')
console.error(error)
process.exit(1)
}

equal(typeof importEsm, 'function')
equal(typeof importEsm.check, 'function')
equal(typeof importEsm.checkSync, 'function')
Expand Down

0 comments on commit 32fa4f8

Please sign in to comment.