Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jan 24, 2019
1 parent 31ffe80 commit 8c89c7a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/specs/controller.line.tests.js
Expand Up @@ -573,6 +573,61 @@ describe('Chart.controllers.line', function() {
expect(meta.dataset._model.borderWidth).toBe(0.55);
});

it('should fall back to the dataset default spanGaps option', function() {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [0, 0],
label: 'dataset1'
}],
labels: ['label1', 'label2']
}
});

var meta = chart.getDatasetMeta(0);

expect(meta.dataset._model.spanGaps).toBe(true);
});

it('should obey the global spanGaps option', function() {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [0, 0],
label: 'dataset1'
}],
labels: ['label1', 'label2']
},
options: {
spanGaps: false
}
});

var meta = chart.getDatasetMeta(0);

expect(meta.dataset._model.spanGaps).toBe(false);
});

it('should obey the dataset spanGaps option', function() {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [0, 0],
label: 'dataset1',
spanGaps: false
}],
labels: ['label1', 'label2']
}
});

var meta = chart.getDatasetMeta(0);

expect(meta.dataset._model.spanGaps).toBe(false);
});

it('should handle number of data point changes in update', function() {
var chart = window.acquireChart({
type: 'line',
Expand Down
23 changes: 23 additions & 0 deletions test/specs/controller.scatter.test.js
Expand Up @@ -47,5 +47,28 @@ describe('Chart.controllers.scatter', function() {
expect(meta.dataset.draw.calls.count()).toBe(0);
expect(meta.data[0].draw.calls.count()).toBe(1);
});

it('should draw a line if true', function() {
var chart = window.acquireChart({
type: 'scatter',
data: {
datasets: [{
data: [{x: 10, y: 15}],
showLine: true,
label: 'dataset1'
}],
},
options: {}
});

var meta = chart.getDatasetMeta(0);
spyOn(meta.dataset, 'draw');
spyOn(meta.data[0], 'draw');

chart.update();

expect(meta.dataset.draw.calls.count()).toBe(1);
expect(meta.data[0].draw.calls.count()).toBe(1);
});
});
});

0 comments on commit 8c89c7a

Please sign in to comment.