Skip to content

Commit d52a803

Browse files
committed
add tests to handle weekday strings
1 parent a03d64d commit d52a803

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/jasmine/tests/axes_test.js

+27
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,33 @@ describe('Test axes', function() {
11351135
expect(layoutOut.xaxis2.rangebreaks[0].pattern).toBe('day of week', 'coerced');
11361136
expect(layoutOut.xaxis3.rangebreaks[0].pattern).toBe(undefined, 'not coerce, using *values*');
11371137
});
1138+
1139+
it('should auto default rangebreaks.pattern to *day of week* when *bounds* include a weekday string and convert bounds to integer days', function() {
1140+
layoutIn = {
1141+
xaxis: {type: 'date', rangebreaks: [
1142+
{bounds: ['Saturday', 'Monday']}
1143+
]},
1144+
xaxis2: {type: 'date', rangebreaks: [
1145+
{bounds: ['sun', 'thu']},
1146+
{bounds: ['mon', 'fri']},
1147+
{bounds: ['tue', 'sat']},
1148+
{bounds: ['wed', '-1']}
1149+
]}
1150+
};
1151+
layoutOut._subplots.xaxis.push('x2');
1152+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
1153+
1154+
expect(layoutOut.xaxis.rangebreaks[0].pattern).toBe('day of week', 'complete Capital');
1155+
expect(layoutOut.xaxis2.rangebreaks[0].pattern).toBe('day of week', '3-letter case');
1156+
expect(layoutOut.xaxis2.rangebreaks[0].bounds[0]).toBe(0, 'convert sun');
1157+
expect(layoutOut.xaxis2.rangebreaks[1].bounds[0]).toBe(1, 'convert mon');
1158+
expect(layoutOut.xaxis2.rangebreaks[2].bounds[0]).toBe(2, 'convert tue');
1159+
expect(layoutOut.xaxis2.rangebreaks[3].bounds[0]).toBe(3, 'convert wed');
1160+
expect(layoutOut.xaxis2.rangebreaks[0].bounds[1]).toBe(4, 'convert thu');
1161+
expect(layoutOut.xaxis2.rangebreaks[1].bounds[1]).toBe(5, 'convert fri');
1162+
expect(layoutOut.xaxis2.rangebreaks[2].bounds[1]).toBe(6, 'convert sat');
1163+
expect(layoutOut.xaxis2.rangebreaks[3].bounds[1]).toBe('-1', 'string');
1164+
});
11381165
});
11391166

11401167
describe('constraints relayout', function() {

0 commit comments

Comments
 (0)