I have a non AMD JavaScript file with a class Snake like so:
// ./www/js/Snake.js
function Snake(initPos) {
this.pos = initPos;
}
// I want to unit test this method.
Snake.proptotype.move = function(dir) {
// Do things.
};
I wrote an Intern module to test it:
// ./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");
...
How to make Intern recognize the Snake class?