Refactoring of method and correct the output
Showing
1 changed file
with
6 additions
and
4 deletions
... | @@ -849,13 +849,15 @@ Tester.prototype.assertType = function assertType(subject, type, message) { | ... | @@ -849,13 +849,15 @@ Tester.prototype.assertType = function assertType(subject, type, message) { |
849 | */ | 849 | */ |
850 | Tester.prototype.assertInstanceOf = function assertInstanceOf(subject, constructor, message) { | 850 | Tester.prototype.assertInstanceOf = function assertInstanceOf(subject, constructor, message) { |
851 | "use strict"; | 851 | "use strict"; |
852 | var actual = subject instanceof constructor; | 852 | if (utils.betterTypeOf(constructor) !== "function") { |
853 | return this.assert(utils.equals(actual, true), message, { | 853 | throw new CasperError('Invalid constructor.'); |
854 | } | ||
855 | return this.assert(subject instanceof constructor, message, { | ||
854 | type: "assertInstanceOf", | 856 | type: "assertInstanceOf", |
855 | standard: f('Subject is an instance of: "%s"', constructor), | 857 | standard: f('Subject is an instance of: "%s"', constructor.name), |
856 | values: { | 858 | values: { |
857 | subject: subject, | 859 | subject: subject, |
858 | constructor: constructor, | 860 | constructor: constructor.name, |
859 | actual: actual | 861 | actual: actual |
860 | } | 862 | } |
861 | }); | 863 | }); | ... | ... |
-
Please register or sign in to post a comment