Skip to content

Commit

Permalink
Pass initialRange to <Root>. components-test passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Mar 20, 2015
1 parent f3fee97 commit a8de3d2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions lib/mocha.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
declare function describe(description: string, spec: () => void): void;
declare function it(expectation: string, assertion: (done: () => void) => void): void;
declare function afterEach(fn: () => void): void;
9 changes: 3 additions & 6 deletions src/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var React = require('react'),
var Root = React.createClass({
propTypes: {
referenceSource: React.PropTypes.object.isRequired,
geneSource: React.PropTypes.object.isRequired
geneSource: React.PropTypes.object.isRequired,
initialRange: React.PropTypes.object.isRequired
},
getInitialState: function() {
return {
Expand All @@ -34,11 +35,7 @@ var Root = React.createClass({

source.on('contigs', () => {
// this is here to facilitate faster iteration
this.handleRangeChange({
contig: 'chr17',
start: 7512444,
stop: 7512484
});
this.handleRangeChange(this.props.initialRange);
});

var geneSource = this.props.geneSource;
Expand Down
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var ensembl = new BigBed('/ensGene.bb');
var ensemblDataSource = createBigBedDataSource(ensembl);

React.render(<Root referenceSource={dataSource}
geneSource={ensemblDataSource} />,
geneSource={ensemblDataSource}
initialRange={{contig: "chr17", start: 7512444, stop: 7512484}} />,
document.getElementById('root'));

window.ensembl = ensembl;
Expand Down
2 changes: 1 addition & 1 deletion test/BigBedDataSource-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('BigBedDataSource', function() {
function getTestSource() {
// This file was created from Biodalliance's ensGene.bb via:
// bigBedToBed ensGene.bb ensGene.bed
// grep '^chr17 ' ensGene.bed > /tmp/ensGene17.bed
// grep '^chr17\t' ensGene.bed > /tmp/ensGene17.bed
// bedToBigBed -type=bed12+2 /tmp/ensGene17.bed <(echo "chr17 78774742")
// test/data/ensembl.chr17.bb
return createBigBedDataSource(new BigBed('/test/data/ensembl.chr17.bb'));
Expand Down
24 changes: 10 additions & 14 deletions test/components-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* @flow */
'use strict';

var chai = require('chai');
var expect = chai.expect;

var Q = require('q');
var _ = require('underscore');

var React = require('react/addons'),
TwoBit = require('../src/TwoBit'),
Expand All @@ -28,7 +28,7 @@ function waitFor(predFn, timeoutMs) {
var check = function() {
if (def.promise.isRejected()) return;
if (predFn()) {
def.resolve();
def.resolve(null); // no arguments needed
window.clearTimeout(timeoutId);
} else {
checkTimeoutId = window.setTimeout(check, WAIT_FOR_POLL_INTERVAL_MS);
Expand All @@ -40,19 +40,13 @@ function waitFor(predFn, timeoutMs) {
}


/**
* Apply a CSS selector to a React tree. Returns an array of DOM nodes.
*/
function findInComponent(selector, component) {
return _.toArray(component.getDOMNode().querySelectorAll(selector));
}


describe('Root component', function() {
var genome = new TwoBit('/hg19.2bit');
var genome = new TwoBit('/test/data/test.2bit');
var dataSource = createTwoBitDataSource(genome);

var ensembl = new BigBed('/ensGene.bb');
// This file contains just the TP53 gene, shifted so that it starts at the
// beginning of chr17 (to match test.2bit).
var ensembl = new BigBed('/test/data/tp53.shifted.bb');
var ensemblDataSource = createBigBedDataSource(ensembl);

var testDiv = document.getElementById('testdiv');
Expand All @@ -68,8 +62,10 @@ describe('Root component', function() {
div.setAttribute('style', 'width: 800px; height: 200px;');
testDiv.appendChild(div);

var root = React.render(<Root referenceSource={dataSource}
geneSource={ensemblDataSource} />, div);
// TODO: changing to {start:1, stop:50} makes the test fail.
React.render(<Root referenceSource={dataSource}
geneSource={ensemblDataSource}
initialRange={{contig:"chr17", start: 100, stop: 150}} />, div);

var ready = (() =>
div.querySelectorAll('.basepair').length > 0 &&
Expand Down
Binary file added test/data/tp53.shifted.bb
Binary file not shown.

0 comments on commit a8de3d2

Please sign in to comment.