Automatically expose custom Jasmine matchers

This commit is contained in:
Simon Brunel 2016-09-08 23:29:39 +02:00
parent 8254331eef
commit 4901471445
14 changed files with 2 additions and 60 deletions

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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);

View File

@ -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',

View File

@ -158,12 +158,12 @@
};
}
window.addDefaultMatchers = function(jasmine) {
beforeEach(function() {
jasmine.addMatchers({
toBeCloseToPixel: toBeCloseToPixel,
toEqualOneOf: toEqualOneOf
});
}
});
// Canvas injection helpers
var charts = {};

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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() {