updates to bring more of the Scratch project under test ... still baby-steps
This commit is contained in:
parent
6699864097
commit
23cc21b7d9
3 changed files with 72 additions and 38 deletions
|
@ -4,18 +4,22 @@ module.exports = function(config){
|
||||||
|
|
||||||
files : [
|
files : [
|
||||||
'test/artifacts/**/*.js',
|
'test/artifacts/**/*.js',
|
||||||
'test/lib/mock-ajax.js',
|
'test/lib/**/*.js',
|
||||||
'test/unit/**/*.js',
|
'test/unit/**/*.js',
|
||||||
'test/lib/jquery-1.11.0.min.js',
|
|
||||||
'js/sound/SoundDecoder.js',
|
'js/sound/SoundDecoder.js',
|
||||||
'js/sound/**/*.js',
|
'js/sound/**/*.js',
|
||||||
'js/util/**/*.js',
|
'js/util/**/*.js',
|
||||||
'js/**/*.js'
|
'js/**/*.js',
|
||||||
|
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
exclude : [
|
exclude : [
|
||||||
],
|
],
|
||||||
|
|
||||||
|
preprocessors: {
|
||||||
|
'*.html': ['html2js']
|
||||||
|
},
|
||||||
|
|
||||||
autoWatch : true,
|
autoWatch : true,
|
||||||
|
|
||||||
frameworks: ['jasmine'],
|
frameworks: ['jasmine'],
|
||||||
|
@ -23,15 +27,10 @@ module.exports = function(config){
|
||||||
browsers : ['Chrome'],
|
browsers : ['Chrome'],
|
||||||
|
|
||||||
plugins : [
|
plugins : [
|
||||||
'karma-junit-reporter',
|
'karma-jasmine',
|
||||||
|
'jasmine-jquery',
|
||||||
|
'karma-html2js-preprocessor',
|
||||||
'karma-chrome-launcher',
|
'karma-chrome-launcher',
|
||||||
'karma-firefox-launcher',
|
'karma-firefox-launcher'
|
||||||
'karma-jasmine'
|
]
|
||||||
],
|
|
||||||
|
|
||||||
junitReporter : {
|
|
||||||
outputFile: 'test_out/unit.xml',
|
|
||||||
suite: 'unit'
|
|
||||||
}
|
|
||||||
|
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -3,11 +3,8 @@
|
||||||
"description": "HTML 5 based Scratch project player",
|
"description": "HTML 5 based Scratch project player",
|
||||||
"repository": "https://github.com/LLK/scratch-html5",
|
"repository": "https://github.com/LLK/scratch-html5",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"phantomjs" : "~1.9",
|
"karma" : "~0.10",
|
||||||
"karma" : "~0.10",
|
"jasmine-jquery" : "1.3.3",
|
||||||
"karma-junit-reporter" : "~0.1",
|
"karma-html2js-preprocessor" : "~0.1.0"
|
||||||
"karma-jasmine" : "~0.1",
|
|
||||||
"karma-ng-scenario" : "~0.1",
|
|
||||||
"jquery" : "~1.11.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,63 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* jasmine specs for Scratch.js go here */
|
/* jasmine specs for Scratch.js go here */
|
||||||
|
|
||||||
describe('Scratch', function(){
|
describe ('Scratch', function() {
|
||||||
var getScript, request, scratch;
|
describe('Scratch - Load Project', function(){
|
||||||
var uri = "http://getScript.example.com";
|
var getScript, request, scratch;
|
||||||
var callBack = jasmine.createSpy('onSuccess');
|
var uri = "http://getScript.example.com";
|
||||||
var testResponseText = 'This is a script';
|
var callBack = jasmine.createSpy('onSuccess');
|
||||||
|
var testResponseText = 'This is a script';
|
||||||
|
|
||||||
var TestResponses = { status: 200, responseText: returnData};
|
var TestResponses = { status: 200, responseText: returnData};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
jasmine.Ajax.useMock();
|
jasmine.Ajax.useMock();
|
||||||
scratch = Scratch;
|
scratch = Scratch;
|
||||||
scratch(project_id);
|
scratch(project_id);
|
||||||
request = mostRecentAjaxRequest();
|
request = mostRecentAjaxRequest();
|
||||||
request.promise(TestResponses, callBack);
|
request.promise(TestResponses, callBack);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the internalapi project', function() {
|
it('should call the internalapi project', function() {
|
||||||
expect(request.url).toBe("proxy.php?resource=internalapi/project/" + project_id + "/get/");
|
expect(request.url).toBe("proxy.php?resource=internalapi/project/" + project_id + "/get/");
|
||||||
expect(callBack).toHaveBeenCalled();
|
expect(callBack).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Scratch - Click Green Flag', function(){
|
||||||
|
beforeEach(function() {
|
||||||
|
setFixtures('<button id=trigger-green-flag tabindex=2></button><div id="overlay"></div>');
|
||||||
|
scratch = Scratch;
|
||||||
|
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 = Scratch;
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue