diff options
author | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
---|---|---|
committer | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
commit | 75687711f35355bc30e4829439384aab28fcac6d (patch) | |
tree | 8f3256f472893c39720a684d390e890a152f7303 /priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js | |
parent | link: post_* callbacks; html & pdftitle. (diff) |
Commit all the changes that hasn't been committed + updates.
Diffstat (limited to 'priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js')
-rw-r--r-- | priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js b/priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js new file mode 100644 index 0000000..6d71dff --- /dev/null +++ b/priv/static/metrics-graphics-3.0-alpha3/tests/common/chart_title_test.js @@ -0,0 +1,93 @@ +module('chart_title'); + +test('Chart title is updated', function() { + var params = { + title: 'foo', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}] + }; + + var params2 = MG.clone(params); + params2.title = 'bar'; + + MG.data_graphic(params); + MG.data_graphic(params2); + + equal(document.querySelector('.mg-chart-title').textContent, 'bar', 'Chart title is foo'); +}); + +test('Chart title is removed if title is set to blank', function() { + var params = { + title: 'foo', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}] + }; + + var params2 = MG.clone(params); + params2.title = ''; + + MG.data_graphic(params); + MG.data_graphic(params2); + equal(document.querySelector('.mg-chart-title'), null, 'Chart title is not added'); +}); + +test('Chart title is removed if title is not set', function() { + var params = { + title: 'foo', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}] + }; + + var params2 = MG.clone(params); + delete params2.title; + + MG.data_graphic(params); + MG.data_graphic(params2); + equal(document.querySelector('.mg-chart-title'), null, 'Chart title is not added'); +}); + +test('When a description is set, we get a question mark', function() { + var params = { + title: 'foo', + description: 'bar', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}], + show_tooltips: true + }; + + MG.data_graphic(params); + ok(document.querySelector('.mg-chart-description'), 'Description icon exists'); +}); + +test('When an error is set, we get an exclamation icon', function() { + var params = { + title: 'foo', + description: 'bar', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}], + error: 'lorem ipsum' + }; + + MG.data_graphic(params); + ok(document.querySelector('.mg-chart-title .mg-warning'), 'Error icon exists'); +}); + +test('Chart title is not duplicated on redraw', function() { + var params = { + title: 'foo', + target: '#qunit-fixture', + data: [{'date': new Date('2014-01-01'), 'value': 12}, + {'date': new Date('2014-03-01'), 'value': 18}] + }; + + var params2 = MG.clone(params); + MG.data_graphic(params); + MG.data_graphic(params2); + + equal(document.querySelectorAll('.mg-chart-title').length, 1, 'there is once chart title'); +}); |