Skip to content

Commit e00dc1e

Browse files
authored
Improve helpers.color test coverage (#8034)
1 parent 63ab5a0 commit e00dc1e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/specs/helpers.color.tests.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ describe('Color helper', function() {
1111
});
1212

1313
describe('Background hover color helper', function() {
14+
it('should return a modified version of color when called with a color', function() {
15+
var originalColorRGB = 'rgb(70, 191, 189)';
16+
17+
expect(getHoverColor('#46BFBD')).not.toEqual(originalColorRGB);
18+
});
19+
});
20+
21+
describe('color and getHoverColor helpers', function() {
1422
it('should return a CanvasPattern when called with a CanvasPattern', function(done) {
1523
var dots = new Image();
1624
dots.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAD1BMVEUAAAD///////////////+PQt5oAAAABXRSTlMAHlFhZsfk/BEAAAAqSURBVHgBY2BgZGJmYmSAAUYWEIDzmcBcJhiXGcxlRpPFrhdmMiqgvX0AcGIBEUAo6UAAAAAASUVORK5CYII=';
@@ -20,10 +28,10 @@ describe('Background hover color helper', function() {
2028
var patternContext = patternCanvas.getContext('2d');
2129
var pattern = patternContext.createPattern(dots, 'repeat');
2230
patternContext.fillStyle = pattern;
31+
var chartPattern = chartContext.createPattern(patternCanvas, 'repeat');
2332

24-
var backgroundColor = getHoverColor(chartContext.createPattern(patternCanvas, 'repeat'));
25-
26-
expect(backgroundColor instanceof CanvasPattern).toBe(true);
33+
expect(color(chartPattern) instanceof CanvasPattern).toBe(true);
34+
expect(getHoverColor(chartPattern) instanceof CanvasPattern).toBe(true);
2735

2836
done();
2937
};
@@ -33,12 +41,7 @@ describe('Background hover color helper', function() {
3341
var context = document.createElement('canvas').getContext('2d');
3442
var gradient = context.createLinearGradient(0, 1, 2, 3);
3543

44+
expect(color(gradient) instanceof CanvasGradient).toBe(true);
3645
expect(getHoverColor(gradient) instanceof CanvasGradient).toBe(true);
3746
});
38-
39-
it('should return a modified version of color when called with a color', function() {
40-
var originalColorRGB = 'rgb(70, 191, 189)';
41-
42-
expect(getHoverColor('#46BFBD')).not.toEqual(originalColorRGB);
43-
});
4447
});

0 commit comments

Comments
 (0)