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 : [
|
||||
'test/artifacts/**/*.js',
|
||||
'test/lib/mock-ajax.js',
|
||||
'test/lib/**/*.js',
|
||||
'test/unit/**/*.js',
|
||||
'test/lib/jquery-1.11.0.min.js',
|
||||
'js/sound/SoundDecoder.js',
|
||||
'js/sound/**/*.js',
|
||||
'js/util/**/*.js',
|
||||
'js/**/*.js'
|
||||
'js/**/*.js',
|
||||
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
|
||||
],
|
||||
|
||||
exclude : [
|
||||
],
|
||||
|
||||
preprocessors: {
|
||||
'*.html': ['html2js']
|
||||
},
|
||||
|
||||
autoWatch : true,
|
||||
|
||||
frameworks: ['jasmine'],
|
||||
|
@ -23,15 +27,10 @@ module.exports = function(config){
|
|||
browsers : ['Chrome'],
|
||||
|
||||
plugins : [
|
||||
'karma-junit-reporter',
|
||||
'karma-jasmine',
|
||||
'jasmine-jquery',
|
||||
'karma-html2js-preprocessor',
|
||||
'karma-chrome-launcher',
|
||||
'karma-firefox-launcher',
|
||||
'karma-jasmine'
|
||||
],
|
||||
|
||||
junitReporter : {
|
||||
outputFile: 'test_out/unit.xml',
|
||||
suite: 'unit'
|
||||
}
|
||||
|
||||
'karma-firefox-launcher'
|
||||
]
|
||||
})}
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
"description": "HTML 5 based Scratch project player",
|
||||
"repository": "https://github.com/LLK/scratch-html5",
|
||||
"devDependencies": {
|
||||
"phantomjs" : "~1.9",
|
||||
"karma" : "~0.10",
|
||||
"karma-junit-reporter" : "~0.1",
|
||||
"karma-jasmine" : "~0.1",
|
||||
"karma-ng-scenario" : "~0.1",
|
||||
"jquery" : "~1.11.0"
|
||||
"karma" : "~0.10",
|
||||
"jasmine-jquery" : "1.3.3",
|
||||
"karma-html2js-preprocessor" : "~0.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,63 @@
|
|||
'use strict';
|
||||
|
||||
/* jasmine specs for Scratch.js go here */
|
||||
|
||||
describe('Scratch', function(){
|
||||
var getScript, request, scratch;
|
||||
var uri = "http://getScript.example.com";
|
||||
var callBack = jasmine.createSpy('onSuccess');
|
||||
var testResponseText = 'This is a script';
|
||||
describe ('Scratch', function() {
|
||||
describe('Scratch - Load Project', function(){
|
||||
var getScript, request, scratch;
|
||||
var uri = "http://getScript.example.com";
|
||||
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() {
|
||||
jasmine.Ajax.useMock();
|
||||
scratch = Scratch;
|
||||
scratch(project_id);
|
||||
request = mostRecentAjaxRequest();
|
||||
request.promise(TestResponses, callBack);
|
||||
});
|
||||
beforeEach(function() {
|
||||
jasmine.Ajax.useMock();
|
||||
scratch = Scratch;
|
||||
scratch(project_id);
|
||||
request = mostRecentAjaxRequest();
|
||||
request.promise(TestResponses, callBack);
|
||||
});
|
||||
|
||||
it('should call the internalapi project', function() {
|
||||
expect(request.url).toBe("proxy.php?resource=internalapi/project/" + project_id + "/get/");
|
||||
expect(callBack).toHaveBeenCalled();
|
||||
});
|
||||
it('should call the internalapi project', function() {
|
||||
expect(request.url).toBe("proxy.php?resource=internalapi/project/" + project_id + "/get/");
|
||||
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