Created
May 20, 2012 01:57
-
-
Save ryuone/2733252 to your computer and use it in GitHub Desktop.
jsTestDriverのサンプルコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server: http://localhost:4224 | |
| load: | |
| - lib/*.js | |
| - src/*.js | |
| - test/*.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.twin = function twin(){ | |
| return this + this; | |
| }; | |
| String.prototype.triple = function twin(){ | |
| return this + this + this; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TestCase("twin_test", { | |
| setUp: function(){ | |
| this.str = "hoge"; | |
| sinon.spy(String.prototype, "twin"); | |
| }, | |
| tearDown: function(){ | |
| delete this.str; | |
| String.prototype.twin.restore(); | |
| }, | |
| "test String.prototype.twin should double the value": function(){ | |
| var result = this.str.twin(); | |
| assertString(result); | |
| assert(String.prototype.twin.calledOnce); | |
| assertEquals("hogehoge", result); | |
| }, | |
| "test twin callonce" : function(){ | |
| var result = this.str.twin(); | |
| assert("called once.", String.prototype.twin.calledOnce); | |
| } | |
| }); | |
| TestCase("triple_test", { | |
| setUp: function(){ | |
| this.str = "hoge"; | |
| }, | |
| tearDown: function(){ | |
| delete this.str; | |
| }, | |
| "test String.prototype.double should double the value": function(){ | |
| var result = this.str.triple(); | |
| assertString(result); | |
| assertEquals("hogehogehoge", result); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment