Skip to content

Instantly share code, notes, and snippets.

@ryuone
Created May 20, 2012 01:57
Show Gist options
  • Select an option

  • Save ryuone/2733252 to your computer and use it in GitHub Desktop.

Select an option

Save ryuone/2733252 to your computer and use it in GitHub Desktop.
jsTestDriverのサンプルコード
server: http://localhost:4224
load:
- lib/*.js
- src/*.js
- test/*.js
String.prototype.twin = function twin(){
return this + this;
};
String.prototype.triple = function twin(){
return this + this + this;
};
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