Skip to content

Commit

Permalink
updating gitignore, adding test file
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Mar 1, 2016
1 parent d87b98a commit ea7e125
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
node_modules/
stats.json
bundle.js
.DS_Store
npm-debug.log
163 changes: 163 additions & 0 deletions prepareCircularViewData.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
var prepareCircularViewData = require('./prepareCircularViewData');
var expect = require('chai').expect;
var mapAnnotationsToRows = require('./mapAnnotationsToRows.js');
describe('prepareCircularViewData', function() {
it('maps overlapping annotations to rows correctly', function() {
var annotation1 = {
start: 0,
end: 9,
id: 'a'
};
var annotation2 = {
start: 0,
end: 9,
id: 'b'
};
var annotations = [annotation1, annotation2];
var sequenceLength = 10;
var bpsPerRow = 5;
var annotationsToRowsMap = mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow);
expect(annotationsToRowsMap).to.deep.equal({
0: [{
annotation: annotation1,
start: 0,
end: 4,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "beginningAndEnd"
},{
start: 0,
end: 4,
id: annotation2.id,
yOffset: 1,
annotation: annotation2,
enclosingRangeType: "beginningAndEnd"
}],
1: [{
annotation: annotation1,
start: 5,
end: 9,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "beginningAndEnd"
},{
start: 5,
end: 9,
id: annotation2.id,
yOffset: 1,
annotation: annotation2,
enclosingRangeType: "beginningAndEnd"
}]
});
});
it('correctly calculates y-offset for annotation split by origin', function() {
var annotation1 = {
start: 7,
end: 9,
id: 'a'
};
var annotation2 = {
start: 5,
end: 3,
id: 'b'
};
var annotations = [annotation1, annotation2];
var sequenceLength = 10;
var bpsPerRow = 10;
var annotationsToRowsMap = mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow);
expect(annotationsToRowsMap).to.deep.equal({
0: [{
start: 7,
end: 9,
id: annotation1.id,
yOffset: 0,
annotation: annotation1,
enclosingRangeType: "beginningAndEnd"
},{
annotation: annotation2,
start: 0,
end: 3,
id: annotation2.id,
yOffset: 1,
enclosingRangeType: "end"
},{
annotation: annotation2,
start: 5,
end: 9,
id: annotation2.id,
yOffset: 1,
enclosingRangeType: "beginning"
},]
});
});
it('correctly calculates y-offset for annotation split by origin (different ordering of annotations)', function() {
var annotation1 = {
start: 5,
end: 3,
id: 'a'
};
var annotation2 = {
start: 7,
end: 9,
id: 'b'
};
var annotations = [annotation1, annotation2];
var sequenceLength = 10;
var bpsPerRow = 10;
var annotationsToRowsMap = mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow);
expect(annotationsToRowsMap).to.deep.equal({
0: [{
annotation: annotation1,
start: 0,
end: 3,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "end"
},{
annotation: annotation1,
start: 5,
end: 9,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "beginning"
},{
start: 7,
end: 9,
id: annotation2.id,
yOffset: 1,
annotation: annotation2,
enclosingRangeType: "beginningAndEnd"
}]
});
});

it('maps single annotation to rows correctly', function() {
var annotation1 = {
start: 0,
end: 9,
id: 'a'
};
var annotations = [annotation1];
var sequenceLength = 10;
var bpsPerRow = 5;
var annotationsToRowsMap = mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow);
expect(annotationsToRowsMap).to.deep.equal({
0: [{
annotation: annotation1,
start: 0,
end: 4,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "beginningAndEnd"
}],
1: [{
annotation: annotation1,
start: 5,
end: 9,
id: annotation1.id,
yOffset: 0,
enclosingRangeType: "beginningAndEnd"
}]
});
});
});

0 comments on commit ea7e125

Please sign in to comment.