New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests related to showLines for controller.scatter #5150
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df987a2
Add tests for showLines for scatter chart
loicbourgois e42d0b2
Add test for sholines false
loicbourgois 4add651
fit() to it()
loicbourgois 493ce86
typo
loicbourgois ee5f811
Emove duplicated tests + fail
loicbourgois a3e09e2
Revert fail
loicbourgois File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
describe('Chart.controllers.scatter', function() { | ||
|
||
it('should not draw a line if the options showLines is not set', function() { | ||
var chart = window.acquireChart({ | ||
type: 'scatter', | ||
data: { | ||
datasets: [{ | ||
data: [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need so much data, maybe one is enough |
||
{x: 10, y: 15}, | ||
{x: 0, y: -8}, | ||
{x: -50, y: -6}, | ||
{x: 12, y: -4}, | ||
{x: -9, y: 8} | ||
], | ||
label: 'dataset1' | ||
}], | ||
}, | ||
options: {} | ||
}); | ||
|
||
var meta = chart.getDatasetMeta(0); | ||
spyOn(meta.dataset, 'draw'); | ||
spyOn(meta.data[0], 'draw'); | ||
spyOn(meta.data[1], 'draw'); | ||
spyOn(meta.data[2], 'draw'); | ||
spyOn(meta.data[3], 'draw'); | ||
spyOn(meta.data[4], 'draw'); | ||
|
||
chart.update(); | ||
|
||
expect(meta.dataset.draw.calls.count()).toBe(0); | ||
expect(meta.data[0].draw.calls.count()).toBe(1); | ||
expect(meta.data[1].draw.calls.count()).toBe(1); | ||
expect(meta.data[2].draw.calls.count()).toBe(1); | ||
expect(meta.data[3].draw.calls.count()).toBe(1); | ||
expect(meta.data[4].draw.calls.count()).toBe(1); | ||
}); | ||
|
||
it('should not draw a line if the options showLines set to false', function() { | ||
var chart = window.acquireChart({ | ||
type: 'scatter', | ||
data: { | ||
datasets: [{ | ||
data: [ | ||
{x: 10, y: 15}, | ||
{x: 0, y: -8}, | ||
{x: -50, y: -6}, | ||
{x: 12, y: -4}, | ||
{x: -9, y: 8} | ||
], | ||
label: 'dataset1' | ||
}], | ||
}, | ||
options: { | ||
showLines: false | ||
} | ||
}); | ||
|
||
var meta = chart.getDatasetMeta(0); | ||
spyOn(meta.dataset, 'draw'); | ||
spyOn(meta.data[0], 'draw'); | ||
spyOn(meta.data[1], 'draw'); | ||
spyOn(meta.data[2], 'draw'); | ||
spyOn(meta.data[3], 'draw'); | ||
spyOn(meta.data[4], 'draw'); | ||
|
||
chart.update(); | ||
|
||
expect(meta.dataset.draw.calls.count()).toBe(0); | ||
expect(meta.data[0].draw.calls.count()).toBe(1); | ||
expect(meta.data[1].draw.calls.count()).toBe(1); | ||
expect(meta.data[2].draw.calls.count()).toBe(1); | ||
expect(meta.data[3].draw.calls.count()).toBe(1); | ||
expect(meta.data[4].draw.calls.count()).toBe(1); | ||
}); | ||
|
||
it('should draw a line if the options showLines is set to true', function() { | ||
var chart = window.acquireChart({ | ||
type: 'scatter', | ||
data: { | ||
datasets: [{ | ||
data: [ | ||
{x: 10, y: 15}, | ||
{x: 0, y: -8}, | ||
{x: -50, y: -6}, | ||
{x: 12, y: -4}, | ||
{x: -9, y: 8} | ||
], | ||
label: 'dataset1' | ||
}], | ||
}, | ||
options: { | ||
showLines: true | ||
} | ||
}); | ||
|
||
var meta = chart.getDatasetMeta(0); | ||
spyOn(meta.dataset, 'draw'); | ||
spyOn(meta.data[0], 'draw'); | ||
spyOn(meta.data[1], 'draw'); | ||
spyOn(meta.data[2], 'draw'); | ||
spyOn(meta.data[3], 'draw'); | ||
spyOn(meta.data[4], 'draw'); | ||
|
||
chart.update(); | ||
|
||
expect(meta.dataset.draw.calls.count()).toBe(1); | ||
expect(meta.data[0].draw.calls.count()).toBe(1); | ||
expect(meta.data[1].draw.calls.count()).toBe(1); | ||
expect(meta.data[2].draw.calls.count()).toBe(1); | ||
expect(meta.data[3].draw.calls.count()).toBe(1); | ||
expect(meta.data[4].draw.calls.count()).toBe(1); | ||
}); | ||
|
||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you nest all these tests under
showLines option
: