【发布时间】:2015-02-15 02:37:30
【问题描述】:
我有一个非 AMD JavaScript 文件,其类 Snake 如下所示:
// ./www/js/Snake.js
function Snake(initPos) {
this.pos = initPos;
}
// I want to unit test this method.
Snake.proptotype.move = function(dir) {
// Do things.
};
我写了一个实习生模块来测试它:
// ./test/Snake.js
define([
'intern!object',
'intern/chai!assert',
"../www/js/Snake"
], function (registerSuite, assert, Snake) {
registerSuite({
name: 'Snake',
move: function () {
// Intern complains that this object is not a function.
var snake = new Snake([
{x: 0, y: 0},
{x: 1, y: 0},
{x: 2, y: 0}
]);
snake.move("right");
...
如何让 Intern 识别 Snake 类?
【问题讨论】:
标签: intern