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:
authorJohannes <johannes.ewald@roomieplanet.de>2012-07-10 22:32:54 +0400
committerJohannes <johannes.ewald@roomieplanet.de>2012-07-10 22:32:54 +0400
commit0bb70adf091ce5ccf8c81f28cc72a229ac15eba1 (patch)
tree61ef88ea9646dd734533e295d7002653c311508e /test/__get__.test.js
parentb443c61ab73679410f083e383be7aef3039d228f (diff)
- fixed parsing error when trying to set a function as mockv0.3.2
- update to mocha 1.3.x - fixed minor IE issues
Diffstat (limited to 'test/__get__.test.js')
-rw-r--r--test/__get__.test.js156
1 files changed, 78 insertions, 78 deletions
diff --git a/test/__get__.test.js b/test/__get__.test.js
index 7c40bdb..8f060f7 100644
--- a/test/__get__.test.js
+++ b/test/__get__.test.js
@@ -1,79 +1,79 @@
-var expect = require("expect.js"),
- vm = require("vm"),
- __get__ = require("../lib/__get__.js"),
-
- expectReferenceError = expectError(ReferenceError),
- expectTypeError = expectError(TypeError);
-
-function expectError(ErrConstructor) {
- return function expectReferenceError(err) {
- expect(err.constructor.name === ErrConstructor.name).to.be(true);
- };
-}
-
-
-describe("__get__", function () {
- var moduleFake;
-
- beforeEach(function () {
- moduleFake = {
- __filename: "some/file.js",
- myNumber: 0,
- myObj: {}
- };
-
- vm.runInNewContext(
- "__get__ = " + __get__.toString() + "; " +
- "setNumber = function (value) { myNumber = value; }; " +
- "setObj = function (value) { myObj = value; }; ",
- moduleFake,
- __filename
- );
- });
- it("should return the initial value", function () {
- expect(moduleFake.__get__("myNumber") === 0).to.be(true);
- expect(moduleFake.__get__("myObj")).to.eql({});
- });
- it("should return the changed value of the number", function () {
- var newObj = { hello: "hello" };
-
- moduleFake.setNumber(2);
- moduleFake.setObj(newObj);
- expect(moduleFake.__get__("myNumber") === 2).to.be(true);
- expect(moduleFake.__get__("myObj") === newObj).to.be(true);
- });
- it("should throw a ReferenceError when getting not existing vars", function () {
- expect(function () {
- moduleFake.__get__("blabla");
- }).to.throwException(expectReferenceError);
- });
- it("should throw a TypeError when passing misfitting params", function () {
- expect(function () {
- moduleFake.__get__();
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__(undefined);
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__(null);
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__(true);
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__(2);
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__("");
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__([]);
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__({});
- }).to.throwException(expectTypeError);
- expect(function () {
- moduleFake.__get__(function () {});
- }).to.throwException(expectTypeError);
- });
+var expect = require("expect.js"),
+ vm = require("vm"),
+ __get__ = require("../lib/__get__.js"),
+
+ expectReferenceError = expectError(ReferenceError),
+ expectTypeError = expectError(TypeError);
+
+function expectError(ErrConstructor) {
+ return function expectReferenceError(err) {
+ expect(err.constructor.name).to.be(ErrConstructor.name);
+ };
+}
+
+
+describe("__get__", function () {
+ var moduleFake;
+
+ beforeEach(function () {
+ moduleFake = {
+ __filename: "some/file.js",
+ myNumber: 0,
+ myObj: {}
+ };
+
+ vm.runInNewContext(
+ "__get__ = " + __get__.toString() + "; " +
+ "setNumber = function (value) { myNumber = value; }; " +
+ "setObj = function (value) { myObj = value; }; ",
+ moduleFake,
+ __filename
+ );
+ });
+ it("should return the initial value", function () {
+ expect(moduleFake.__get__("myNumber")).to.be(0);
+ expect(moduleFake.__get__("myObj")).to.eql({});
+ });
+ it("should return the changed value of the number", function () {
+ var newObj = { hello: "hello" };
+
+ moduleFake.setNumber(2);
+ moduleFake.setObj(newObj);
+ expect(moduleFake.__get__("myNumber")).to.be(2);
+ expect(moduleFake.__get__("myObj")).to.be(newObj);
+ });
+ it("should throw a ReferenceError when getting not existing vars", function () {
+ expect(function () {
+ moduleFake.__get__("blabla");
+ }).to.throwException(expectReferenceError);
+ });
+ it("should throw a TypeError when passing misfitting params", function () {
+ expect(function () {
+ moduleFake.__get__();
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__(undefined);
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__(null);
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__(true);
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__(2);
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__("");
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__([]);
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__({});
+ }).to.throwException(expectTypeError);
+ expect(function () {
+ moduleFake.__get__(function () {});
+ }).to.throwException(expectTypeError);
+ });
}); \ No newline at end of file