From 74cb45263012aaa372ee77ce5e98a2456b7438f2 Mon Sep 17 00:00:00 2001 From: Adrien Gallou Date: Sat, 14 Nov 2015 01:15:58 +0100 Subject: [PATCH] add first tests on highchartTable --- .travis.yml | 6 +++ karma.conf-ci.js | 100 ++++++++++++++++++++++++++++++++++++++++++++++ karma.conf.js | 72 +++++++++++++++++++++++++++++++++ package.json | 10 ++++- tests/baseSpec.js | 60 ++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 karma.conf-ci.js create mode 100644 karma.conf.js create mode 100644 tests/baseSpec.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..765671d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - '0.11' +env: + - JQUERY_VERSION=1.11.3 HIGHCHARTS_VERSION=2.2.4 + - JQUERY_VERSION=1.11.1 HIGHCHARTS_VERSION=2.2.4 diff --git a/karma.conf-ci.js b/karma.conf-ci.js new file mode 100644 index 0000000..64f93b3 --- /dev/null +++ b/karma.conf-ci.js @@ -0,0 +1,100 @@ +// Karma configuration +// Generated on Wed Nov 11 2015 19:12:34 GMT+0100 (CET) + +module.exports = function(config) { + + var jqueryVersion = process.env.JQUERY_VERSION; + var highchartsVersion = process.env.HIGHCHARTS_VERSION; + + // Browsers to run on Sauce Labs + var customLaunchers = { + 'SL_Chrome': { + base: 'SauceLabs', + browserName: 'chrome' + }, + 'SL_InternetExplorer': { + base: 'SauceLabs', + browserName: 'internet explorer', + version: '10' + }, + 'SL_FireFox': { + base: 'SauceLabs', + browserName: 'firefox', + version: '37' + } + }; + + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'http://code.jquery.com/jquery-' + jqueryVersion + '.min.js', + 'http://code.highcharts.com/' + highchartsVersion + '/highcharts.js', + 'jquery.highchartTable.js', + 'tests/*Spec.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress', 'saucelabs'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + sauceLabs: { + testName: 'HighchartTable tests / jquery ' + jqueryVersion + ' / highcharts ' + highchartsVersion + }, + + captureTimeout: 120000, + customLaunchers: customLaunchers, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: Object.keys(customLaunchers), + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultanous + concurrency: Infinity + }) +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..fb0d04d --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,72 @@ +// Karma configuration +// Generated on Wed Nov 11 2015 19:12:34 GMT+0100 (CET) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'http://code.jquery.com/jquery-1.11.3.min.js', + 'http://code.highcharts.com/2.2.4/highcharts.js', + 'jquery.highchartTable.js', + 'tests/*Spec.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultanous + concurrency: Infinity + }) +} diff --git a/package.json b/package.json index f2219ef..c6fa33e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,15 @@ { "name": "highchartTable", "version": "1.1.0", + "scripts": { + "test": "./node_modules/karma/bin/karma start karma.conf-ci.js" + }, "devDependencies": { - "grunt-bump": "0.0.13" + "grunt-bump": "0.0.13", + "jasmine-core": "^2.3.4", + "karma": "^0.13.15", + "karma-chrome-launcher": "^0.2.1", + "karma-jasmine": "^0.3.6", + "karma-sauce-launcher": "^0.3.0" } } diff --git a/tests/baseSpec.js b/tests/baseSpec.js new file mode 100644 index 0000000..dc50b39 --- /dev/null +++ b/tests/baseSpec.js @@ -0,0 +1,60 @@ + +describe("Base test", function() { + + var fixture; + + + beforeEach(function() { + var htmlContent = ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' '; + + $('#fixture').remove(); + $('body').append(htmlContent); + }); + + + it("Simple table", function() { + + var beforeRenderCalled = false; + + $('table') + .bind('highchartTable.beforeRender', function(event, highChartConfig) { + beforeRenderCalled = true; + expect(highChartConfig.title.text).toBe("Example of title"); + expect(highChartConfig.series[0].type).toBe("column"); + expect(highChartConfig.series[0].data[0].name).toBe('8000'); + expect(highChartConfig.series[0].data[0].y).toBe(8000); + expect(highChartConfig.series[0].data[1].name).toBe('12000'); + expect(highChartConfig.series[0].data[1].y).toBe(12000); + expect(highChartConfig.series[0].data[2].name).toBe('18000'); + expect(highChartConfig.series[0].data[2].y).toBe(18000); + }) + .highchartTable() + ; + + expect(beforeRenderCalled).toBe(true); + }); +}); + +