Skip to content

Commit

Permalink
Add omnibox test
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Oct 27, 2015
1 parent de2ef87 commit a0f06a5
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions src/test/GenomeTrack-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ describe('GenomeTrack', function() {
});
});

var getInputs = function(selector): HTMLInputElement[] {
var els = testDiv.querySelectorAll(selector);
// note: this isn't really true, but it makes flow happy
return ((els: any): HTMLInputElement[]);
};

it('should zoom in and out', function() {
var p = pileup.create(testDiv, {
range: {contig: '17', start: 7500725, stop: 7500775},
Expand All @@ -87,12 +93,6 @@ describe('GenomeTrack', function() {
]
});

var getInputs = function(selector): HTMLInputElement[] {
var els = testDiv.querySelectorAll(selector);
// note: this isn't really true, but it makes flow happy
return ((els: any): HTMLInputElement[]);
};

expect(testDiv.querySelectorAll('.zoom-controls')).to.have.length(1);

var buttons = testDiv.querySelectorAll('.controls button');
Expand Down Expand Up @@ -123,4 +123,35 @@ describe('GenomeTrack', function() {
p.destroy();
});
});

it('should accept user-entered locations', function() {
var p = pileup.create(testDiv, {
range: {contig: '17', start: 7500725, stop: 7500775},
tracks: [
{
data: referenceSource,
viz: pileup.viz.genome(),
isReference: true
}
]
});

var [locationTxt] = getInputs('.controls input[type="text"]');
var [goBtn] = testDiv.querySelectorAll('.controls button');
expect(goBtn.textContent).to.equal('Go');

return waitFor(hasReference, 2000).then(() => {
expect(locationTxt.value).to.equal('7,500,725-7,500,775');
locationTxt.value = '17:7500745-7500785';
ReactTestUtils.Simulate.click(goBtn);
}).delay(50).then(() => {
expect(p.getRange()).to.deep.equal({
contig: 'chr17', // note: not '17'
start: 7500745,
stop: 7500785
});
expect(locationTxt.value).to.equal('7,500,745-7,500,785');
p.destroy();
});
});
});

0 comments on commit a0f06a5

Please sign in to comment.