Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/testModules/moduleA.js')
-rw-r--r--test/testModules/moduleA.js62
1 files changed, 54 insertions, 8 deletions
diff --git a/test/testModules/moduleA.js b/test/testModules/moduleA.js
index 6e655ab..1e14071 100644
--- a/test/testModules/moduleA.js
+++ b/test/testModules/moduleA.js
@@ -28,21 +28,67 @@ function readFileSync() {
}
function checkSomeGlobals() {
- if (typeof global === "undefined") {
- throw new ReferenceError("global is undefined");
+ if (typeof global !== "object") {
+ throw new ReferenceError("global is not an object");
}
- if (typeof console === "undefined") {
- throw new ReferenceError("console is undefined");
+ if (typeof console !== "object") {
+ throw new ReferenceError("console is not an object");
}
- if (typeof __filename === "undefined") {
- throw new ReferenceError("__filename is undefined");
+ if (typeof require !== "function") {
+ throw new ReferenceError("require is not a function");
}
- if (typeof __dirname === "undefined") {
- throw new ReferenceError("__dirname is undefined");
+ if (typeof module !== "object") {
+ throw new ReferenceError("module is not an object");
}
+ if (typeof exports !== "object") {
+ throw new ReferenceError("exports is not an object");
+ }
+ if (module.exports !== exports) {
+ throw new Error("module.exports === exports returns false");
+ }
+ if (typeof __dirname !== "string") {
+ throw new ReferenceError("__dirname is not a string");
+ }
+ if (typeof __filename !== "string") {
+ throw new ReferenceError("__filename is not a string");
+ }
+ //TODO add accurate checks here
if (typeof setTimeout === "undefined") {
throw new ReferenceError("setTimeout is undefined");
}
+ if (typeof clearTimeout === "undefined") {
+ throw new ReferenceError("clearTimeout is undefined");
+ }
+ if (typeof setInterval === "undefined") {
+ throw new ReferenceError("setInterval is undefined");
+ }
+ if (typeof clearInterval === "undefined") {
+ throw new ReferenceError("clearInterval is undefined");
+ }
+ if (typeof Error === "undefined") {
+ throw new ReferenceError("Error is undefined");
+ }
+ if (typeof parseFloat === "undefined") {
+ throw new ReferenceError("parseFloat is undefined");
+ }
+ if (typeof parseInt === "undefined") {
+ throw new ReferenceError("parseInt is undefined");
+ }
+ if (typeof window === "undefined") {
+ if (typeof process === "undefined") {
+ throw new ReferenceError("process is undefined");
+ }
+ if (typeof Buffer === "undefined") {
+ throw new ReferenceError("Buffer is undefined");
+ }
+ } else {
+ if (typeof encodeURIComponent === "undefined") {
+ throw new ReferenceError("encodeURIComponent is undefined");
+ }
+ if (typeof decodeURIComponent === "undefined") {
+ throw new ReferenceError("decodeURIComponent is undefined");
+ }
+ }
}
function getConsole() {