From 5b77d49fc5a5b85368e464e8cfa52f96bc42c8cd Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Fri, 10 Feb 2017 09:47:03 +0100 Subject: [PATCH] Fix #38: Avoid running tests of an abstract class --- src/testCase.js | 4 ++-- test/src/abstractTestCaseSpec.js | 28 ++++++++++++++++++++++++++++ test/tests.js | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/src/abstractTestCaseSpec.js diff --git a/src/testCase.js b/src/testCase.js index 90e8d79..5e02eb1 100644 --- a/src/testCase.js +++ b/src/testCase.js @@ -86,8 +86,8 @@ define([ // All test classes are singletons. // TODO: Refactor with a super call when we"ll have super on class-side. - that.subclass = (function(superSubclass, options) { - return function(builder) { + that.subclass = (function(superSubclass) { + return function(builder, options) { var klass = superSubclass.apply(that, [builder]); if (options && options.isAbstract) { diff --git a/test/src/abstractTestCaseSpec.js b/test/src/abstractTestCaseSpec.js new file mode 100644 index 0000000..4072876 --- /dev/null +++ b/test/src/abstractTestCaseSpec.js @@ -0,0 +1,28 @@ +define([ + "src/testCase" +], function(testCase) { + + var a = testCase.abstractSubclass(function(that, my) { + + my.name = function() { + return "Abstract test case"; + }; + + my.createObject = function() { + return "a"; + }; + + my.shouldNotExecuteTestsTest = function() { + expect(my.createObject()).toBe("b"); + }; + }); + + var b = a.subclass(function(that, my) { + + my.createObject = function() { + return "b"; + }; + }); + + return b; +}); diff --git a/test/tests.js b/test/tests.js index c8abbef..c209263 100644 --- a/test/tests.js +++ b/test/tests.js @@ -12,6 +12,7 @@ define([], function() { "test/src/getterSetterSpec", "test/src/singletonSpec", "test/src/testCaseSpec", + "test/src/abstractTestCaseSpec", "test/src/propertyListenersSpec" ]; return {