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() {
|
|
|
|
|
2014-09-09 19:53:30 +00:00
|
|
|
expectController( 'dat-gui-number', 1234 );
|
|
|
|
expectController( 'dat-gui-string', 'string value' );
|
2014-09-09 20:58:28 +00:00
|
|
|
expectController( 'dat-gui-function', function() {} );
|
2014-09-09 19:53:30 +00:00
|
|
|
expectController( 'dat-gui-boolean', true );
|
2014-09-03 16:16:16 +00:00
|
|
|
|
2014-09-09 19:53:30 +00:00
|
|
|
expectController( 'dat-gui-option', 'hey', [ 'hey', 'hi', 'ho' ] );
|
|
|
|
expectController( 'dat-gui-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 ) {
|
2014-09-09 20:18:15 +00:00
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
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 );
|
2014-09-09 20:18:15 +00:00
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
// test using gui.anon
|
|
|
|
|
|
|
|
var gui = new Gui();
|
|
|
|
|
|
|
|
args = Array.prototype.slice.call( arguments, 2 );
|
|
|
|
args.unshift( value );
|
|
|
|
args.unshift( 'name' );
|
|
|
|
|
2014-09-09 20:18:15 +00:00
|
|
|
controller = gui.var.apply( gui, args );
|
2014-09-07 20:18:36 +00:00
|
|
|
expect( controller.nodeName.toLowerCase() ).toBe( controllerType );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-09-09 20:18:15 +00:00
|
|
|
} );
|