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:
authorjeroenvalcke <valcke_jeroen@hotmail.com>2017-11-15 20:23:21 +0300
committerjeroenvalcke <valcke_jeroen@hotmail.com>2017-11-15 20:23:21 +0300
commit35d43982c8f11717761562fcc29b087b2dbd89f9 (patch)
tree5b534a46156853b811b18a0259436ecb47908b50
parent0a77533c6b7a41606975303be2327c250cd77d19 (diff)
Add class tests
-rw-r--r--testLib/ClassA.js12
-rw-r--r--testLib/ClassB.js13
-rw-r--r--testLib/sharedTestCases.js13
3 files changed, 38 insertions, 0 deletions
diff --git a/testLib/ClassA.js b/testLib/ClassA.js
new file mode 100644
index 0000000..8aec279
--- /dev/null
+++ b/testLib/ClassA.js
@@ -0,0 +1,12 @@
+class A {
+ get prop1() {
+ return "A"
+ }
+ get prop2() {
+ return "something"
+ }
+
+ method2() { return "testA"; }
+}
+
+module.exports = A;
diff --git a/testLib/ClassB.js b/testLib/ClassB.js
new file mode 100644
index 0000000..625abfb
--- /dev/null
+++ b/testLib/ClassB.js
@@ -0,0 +1,13 @@
+const AClass = require("./ClassA");
+
+class ClassB extends AClass {
+ get prop1() {
+ return "B";
+ }
+
+ method1() {
+ return "testB";
+ }
+}
+
+module.exports = ClassB;
diff --git a/testLib/sharedTestCases.js b/testLib/sharedTestCases.js
index b6caf6a..941b971 100644
--- a/testLib/sharedTestCases.js
+++ b/testLib/sharedTestCases.js
@@ -390,4 +390,17 @@ module.exports = function () {
expect(constModule.dirname).to.equal(require("./constModule").dirname);
});
+ it("should be possible to create a class", function() {
+ var BClass = rewire("./ClassB");
+
+ expect(function() {
+ new BClass();
+ }).to.not.throw;
+
+ var b = new BClass();
+
+ expect(b.prop1).to.equal("B");
+ expect(b.prop2).to.equal("something")
+ });
+
};