Merge pull request #2678 from solgenomics/BBase-15
[sgn.git] / js / test / boxplotter.test.js
blobd620ca2f9b67ba172b5975b68fcd5ca184c4f9b3
1 import test from 'tape';
2 import nock from 'nock';
3 import * as Boxplotter from '../source/entries/boxplotter.js';
4 import data from './boxplotter.test.data.js';
6 test('Boxplot', t=>{
7     
8     document.querySelector('body').innerHTML = `<div id="bxplt"></div>`;
9     
10     var boxplotter;
11     
12     t.test("initialize", t=>{
13         t.plan(1);
14         t.doesNotThrow(()=>{
15             boxplotter = Boxplotter.init("#bxplt");
16         })
17     });
18     
19     t.test("populate", t=>{
20         t.plan(2);
21         
22         var scope = nock(document.location.origin);
23         scope.get('/ajax/tools/boxplotter/get_constraints').query({dataset: 7})
24             .reply(200, data.constraints);
25         scope.post('/brapi/v1/phenotypes-search')
26             .reply(200, data.phenotypes);
27             
28         setTimeout(() => {
29             t.ok(scope.isDone(),"expected calls made");
30         }, 200)
31             
32         t.doesNotThrow(()=>{
33             boxplotter.loadDatasetObsUnits(7,"plot");
34         },"loadDatasetObsUnits works");
35     });
36 });