mojio-js-sdk
Version:
Mojio javascript REST client.
269 lines (209 loc) • 6.97 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var Module, should,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
should = require('should');
Module = require('../../template/helpers/Module');
describe('Test Module', function() {
it('Module can extend from object', function() {
var Guitar, classProperties;
classProperties = {
tuning: function() {
return true;
}
};
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
return Guitar.__super__.constructor.apply(this, arguments);
}
Guitar.extend(classProperties);
return Guitar;
})(Module);
return Guitar.tuning().should.be["true"];
});
it('Module can include from object', function() {
var Guitar, guitar, instanceProperties;
instanceProperties = {
makeSound: function() {
return true;
}
};
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
return Guitar.__super__.constructor.apply(this, arguments);
}
Guitar.include(instanceProperties);
return Guitar;
})(Module);
guitar = new Guitar();
return guitar.makeSound().should.be["true"];
});
it('Module can extend from class', function() {
var Guitar, classProperties;
classProperties = (function() {
function classProperties() {}
classProperties.prototype.tuning = function() {
return true;
};
return classProperties;
})();
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
return Guitar.__super__.constructor.apply(this, arguments);
}
Guitar.extend(classProperties);
return Guitar;
})(Module);
return Guitar.tuning().should.be["true"];
});
it('Module can include from class', function() {
var Guitar, guitar, instanceProperties;
instanceProperties = (function() {
function instanceProperties() {}
instanceProperties.prototype.makeSound = function() {
return true;
};
return instanceProperties;
})();
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
return Guitar.__super__.constructor.apply(this, arguments);
}
Guitar.include(instanceProperties);
return Guitar;
})(Module);
guitar = new Guitar();
return guitar.makeSound().should.be["true"];
});
it('Module can include from object in constructor', function() {
var Guitar, guitar, instanceProperties;
instanceProperties = {
makeSound: function() {
return true;
}
};
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
this.include(instanceProperties);
}
return Guitar;
})(Module);
guitar = new Guitar();
return guitar.makeSound().should.be["true"];
});
it('Module can include from class in constructor', function() {
var Guitar, guitar, instanceProperties;
instanceProperties = (function() {
function instanceProperties() {}
instanceProperties.prototype.makeSound = function() {
return true;
};
return instanceProperties;
})();
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
this.include(instanceProperties);
}
return Guitar;
})(Module);
guitar = new Guitar();
return guitar.makeSound().should.be["true"];
});
it("Module can't include from hidden variables", function() {
var Guitar, error, guitar, instanceProperties;
try {
instanceProperties = (function() {
var state;
function instanceProperties() {}
state = {};
instanceProperties.prototype.makeSound = function() {
stateMachine["thing"] = true;
return true;
};
return instanceProperties;
})();
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
this.include(instanceProperties);
}
Guitar.prototype.makeAnotherSound = function() {
var error;
try {
stateMachine["thing"] = true;
} catch (error) {
return true;
}
return true;
};
return Guitar;
})(Module);
guitar = new Guitar();
guitar.makeSound().should.be["true"];
return guitar.makeAnotherSound().should.be["true"];
} catch (error) {
return true.should.be["true"];
}
});
return it("Module can't include from hidden variables", function() {
var Guitar, State, guitar, instanceProperties;
State = (function() {
var stuff;
stuff = {
stuff: "hi"
};
function State() {
this.stateMachine = {
stuff: "hi"
};
}
State.prototype.set = function() {
return stuff['thing'] = true;
};
State.prototype.reset = function() {
return stuff['thing'] = false;
};
State.prototype.show = function() {
return stuff;
};
return State;
})();
instanceProperties = (function() {
function instanceProperties() {}
instanceProperties.prototype.makeSound = function() {
console.log(JSON.stringify(this.stateMachine.show()));
this.stateMachine.set();
console.log(JSON.stringify(this.stateMachine.show()));
return true;
};
return instanceProperties;
})();
Guitar = (function(superClass) {
extend(Guitar, superClass);
function Guitar() {
Guitar.__super__.constructor.call(this);
this.include(instanceProperties);
this.stateMachine = new State();
}
Guitar.prototype.makeAnotherSound = function() {
console.log(JSON.stringify(this.stateMachine.show()));
this.stateMachine.reset();
console.log(JSON.stringify(this.stateMachine.show()));
return true;
};
return Guitar;
})(Module);
guitar = new Guitar();
guitar.makeSound().should.be["true"];
return guitar.makeAnotherSound().should.be["true"];
});
});
}).call(this);
//# sourceMappingURL=Module_test.js.map