-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for default import export and variable default export
- Loading branch information
1 parent
977019a
commit 8b45998
Showing
4 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function () { | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import fnDefaultExport from "./fn-default-export.mjs"; | ||
export default fnDefaultExport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const temp = function () { | ||
return 1 | ||
} | ||
|
||
export default temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Hook from '../../index.js' | ||
import defaultImportExport from '../fixtures/import-default-export.mjs' | ||
import varDefaultExport from '../fixtures/variable-default-export.mjs' | ||
import { strictEqual } from 'assert' | ||
|
||
Hook((exports, name) => { | ||
if (name.match(/import-default-export\.m?js/)) { | ||
const orig = exports.default | ||
exports.default = function () { | ||
return orig() + 1 | ||
} | ||
} else if (name.match(/variable-default-export\.m?js/)) { | ||
const orig2 = exports.default | ||
exports.default = function () { | ||
return orig2() + 1 | ||
} | ||
} | ||
}) | ||
|
||
strictEqual(defaultImportExport(), 2) | ||
strictEqual(varDefaultExport(), 2) |