-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugin-define): add unit test of "should replace only in option's…
… own property"
- Loading branch information
Showing
3 changed files
with
37 additions
and
24 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
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 |
---|---|---|
@@ -1,27 +1,40 @@ | ||
<script lang="js"> | ||
function definedVariable () { | ||
let BASE_URL = 'http://www.foo.com'; | ||
return BASE_URL; | ||
} | ||
function definedVariable() { | ||
let BASE_URL = 'http://www.foo.com'; | ||
return BASE_URL; | ||
} | ||
|
||
const inObjectProperty = { | ||
BASE_URL: 'http://foo.com' | ||
}; | ||
const inString = 'BASE_URL'; | ||
const inObjectProperty = { | ||
BASE_URL: 'http://foo.com' | ||
}; | ||
const inString = 'BASE_URL'; | ||
|
||
function useBuiltinFunc() { | ||
let obj = {}; | ||
let b = 1; | ||
|
||
module.exports = { | ||
definedVariable: definedVariable(), | ||
inObjectProperty, | ||
inString, | ||
inTemplateLiterals: `${BASE_URL}/api/`, | ||
__defineSetter__.call(obj, 'a', function (val) { | ||
b = val; | ||
}); | ||
obj.a = 666; | ||
|
||
shouldReplaced: BASE_URL, | ||
return b; | ||
} | ||
|
||
objectTest: process.env.NODE_ENV, | ||
module.exports = { | ||
definedVariable: definedVariable(), | ||
inObjectProperty, | ||
inString, | ||
inTemplateLiterals: `${BASE_URL}/api/`, | ||
|
||
typeofTest: typeof window, | ||
typeofTest2: typeof(window) | ||
} | ||
shouldReplaced: BASE_URL, | ||
|
||
objectTest: process.env.NODE_ENV, | ||
|
||
typeofTest: typeof window, | ||
typeofTest2: typeof (window), | ||
|
||
builtinFuncValue: useBuiltinFunc() | ||
}; | ||
|
||
</script> |
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