Skip to content

Commit

Permalink
Add new test to localize_test to handle new locale format parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDemulierChevret committed Jan 22, 2018
1 parent f90efdc commit 58acd27
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/jasmine/tests/localize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,54 @@ describe('localization', function() {
.catch(failTest)
.then(done);
});

it('uses extraFormat to localize the autoFormatted x-axis date tick', function(done) {
plot('test')
.then(function() {
// test format.month
expect(firstXLabel()).toBe('Jan 2001');
return Plotly.update(gd, {x: [['2001-01-01', '2001-02-01']]});
})
.then(function() {
// test format.dayMonth & format.year
expect(firstXLabel()).toBe('Dec 312000');

return Plotly.update(gd, {x: [['2001-01-01', '2001-01-02']]});
})
.then(function() {
// test format.dayMonthYear
expect(firstXLabel()).toBe('00:00Jan 1, 2001');

Plotly.register({
moduleType: 'locale',
name: 'test',
format: {
year: 'Y%Y',
month: '%Y %b',
dayMonth: '%-d %b',
dayMonthYear: '%-d %b %Y'
}
});

return Plotly.update(gd, {x: [['2001-01-01', '2002-01-01']]});
})
.then(function() {
// test format.month
expect(firstXLabel()).toBe('2001 Jan');

return Plotly.update(gd, {x: [['2001-01-01', '2001-02-01']]});
})
.then(function() {
// test format.dayMonth & format.year
expect(firstXLabel()).toBe('31 DecY2000');

return Plotly.update(gd, {x: [['2001-01-01', '2001-01-02']]});
})
.then(function() {
// test format.dayMonthYear
expect(firstXLabel()).toBe('00:001 Jan 2001');
})
.catch(failTest)
.then(done);
});
});

0 comments on commit 58acd27

Please sign in to comment.