improve unit testing
currently the only problem is that phantomjs is unable to parse the js files fix test exec on travis env
This commit is contained in:
parent
75b9cc60df
commit
d3901cc286
|
@ -1514,6 +1514,12 @@
|
|||
"resolved": "https://registry.npmjs.org/angular/-/angular-1.8.2.tgz",
|
||||
"integrity": "sha512-IauMOej2xEe7/7Ennahkbb5qd/HFADiNuLSESz9Q27inmi32zB0lnAsFeLEWcox3Gd1F6YhNd1CP7/9IukJ0Gw=="
|
||||
},
|
||||
"angular-mocks": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/angular-mocks/-/angular-mocks-1.8.2.tgz",
|
||||
"integrity": "sha512-I5L3P0l21HPdVsP4A4qWmENt4ePjjbkDFdAzOaM7QiibFySbt14DptPbt2IjeG4vFBr4vSLbhIz8Fk03DISl8Q==",
|
||||
"dev": true
|
||||
},
|
||||
"angular-route": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/angular-route/-/angular-route-1.8.2.tgz",
|
||||
|
@ -5272,6 +5278,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"jquery-linkify": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery-linkify/-/jquery-linkify-2.2.1.tgz",
|
||||
"integrity": "sha1-yXMApcqmaHeHfg05y5Jdg4XaZEs="
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
|
@ -5564,6 +5575,17 @@
|
|||
"phantomjs-prebuilt": "^2.1.7"
|
||||
}
|
||||
},
|
||||
"karma-webpack": {
|
||||
"version": "5.0.0-alpha.3.0",
|
||||
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-5.0.0-alpha.3.0.tgz",
|
||||
"integrity": "sha512-ID2xYs8CnvPPbOCdj/ridr0w9l0vmuZem7hJP7yEXVQ94KhFG++IrTH1qj+EUO4ymll3ECLCw6N+nQIY/Nvj1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "^7.1.3",
|
||||
"minimatch": "^3.0.4",
|
||||
"webpack-merge": "^4.1.5"
|
||||
}
|
||||
},
|
||||
"kew": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz",
|
||||
|
@ -8595,6 +8617,11 @@
|
|||
"integrity": "sha512-8lBMSkFZuAK7gGF8LswsXmir8eX8d2AAMOnxSDWjKBx/fBR6MypQjs78m6ML9zQVp1/hD4TBdfeMZMC7nW1TAA==",
|
||||
"dev": true
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.10.2",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz",
|
||||
"integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg=="
|
||||
},
|
||||
"unicode-canonical-property-names-ecmascript": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"devDependencies": {
|
||||
"@babel/core": "^7.12.9",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
"angular-mocks": "^1.8.2",
|
||||
"babel-loader": "^8.2.2",
|
||||
"bower": "^1.8.8",
|
||||
"copy-webpack-plugin": "^6.3.2",
|
||||
|
@ -21,6 +22,7 @@
|
|||
"karma-jasmine": "~3.1",
|
||||
"karma-junit-reporter": "~2.0",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"karma-webpack": "^5.0.0-alpha.3.0",
|
||||
"linkifyjs": "^2.1.9",
|
||||
"protractor": "^7.0.0",
|
||||
"shelljs": "^0.8.4",
|
||||
|
@ -31,11 +33,9 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"postinstall": "bower install -p",
|
||||
"minify": " uglifyjs js/localstorage.js js/weechat.js js/irc-utils.js js/glowingbear.js js/settings.js js/utils.js js/notifications.js js/filters.js js/handlers.js js/connection.js js/file-change.js js/imgur-drop-directive.js js/whenscrolled-directive.js js/inputbar.js js/plugin-directive.js js/websockets.js js/models.js js/bufferResume.js js/plugins.js js/imgur.js -c -m -o min.js --source-map url='min.js.map'",
|
||||
"lint": "jshint src/js/*.js test/unit/*.js",
|
||||
"prestart": "npm install",
|
||||
"start": "webpack serve",
|
||||
"pretest": "npm install",
|
||||
"test": "karma start test/karma.conf.js",
|
||||
"test-single-run": "karma start test/karma.conf.js --single-run",
|
||||
"preupdate-webdriver": "npm install",
|
||||
|
@ -55,6 +55,8 @@
|
|||
"angular-sanitize": "^1.8.2",
|
||||
"angular-touch": "^1.8.2",
|
||||
"favico.js": "^0.3.10",
|
||||
"jquery-linkify": "^2.2.1",
|
||||
"underscore": "^1.10.2",
|
||||
"zlibjs": "^0.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
./node_modules/.bin/jshint js/*.js test/unit/*.js
|
||||
npm run lint
|
||||
npm test
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<link rel="shortcut icon" type="image/png" href="assets/img/favicon.png" >
|
||||
<link href="css/glowingbear.css" rel="stylesheet" media="screen">
|
||||
<link href="css/themes/dark.css" rel="stylesheet" media="screen" id="themeCSS" />
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.10.2/underscore-min.js" integrity="sha512-HKvDCFVKg8ZPGjecy6on7UECEpE76Y86h3GaE4JMCz+deFWdjcW/tWnh0hCfaBvURvlOa9f5CNVzt7EFkulYbw==" crossorigin="anonymous"></script>
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.10.2/underscore-min.js" integrity="sha512-HKvDCFVKg8ZPGjecy6on7UECEpE76Y86h3GaE4JMCz+deFWdjcW/tWnh0hCfaBvURvlOa9f5CNVzt7EFkulYbw==" crossorigin="anonymous"></script> -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/lib/js/emojione.min.js" integrity="sha256-9cBkVeU53NiJ9/BdcJta3HbERAmf5X9DE2WvL8V+gDs=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery-linkify/2.1.9/linkify.min.js" integrity="sha512-kxj7VjlzsQgiku2vbRcZI0FJ0dXmPsiRLugiRxJrCROusKHaFfX/hGDD1/L/R0Y+xI8zlA2B5nm6USapz7nQbg==" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery-linkify/2.1.9/linkify-string.min.js" integrity="sha512-CMBjJdVIcw7zafkE+uedZCnw6r4ABU1Fev5xA7db0D097/NzhO6Ajo2kdZFOQ+y0kg9sE/t44bPAwuuNhUVIcQ==" crossorigin="anonymous"></script>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var weechat = angular.module('weechat');
|
||||
|
@ -235,6 +234,4 @@ weechat.filter('codify', function() {
|
|||
return rr;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
})();
|
||||
});
|
|
@ -2,9 +2,10 @@
|
|||
* This file contains the plugin definitions
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
import * as _ from "underscore";
|
||||
|
||||
var plugins = angular.module('plugins', []);
|
||||
|
||||
/*
|
||||
|
@ -594,4 +595,3 @@ plugins.factory('userPlugins', function() {
|
|||
|
||||
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -8,7 +8,10 @@ import "angular-touch";
|
|||
|
||||
import "./js/localstorage.js";
|
||||
import "./js/irc-utils.js";
|
||||
import "./js/bufferResume.js";
|
||||
import "./js/models.js";
|
||||
import "./js/plugins.js";
|
||||
import "./js/websockets.js";
|
||||
import "./js/glowingbear.js";
|
||||
import "./js/settings.js";
|
||||
import "./js/utils.js";
|
||||
|
@ -20,8 +23,5 @@ import "./js/imgur-drop-directive.js";
|
|||
import "./js/whenscrolled-directive.js";
|
||||
import "./js/inputbar.js";
|
||||
import "./js/plugin-directive.js";
|
||||
import "./js/websockets.js";
|
||||
import "./js/bufferResume.js";
|
||||
import "./js/models.js";
|
||||
|
||||
import "./js/imgur.js";
|
|
@ -1,53 +1,72 @@
|
|||
module.exports = function(config){
|
||||
const webpackConfig = require('../webpack.config');
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
|
||||
basePath : '../',
|
||||
basePath: '../',
|
||||
|
||||
files : [
|
||||
'bower_components/angular/angular.js',
|
||||
'bower_components/angular-route/angular-route.js',
|
||||
'bower_components/angular-mocks/angular-mocks.js',
|
||||
'bower_components/angular-sanitize/angular-sanitize.js',
|
||||
'bower_components/angular-touch/angular-touch.js',
|
||||
'bower_components/underscore/underscore.js',
|
||||
files: [
|
||||
'node_modules/linkifyjs/dist/linkify.js',
|
||||
'node_modules/linkifyjs/dist/linkify-string.js',
|
||||
'src/js/localstorage.js',
|
||||
'src/js/weechat.js',
|
||||
'src/js/irc-utils.js',
|
||||
'src/js/glowingbear.js',
|
||||
'src/js/utils.js',
|
||||
'src/js/notifications.js',
|
||||
'src/js/filters.js',
|
||||
'src/js/handlers.js',
|
||||
'src/js/connection.js',
|
||||
'src/js/inputbar.js',
|
||||
'src/js/plugin-directive.js',
|
||||
'src/js/websockets.js',
|
||||
'src/js/models.js',
|
||||
'src/js/bufferResume.js',
|
||||
'src/js/plugins.js',
|
||||
'test/unit/**/*.js'
|
||||
'test/unit/main.test.js'
|
||||
],
|
||||
|
||||
autoWatch : true,
|
||||
autoWatch: true,
|
||||
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
browsers : ['PhantomJS'],
|
||||
browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessNoSandbox'],
|
||||
|
||||
singleRun: true,
|
||||
|
||||
plugins : [
|
||||
'karma-phantomjs-launcher',
|
||||
'karma-jasmine',
|
||||
'karma-junit-reporter'
|
||||
],
|
||||
plugins: [
|
||||
'karma-phantomjs-launcher',
|
||||
'karma-jasmine',
|
||||
'karma-junit-reporter',
|
||||
'karma-webpack'
|
||||
],
|
||||
|
||||
junitReporter : {
|
||||
customLaunchers: {
|
||||
ChromeHeadlessNoSandbox: {
|
||||
base: 'ChromeHeadless',
|
||||
flags: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
junitReporter: {
|
||||
outputFile: 'test_out/unit.xml',
|
||||
suite: 'unit'
|
||||
}
|
||||
},
|
||||
|
||||
/* karma-webpack config
|
||||
pass your webpack configuration for karma
|
||||
add `babel-loader` to the webpack configuration to make
|
||||
the ES6+ code in the test files readable to the browser
|
||||
eg. import, export keywords */
|
||||
webpack: {
|
||||
devtool: webpackConfig.devtool,
|
||||
module: webpackConfig.module,
|
||||
optimization: {
|
||||
runtimeChunk: false,
|
||||
splitChunks: false
|
||||
},
|
||||
},
|
||||
|
||||
preprocessors: {
|
||||
//add webpack as preprocessor to support require() in test-suits .js files
|
||||
'./test/unit/*.js': ['webpack'],
|
||||
'./src/**/*.js': ['webpack']
|
||||
},
|
||||
// webpackMiddleware: {
|
||||
// //turn off webpack bash output when run the tests
|
||||
// noInfo: true,
|
||||
// stats: 'errors-only'
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
if(process.env.TRAVIS){
|
||||
config.browsers = ['ChromeHeadlessNoSandbox'];
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
var weechat = angular.module('weechat');
|
||||
"use strict";
|
||||
|
||||
import angular from "angular";
|
||||
|
||||
import "angular-mocks";
|
||||
|
||||
import "../../src/main";
|
||||
|
||||
describe('Filters', function() {
|
||||
beforeEach(module('weechat'));
|
||||
beforeEach(angular.mock.module('weechat'));
|
||||
/*beforeEach(module(function($provide) {
|
||||
$provide.value('version', 'TEST_VER');
|
||||
}));*/
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
import "./filters";
|
||||
import "./plugins";
|
|
@ -1,5 +1,11 @@
|
|||
/* plugins go here */
|
||||
|
||||
import angular from "angular";
|
||||
|
||||
import "angular-mocks";
|
||||
|
||||
import "../../src/main";
|
||||
|
||||
var msg = function(msg) {
|
||||
return {'text': msg };
|
||||
};
|
||||
|
@ -22,10 +28,10 @@ var expectTheseMessagesToContain = function(urls, pluginType, plugins) {
|
|||
};
|
||||
|
||||
describe('filter', function() {
|
||||
beforeEach(module('plugins'));
|
||||
beforeEach(angular.mock.module('plugins'));
|
||||
|
||||
describe('Plugins', function() {
|
||||
beforeEach(module(function($provide) {
|
||||
beforeEach(angular.mock.module(function($provide) {
|
||||
$provide.value('version', 'TEST_VER');
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in New Issue