2014-09-03 16:16:16 +00:00
|
|
|
describe( 'Gui', function() {
|
|
|
|
|
|
|
|
it( 'exists', function() {
|
|
|
|
|
|
|
|
expect( Gui ).toBeDefined();
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'has a ready callback', function() {
|
|
|
|
|
|
|
|
var ready = {
|
|
|
|
ready: function() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
spyOn( ready, 'ready' );
|
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
expect( Gui.ready ).toBeDefined();
|
|
|
|
|
2014-09-03 16:16:16 +00:00
|
|
|
runs( function() {
|
|
|
|
Gui.ready( ready.ready );
|
|
|
|
} );
|
|
|
|
|
|
|
|
waits( 100 );
|
|
|
|
|
|
|
|
runs( function() {
|
|
|
|
expect( ready.ready ).toHaveBeenCalled();
|
|
|
|
} );
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'picks the right controller for the job', function() {
|
|
|
|
|
|
|
|
expectController( 'controller-number', 1234 );
|
|
|
|
expectController( 'controller-string', 'string value' );
|
|
|
|
expectController( 'controller-function', function(){} );
|
|
|
|
expectController( 'controller-boolean', true );
|
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
expectController( 'controller-option', 'hey', [ 'hey', 'hi', 'ho' ] );
|
|
|
|
expectController( 'controller-option', 'a', { a: 'a', b: 'b', c: 'c' } );
|
2014-09-03 16:16:16 +00:00
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
// expectController( 'controller-color', '#00ff00' );
|
|
|
|
// expectController( 'controller-color', '#aba' );
|
2014-09-03 16:16:16 +00:00
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
// expectController( 'controller-color', 'rgba(255, 0, 255, 0.2)' );
|
|
|
|
// expectController( 'controller-color', 'rgb(255, 0, 255)' );
|
|
|
|
|
|
|
|
// expectController( 'controller-color', 'hsl(240, 100%, 50%)' );
|
|
|
|
// expectController( 'controller-color', 'hsla(255, 100%, 40%, 0.5)' );
|
2014-09-03 16:16:16 +00:00
|
|
|
|
|
|
|
} );
|
2014-09-07 20:18:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
function expectController( controllerType, value ) {
|
|
|
|
|
|
|
|
var gui = new Gui();
|
|
|
|
|
|
|
|
// test using gui.add
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'name': value
|
|
|
|
};
|
|
|
|
|
|
|
|
var args = Array.prototype.slice.call( arguments, 2 );
|
|
|
|
args.unshift( 'name' );
|
|
|
|
args.unshift( params );
|
|
|
|
|
|
|
|
var controller = gui.add.apply( gui, args );
|
|
|
|
expect( controller.nodeName.toLowerCase() ).toBe( controllerType );
|
|
|
|
|
|
|
|
// test using gui.anon
|
|
|
|
|
|
|
|
var gui = new Gui();
|
|
|
|
|
|
|
|
args = Array.prototype.slice.call( arguments, 2 );
|
|
|
|
args.unshift( value );
|
|
|
|
args.unshift( 'name' );
|
|
|
|
|
|
|
|
controller = gui.define.apply( gui, args );
|
|
|
|
expect( controller.nodeName.toLowerCase() ).toBe( controllerType );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-09-03 16:16:16 +00:00
|
|
|
} );
|