Skip to content

Commit 081cb77

Browse files
committed
add jasmine tests
1 parent 804be62 commit 081cb77

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

test/jasmine/tests/bar_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,23 @@ describe('Bar.crossTraceCalc (formerly known as setPositions)', function() {
969969
assertPointField(gd.calcdata, 'b', [[0, 0, 0, 0]]);
970970
});
971971

972+
it('should set unit width for categories in overlay mode', function() {
973+
var gd = mockBarPlot([{
974+
type: 'bar',
975+
x: ['a', 'b', 'c'],
976+
y: [2, 2, 2]
977+
},
978+
{
979+
type: 'bar',
980+
x: ['a', 'c'],
981+
y: [1, 1]
982+
}], {
983+
barmode: 'overlay'
984+
});
985+
986+
expect(gd.calcdata[1][0].t.bardelta).toBe(1);
987+
});
988+
972989
describe('should relative-stack bar within the same trace that overlap under barmode=group', function() {
973990
it('- base case', function() {
974991
var gd = mockBarPlot([{

test/jasmine/tests/box_test.js

+48
Original file line numberDiff line numberDiff line change
@@ -1534,3 +1534,51 @@ describe('Test box calc', function() {
15341534
});
15351535
});
15361536
});
1537+
1538+
1539+
describe('Box crossTraceCalc', function() {
1540+
'use strict';
1541+
1542+
function mockBoxPlot(dataWithoutTraceType, layout) {
1543+
var traceTemplate = { type: 'box' };
1544+
1545+
var dataWithTraceType = dataWithoutTraceType.map(function(trace) {
1546+
return Lib.extendFlat({}, traceTemplate, trace);
1547+
});
1548+
1549+
var gd = {
1550+
data: dataWithTraceType,
1551+
layout: layout || {},
1552+
calcdata: [],
1553+
_context: {locale: 'en', locales: {}}
1554+
};
1555+
1556+
supplyAllDefaults(gd);
1557+
Plots.doCalcdata(gd);
1558+
1559+
return gd;
1560+
}
1561+
1562+
it('should set unit width for categories in overlay mode', function() {
1563+
var gd = mockBoxPlot([{
1564+
y: [1, 2, 3]
1565+
},
1566+
{
1567+
y: [null, null, null]
1568+
},
1569+
{
1570+
y: [null, null, null]
1571+
},
1572+
{
1573+
y: [4, 5, 6]
1574+
}], {
1575+
boxgap: 0,
1576+
xaxis: {
1577+
range: [-0.5, 3.5],
1578+
type: 'category'
1579+
}
1580+
});
1581+
1582+
expect(gd.calcdata[0][0].t.dPos).toBe(0.5);
1583+
});
1584+
});

0 commit comments

Comments
 (0)