Skip to content

Commit

Permalink
more toward #533 - began adding more tests. Much more to do.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamilton committed Oct 27, 2015
1 parent d0162e3 commit b963fac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/metricsgraphics.js
Expand Up @@ -1920,7 +1920,7 @@ function mg_init_compute_width(args){
// get parent element
svg_width = get_width(args.target);
}
args.width=svg_width;
args.width = svg_width;
}

function mg_init_compute_height(args){
Expand Down Expand Up @@ -2059,7 +2059,7 @@ function init(args) {
mg_is_time_series(args);
mg_init_compute_width(args);
mg_init_compute_height(args);

mg_remove_svg_if_chart_type_has_changed(svg, args);
svg = mg_add_svg_if_it_doesnt_exist(svg, args);

Expand Down
4 changes: 2 additions & 2 deletions src/js/common/init.js
Expand Up @@ -27,7 +27,7 @@ function mg_init_compute_width(args){
// get parent element
svg_width = get_width(args.target);
}
args.width=svg_width;
args.width = svg_width;
}

function mg_init_compute_height(args){
Expand Down Expand Up @@ -166,7 +166,7 @@ function init(args) {
mg_is_time_series(args);
mg_init_compute_width(args);
mg_init_compute_height(args);

mg_remove_svg_if_chart_type_has_changed(svg, args);
svg = mg_add_svg_if_it_doesnt_exist(svg, args);

Expand Down
35 changes: 35 additions & 0 deletions tests/common/init_test.js
@@ -1,5 +1,40 @@
module('init');

test('MG properly detects time series vs. not.', function() {
var params1 = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-11-01'), 'value': 12},
{'date': new Date('2014-11-02'), 'value': 18}],
x_accessor:'date'
};

var params2 = {
target: '#qunit-fixture',
data: [{'date': 5434, 'value': 12},
{'date': 5435, 'value': 18}],
x_accessor:'date'
};

var params3 = {
target: '#qunit-fixture',
data: [[{'date': new Date('2014-11-01'), 'value': 12},
{'date': new Date('2014-11-02'), 'value': 18}],
[{'date': new Date('2014-11-01'), 'value': 32},
{'date': new Date('2014-11-02'), 'value': 43}]],
x_accessor:'date'
};
mg_merge_args_with_defaults(params1);
mg_merge_args_with_defaults(params2);
mg_merge_args_with_defaults(params3);
mg_is_time_series(params1);
mg_is_time_series(params2);
mg_is_time_series(params3);

ok(params1.time_series === true, 'Date-accessed data set is a time series.');
ok(params2.time_series === false, 'Number-accessed data set is not a time series.');
ok(params3.time_series === true, 'Nested data set w/ dates detected as time series.');
});

test('Chart\'s width is set correctly on subsequent calls to existing chart', function() {
var params_0 = {
target: '#qunit-fixture',
Expand Down

0 comments on commit b963fac

Please sign in to comment.