Skip to content

Commit 74cb452

Browse files
committed
add first tests on highchartTable
1 parent 3456a13 commit 74cb452

File tree

5 files changed

+247
-1
lines changed

5 files changed

+247
-1
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- '0.11'
4+
env:
5+
- JQUERY_VERSION=1.11.3 HIGHCHARTS_VERSION=2.2.4
6+
- JQUERY_VERSION=1.11.1 HIGHCHARTS_VERSION=2.2.4

karma.conf-ci.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Karma configuration
2+
// Generated on Wed Nov 11 2015 19:12:34 GMT+0100 (CET)
3+
4+
module.exports = function(config) {
5+
6+
var jqueryVersion = process.env.JQUERY_VERSION;
7+
var highchartsVersion = process.env.HIGHCHARTS_VERSION;
8+
9+
// Browsers to run on Sauce Labs
10+
var customLaunchers = {
11+
'SL_Chrome': {
12+
base: 'SauceLabs',
13+
browserName: 'chrome'
14+
},
15+
'SL_InternetExplorer': {
16+
base: 'SauceLabs',
17+
browserName: 'internet explorer',
18+
version: '10'
19+
},
20+
'SL_FireFox': {
21+
base: 'SauceLabs',
22+
browserName: 'firefox',
23+
version: '37'
24+
}
25+
};
26+
27+
config.set({
28+
29+
// base path that will be used to resolve all patterns (eg. files, exclude)
30+
basePath: '',
31+
32+
33+
// frameworks to use
34+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
35+
frameworks: ['jasmine'],
36+
37+
38+
// list of files / patterns to load in the browser
39+
files: [
40+
'http://code.jquery.com/jquery-' + jqueryVersion + '.min.js',
41+
'http://code.highcharts.com/' + highchartsVersion + '/highcharts.js',
42+
'jquery.highchartTable.js',
43+
'tests/*Spec.js'
44+
],
45+
46+
47+
// list of files to exclude
48+
exclude: [
49+
],
50+
51+
52+
// preprocess matching files before serving them to the browser
53+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
54+
preprocessors: {
55+
},
56+
57+
58+
// test results reporter to use
59+
// possible values: 'dots', 'progress'
60+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
61+
reporters: ['progress', 'saucelabs'],
62+
63+
64+
// web server port
65+
port: 9876,
66+
67+
68+
// enable / disable colors in the output (reporters and logs)
69+
colors: true,
70+
71+
72+
// level of logging
73+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
74+
logLevel: config.LOG_INFO,
75+
76+
77+
// enable / disable watching file and executing tests whenever any file changes
78+
autoWatch: true,
79+
80+
sauceLabs: {
81+
testName: 'HighchartTable tests / jquery ' + jqueryVersion + ' / highcharts ' + highchartsVersion
82+
},
83+
84+
captureTimeout: 120000,
85+
customLaunchers: customLaunchers,
86+
87+
// start these browsers
88+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
89+
browsers: Object.keys(customLaunchers),
90+
91+
92+
// Continuous Integration mode
93+
// if true, Karma captures browsers, runs the tests and exits
94+
singleRun: true,
95+
96+
// Concurrency level
97+
// how many browser should be started simultanous
98+
concurrency: Infinity
99+
})
100+
}

karma.conf.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Karma configuration
2+
// Generated on Wed Nov 11 2015 19:12:34 GMT+0100 (CET)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13+
frameworks: ['jasmine'],
14+
15+
16+
// list of files / patterns to load in the browser
17+
files: [
18+
'http://code.jquery.com/jquery-1.11.3.min.js',
19+
'http://code.highcharts.com/2.2.4/highcharts.js',
20+
'jquery.highchartTable.js',
21+
'tests/*Spec.js'
22+
],
23+
24+
25+
// list of files to exclude
26+
exclude: [
27+
],
28+
29+
30+
// preprocess matching files before serving them to the browser
31+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
32+
preprocessors: {
33+
},
34+
35+
36+
// test results reporter to use
37+
// possible values: 'dots', 'progress'
38+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
39+
reporters: ['progress'],
40+
41+
42+
// web server port
43+
port: 9876,
44+
45+
46+
// enable / disable colors in the output (reporters and logs)
47+
colors: true,
48+
49+
50+
// level of logging
51+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
52+
logLevel: config.LOG_INFO,
53+
54+
55+
// enable / disable watching file and executing tests whenever any file changes
56+
autoWatch: false,
57+
58+
59+
// start these browsers
60+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
61+
browsers: ['Chrome'],
62+
63+
64+
// Continuous Integration mode
65+
// if true, Karma captures browsers, runs the tests and exits
66+
singleRun: true,
67+
68+
// Concurrency level
69+
// how many browser should be started simultanous
70+
concurrency: Infinity
71+
})
72+
}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"name": "highchartTable",
33
"version": "1.1.0",
4+
"scripts": {
5+
"test": "./node_modules/karma/bin/karma start karma.conf-ci.js"
6+
},
47
"devDependencies": {
5-
"grunt-bump": "0.0.13"
8+
"grunt-bump": "0.0.13",
9+
"jasmine-core": "^2.3.4",
10+
"karma": "^0.13.15",
11+
"karma-chrome-launcher": "^0.2.1",
12+
"karma-jasmine": "^0.3.6",
13+
"karma-sauce-launcher": "^0.3.0"
614
}
715
}

tests/baseSpec.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
describe("Base test", function() {
3+
4+
var fixture;
5+
6+
7+
beforeEach(function() {
8+
var htmlContent = ' <table class="highchart" data-graph-container-before="1" data-graph-type="column" style="display:none">' +
9+
'<caption>Example of title</caption>' +
10+
'<thead>' +
11+
' <tr>' +
12+
' <th>Month</th>' +
13+
' <th>Sales</th>' +
14+
' </tr>' +
15+
' </thead>' +
16+
' <tbody>' +
17+
' <tr>' +
18+
' <td>January</td>' +
19+
' <td>8000</td>' +
20+
' </tr>' +
21+
' <tr>' +
22+
' <td>February</td>' +
23+
' <td>12000</td>' +
24+
' </tr>' +
25+
' <tr>' +
26+
' <td>March</td>' +
27+
' <td>18000</td>' +
28+
' </tr>' +
29+
' </tbody>' +
30+
' </table>';
31+
32+
$('#fixture').remove();
33+
$('body').append(htmlContent);
34+
});
35+
36+
37+
it("Simple table", function() {
38+
39+
var beforeRenderCalled = false;
40+
41+
$('table')
42+
.bind('highchartTable.beforeRender', function(event, highChartConfig) {
43+
beforeRenderCalled = true;
44+
expect(highChartConfig.title.text).toBe("Example of title");
45+
expect(highChartConfig.series[0].type).toBe("column");
46+
expect(highChartConfig.series[0].data[0].name).toBe('8000');
47+
expect(highChartConfig.series[0].data[0].y).toBe(8000);
48+
expect(highChartConfig.series[0].data[1].name).toBe('12000');
49+
expect(highChartConfig.series[0].data[1].y).toBe(12000);
50+
expect(highChartConfig.series[0].data[2].name).toBe('18000');
51+
expect(highChartConfig.series[0].data[2].y).toBe(18000);
52+
})
53+
.highchartTable()
54+
;
55+
56+
expect(beforeRenderCalled).toBe(true);
57+
});
58+
});
59+
60+

0 commit comments

Comments
 (0)