Skip to content

Commit

Permalink
Start testing the AngularJS application
Browse files Browse the repository at this point in the history
Make the client-side code more modular to make it easier to test.
Only data-sources code and related services are concerned for now.

There are two new AngularJS modules:
- app.core contains services shared by all code (connection and pager)
- app.data-sources contains controllers and define routes related to
data sources.

AngularJS application code is tested using Karma, Jasmine and jsdom.
Server code is still tested using mocha, and mocha is updated to v6 to
be able to configure it in .mocharc.js

connection service has dropped its callback parameter. All existing
calls are now using the returned Promise.
It also dropped its showLoader parameter which was useless.

Unused Constants service is removed.

The new code follows some advices from this guide:
https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md
  • Loading branch information
jajm committed Apr 19, 2019
1 parent e24598e commit 758a338
Show file tree
Hide file tree
Showing 39 changed files with 3,287 additions and 984 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Expand Up @@ -4,6 +4,7 @@ module.exports = {
browser: true,
jquery: true,
mocha: true,
jasmine: true,
},
globals: {
// defined in server.js
Expand All @@ -23,6 +24,9 @@ module.exports = {
angular: false,
noty: false,
layerUtils: false,

// Angular mocks
inject: false,
},
rules: {
'no-console': 'off',
Expand Down
5 changes: 5 additions & 0 deletions .mocharc.js
@@ -0,0 +1,5 @@
module.exports = {
"no-colors": true,
"spec": 'test/server/**/*.js',
"timeout": 10000,
};
88 changes: 88 additions & 0 deletions karma.conf.js
@@ -0,0 +1,88 @@
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: [
'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery-validation/dist/jquery.validate.min.js',
'node_modules/components-jqueryui/jquery-ui.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/angular/angular.min.js',
'node_modules/angular-sanitize/angular-sanitize.min.js',
'node_modules/angular-draganddrop/angular-draganddrop.min.js',
'node_modules/angular-route/angular-route.min.js',
'node_modules/noty/js/noty/packaged/jquery.noty.packaged.min.js',
'node_modules/angular-uuid2/dist/angular-uuid2.min.js',
'node_modules/angular-vs-repeat/src/angular-vs-repeat.min.js',
'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js',
'node_modules/moment/min/moment.min.js',
'node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.js',
'node_modules/numeral/min/numeral.min.js',
'node_modules/angular-ui-tree/dist/angular-ui-tree.min.js',
'node_modules/angular-file-saver/dist/angular-file-saver.bundle.min.js',
'node_modules/angular-ui-bootstrap/ui-bootstrap-tpls.min.js',
'node_modules/angular-ui-sortable/dist/sortable.min.js',
'node_modules/ui-select/dist/select.min.js',
'node_modules/angular-loading-overlay/dist/angular-loading-overlay.js',
'node_modules/angular-xeditable/dist/js/xeditable.min.js',
'node_modules/ng-file-upload/dist/ng-file-upload-shim.min.js',
'node_modules/ng-file-upload/dist/ng-file-upload.min.js',
'node_modules/angular-bootstrap-colorpicker/js/bootstrap-colorpicker-module.min.js',
'node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js',
'node_modules/angular-gettext/dist/angular-gettext.min.js',
'node_modules/cynteka-pivot-table-jquery/dist/jquery.cy-pivot.min.js',
'public/js/webapp.js',
'public/js/core/core.module.js',
'public/js/data-sources/data-sources.module.js',
'public/js/**/*.js',
'node_modules/angular-mocks/angular-mocks.js',
'test/client/**/*.js',
],

// list of files / patterns 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: ['jsdom'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};

0 comments on commit 758a338

Please sign in to comment.