From: Simon Brunel Date: Thu, 8 Sep 2016 21:29:39 +0000 (+0200) Subject: Automatically expose custom Jasmine matchers X-Git-Tag: v2.3.0-rc.1~1^2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3287%2Fhead;p=thirdparty%2FChart.js.git Automatically expose custom Jasmine matchers --- diff --git a/test/controller.bar.tests.js b/test/controller.bar.tests.js index 427818723..3ef9cabdf 100644 --- a/test/controller.bar.tests.js +++ b/test/controller.bar.tests.js @@ -1,10 +1,5 @@ // Test the bar controller describe('Bar controller tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'bar', diff --git a/test/controller.bubble.tests.js b/test/controller.bubble.tests.js index ad81bd544..ec61a0b50 100644 --- a/test/controller.bubble.tests.js +++ b/test/controller.bubble.tests.js @@ -1,10 +1,5 @@ // Test the bubble controller describe('Bubble controller tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'bubble', diff --git a/test/controller.doughnut.tests.js b/test/controller.doughnut.tests.js index 0fac90d58..0d31653a7 100644 --- a/test/controller.doughnut.tests.js +++ b/test/controller.doughnut.tests.js @@ -1,10 +1,5 @@ // Test the bar controller describe('Doughnut controller tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'doughnut', diff --git a/test/controller.line.tests.js b/test/controller.line.tests.js index 70535ace9..9afc9cec0 100644 --- a/test/controller.line.tests.js +++ b/test/controller.line.tests.js @@ -1,10 +1,5 @@ // Test the line controller describe('Line controller tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'line', diff --git a/test/controller.polarArea.tests.js b/test/controller.polarArea.tests.js index 43f200d13..648117a4c 100644 --- a/test/controller.polarArea.tests.js +++ b/test/controller.polarArea.tests.js @@ -1,10 +1,5 @@ // Test the polar area controller describe('Polar area controller tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'polarArea', diff --git a/test/controller.radar.tests.js b/test/controller.radar.tests.js index c99219588..421ff9eb3 100644 --- a/test/controller.radar.tests.js +++ b/test/controller.radar.tests.js @@ -1,9 +1,5 @@ // Test the polar area controller describe('Radar controller tests', function() { - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('Should be constructed', function() { var chart = window.acquireChart({ type: 'radar', diff --git a/test/core.layoutService.tests.js b/test/core.layoutService.tests.js index 024b379e0..860b4b649 100644 --- a/test/core.layoutService.tests.js +++ b/test/core.layoutService.tests.js @@ -1,9 +1,5 @@ // Tests of the scale service describe('Test the layout service', function() { - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should fit a simple chart with 2 scales', function() { var chart = window.acquireChart({ type: 'bar', diff --git a/test/core.legend.tests.js b/test/core.legend.tests.js index ee42b098c..caa35883a 100644 --- a/test/core.legend.tests.js +++ b/test/core.legend.tests.js @@ -1,10 +1,5 @@ // Test the rectangle element describe('Legend block tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('Should be constructed', function() { var legend = new Chart.Legend({}); expect(legend).not.toBe(undefined); diff --git a/test/core.tooltip.tests.js b/test/core.tooltip.tests.js index 82723fb70..21d25ebaa 100755 --- a/test/core.tooltip.tests.js +++ b/test/core.tooltip.tests.js @@ -1,10 +1,5 @@ // Test the rectangle element describe('tooltip tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('Should display in label mode', function() { var chartInstance = window.acquireChart({ type: 'line', diff --git a/test/mockContext.js b/test/mockContext.js index db91fee26..9590b5360 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -158,12 +158,12 @@ }; } - window.addDefaultMatchers = function(jasmine) { + beforeEach(function() { jasmine.addMatchers({ toBeCloseToPixel: toBeCloseToPixel, toEqualOneOf: toEqualOneOf }); - } + }); // Canvas injection helpers var charts = {}; diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index 549424ddd..659ccc727 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -1,8 +1,4 @@ describe('Linear Scale', function() { - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('Should register the constructor with the scale service', function() { var Constructor = Chart.scaleService.getScaleConstructor('linear'); expect(Constructor).not.toBe(undefined); diff --git a/test/scale.logarithmic.tests.js b/test/scale.logarithmic.tests.js index dc5d8b4f6..be6350341 100644 --- a/test/scale.logarithmic.tests.js +++ b/test/scale.logarithmic.tests.js @@ -1,9 +1,4 @@ describe('Logarithmic Scale tests', function() { - - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('should register the constructor with the scale service', function() { var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); expect(Constructor).not.toBe(undefined); diff --git a/test/scale.radialLinear.tests.js b/test/scale.radialLinear.tests.js index ce269b12d..61b6d9689 100644 --- a/test/scale.radialLinear.tests.js +++ b/test/scale.radialLinear.tests.js @@ -1,9 +1,5 @@ // Tests for the radial linear scale used by the polar area and radar charts describe('Test the radial linear scale', function() { - beforeEach(function() { - window.addDefaultMatchers(jasmine); - }); - it('Should register the constructor with the scale service', function() { var Constructor = Chart.scaleService.getScaleConstructor('radialLinear'); expect(Constructor).not.toBe(undefined); diff --git a/test/scale.time.tests.js b/test/scale.time.tests.js index c37910934..5179191ba 100755 --- a/test/scale.time.tests.js +++ b/test/scale.time.tests.js @@ -1,8 +1,6 @@ // Time scale tests describe('Time scale tests', function() { beforeEach(function() { - window.addDefaultMatchers(jasmine); - // Need a time matcher for getValueFromPixel jasmine.addMatchers({ toBeCloseToTime: function() {