Maison >interface Web >js tutoriel >kmock javascript 单元测试代码_javascript技巧
/// <reference path="Flight.js"></reference> <br>/// <reference path="http://demo.jb51.net/jslib/qunit/qunit.js"></reference> <br>/// <reference path="KMock.js"></reference> <br><br><br>module("enter coin"); <br><br>test("enter coin while game has not yet start", function () { <br>var flight = new KFlight(); <br><br>var mock = new KMock(); <br>mock.setup("draw").returnAs(function () { <br>}); <br><br>flight.draw = mock.draw.invoke; <br><br><br>equal(flight.coinNum, 0); <br>equal(flight.gameState, 0); <br>flight.coinEnter(); <br>equal(flight.coinNum, 0); <br>equal(flight.gameState, 1); <br><br><br>equal(mock.draw.isVerify(1), true); <br><br>});<br>