This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
scratch-html5/test/unit/scratchSpec.js
2014-04-09 01:18:14 -07:00

66 lines
2.2 KiB
JavaScript

/* jasmine specs for Scratch.js go here */
describe('Scratch', function() {
var scratch;
beforeEach(function() {
spyOn(IO.prototype, "loadProject");
spyOn(Runtime.prototype, "init");
spyOn(Interpreter.prototype, "initPrims");
scratch = Scratch;
});
describe('Scratch - Load Project', function() {
beforeEach(function() {
scratch(project_id);
});
it('should call the IO loadProject Method', function() {
expect(IO.prototype.loadProject).toHaveBeenCalled();
});
it('should call the Runtime init method', function() {
expect(Runtime.prototype.init).toHaveBeenCalled();
});
it('should call the Interpreter initPrims method', function() {
expect(Interpreter.prototype.initPrims).toHaveBeenCalled();
});
});
describe('Scratch - Click Green Flag', function() {
beforeEach(function() {
setFixtures('<button id=trigger-green-flag tabindex=2></button><div id="overlay"></div>');
scratch(project_id);
});
it('should not click on the green flag if the project is loading', function() {
runtime.projectLoaded = false;
spyOn(runtime, 'greenFlag');
$('#trigger-green-flag').click();
expect(runtime.greenFlag).not.toHaveBeenCalled();
expect($('#overlay').css('display')).toBe('block');
});
it('should click on the green flag if the project is loaded', function() {
runtime.projectLoaded = true;
spyOn(runtime, 'greenFlag');
$('#trigger-green-flag').click();
expect(runtime.greenFlag).toHaveBeenCalled();
expect($('#overlay').css('display')).toBe('none');
});
});
describe('Scratch - Click Stop', function() {
beforeEach(function() {
setFixtures('<button id=trigger-stop tabindex=3></button>');
scratch(project_id);
});
it('should not click on the green flag if the project is loading', function() {
spyOn(runtime, 'stopAll');
$('#trigger-stop').click();
expect(runtime.stopAll).toHaveBeenCalled();
});
});
});