2014-02-19 20:11:08 -07:00
/* jasmine specs for Scratch.js go here */
2014-03-10 21:04:56 -06:00
describe ( 'Scratch' , function ( ) {
var scratch ;
2014-03-04 21:48:22 -07:00
2014-03-10 21:04:56 -06:00
beforeEach ( function ( ) {
2014-04-09 01:18:14 -07:00
spyOn ( IO . prototype , "loadProject" ) ;
spyOn ( Runtime . prototype , "init" ) ;
spyOn ( Interpreter . prototype , "initPrims" ) ;
scratch = Scratch ;
2014-03-10 21:04:56 -06:00
} ) ;
2014-03-04 21:48:22 -07:00
2014-04-09 01:18:14 -07:00
describe ( 'Scratch - Load Project' , function ( ) {
beforeEach ( function ( ) {
scratch ( project _id ) ;
} ) ;
2014-03-04 21:48:22 -07:00
2014-04-09 01:18:14 -07:00
it ( 'should call the IO loadProject Method' , function ( ) {
expect ( IO . prototype . loadProject ) . toHaveBeenCalled ( ) ;
} ) ;
2014-03-10 21:04:56 -06:00
2014-04-09 01:18:14 -07:00
it ( 'should call the Runtime init method' , function ( ) {
expect ( Runtime . prototype . init ) . toHaveBeenCalled ( ) ;
} ) ;
2014-03-10 21:04:56 -06:00
2014-04-09 01:18:14 -07:00
it ( 'should call the Interpreter initPrims method' , function ( ) {
expect ( Interpreter . prototype . initPrims ) . toHaveBeenCalled ( ) ;
} ) ;
2014-03-04 21:48:22 -07:00
} ) ;
2014-04-09 01:18:14 -07:00
describe ( 'Scratch - Click Green Flag' , function ( ) {
beforeEach ( function ( ) {
setFixtures ( '<button id=trigger-green-flag tabindex=2></button><div id="overlay"></div>' ) ;
scratch ( project _id ) ;
} ) ;
2014-03-04 21:48:22 -07:00
2014-04-09 01:18:14 -07:00
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' ) ;
} ) ;
2014-03-04 21:48:22 -07:00
2014-04-09 01:18:14 -07:00
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' ) ;
} ) ;
2014-03-04 21:48:22 -07:00
} ) ;
2014-04-09 01:18:14 -07:00
describe ( 'Scratch - Click Stop' , function ( ) {
beforeEach ( function ( ) {
setFixtures ( '<button id=trigger-stop tabindex=3></button>' ) ;
scratch ( project _id ) ;
} ) ;
2014-03-04 21:48:22 -07:00
2014-04-09 01:18:14 -07:00
it ( 'should not click on the green flag if the project is loading' , function ( ) {
spyOn ( runtime , 'stopAll' ) ;
$ ( '#trigger-stop' ) . click ( ) ;
expect ( runtime . stopAll ) . toHaveBeenCalled ( ) ;
} ) ;
2014-03-04 21:48:22 -07:00
} ) ;
2014-02-19 20:11:08 -07:00
} ) ;