@@ -11,6 +11,7 @@ var subroutines = require('@src/plot_api/subroutines');
1111var d3 = require ( 'd3' ) ;
1212var createGraphDiv = require ( '../assets/create_graph_div' ) ;
1313var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
14+ var fail = require ( '../assets/fail_test' ) ;
1415
1516
1617describe ( 'Test plot api' , function ( ) {
@@ -22,6 +23,44 @@ describe('Test plot api', function() {
2223 } ) ;
2324 } ) ;
2425
26+ describe ( 'Plotly.plot' , function ( ) {
27+ var gd ;
28+
29+ beforeEach ( function ( ) {
30+ gd = createGraphDiv ( ) ;
31+ } ) ;
32+
33+ afterEach ( destroyGraphDiv ) ;
34+
35+ it ( 'accepts gd, data, layout, and config as args' , function ( done ) {
36+ Plotly . plot ( gd ,
37+ [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
38+ { width : 500 , height : 500 } ,
39+ { editable : true }
40+ ) . then ( function ( ) {
41+ expect ( gd . layout . width ) . toEqual ( 500 ) ;
42+ expect ( gd . layout . height ) . toEqual ( 500 ) ;
43+ expect ( gd . data . length ) . toEqual ( 1 ) ;
44+ expect ( gd . _context . editable ) . toBe ( true ) ;
45+ } ) . catch ( fail ) . then ( done ) ;
46+ } ) ;
47+
48+ it ( 'accepts gd and an object as args' , function ( done ) {
49+ Plotly . plot ( gd , {
50+ data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
51+ layout : { width : 500 , height : 500 } ,
52+ config : { editable : true } ,
53+ frames : [ { y : [ 2 , 1 , 0 ] , name : 'frame1' } ]
54+ } ) . then ( function ( ) {
55+ expect ( gd . layout . width ) . toEqual ( 500 ) ;
56+ expect ( gd . layout . height ) . toEqual ( 500 ) ;
57+ expect ( gd . data . length ) . toEqual ( 1 ) ;
58+ expect ( gd . _transitionData . _frames . length ) . toEqual ( 1 ) ;
59+ expect ( gd . _context . editable ) . toBe ( true ) ;
60+ } ) . catch ( fail ) . then ( done ) ;
61+ } ) ;
62+ } ) ;
63+
2564 describe ( 'Plotly.relayout' , function ( ) {
2665 var gd ;
2766
0 commit comments