Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1072 from alphagov/node-6-jasmine
Browse files Browse the repository at this point in the history
馃挭 KILLING IT with the Jasmine unit tests 馃挭
  • Loading branch information
leelongmore committed Oct 17, 2017
2 parents c9639e6 + f1b74b0 commit 13fe55c
Show file tree
Hide file tree
Showing 46 changed files with 7,400 additions and 5,860 deletions.
23 changes: 17 additions & 6 deletions Gruntfile.js
Expand Up @@ -80,20 +80,26 @@ module.exports = function (grunt) {
spotlight: {
src: ['app/**/*.js'],
options: {
helpers: ['spec/helpers/*.js'],
helpers: [
'spec/helpers/*.js',
'!spec/helpers/server-*.js'
],
specs: [
'spec/shared/**/spec.*.js',
'spec/client/**/spec.*.js'
'spec/client/**/*.js',
'!spec/client/preprocessors/spec.visualisation_fallback.js' // fallback images (expect async)
],
template: 'spec/index.html',
keepRunner: true
keepRunner: false,
vendor: [
'app/vendor/jquery.js',
'app/vendor/require.js'
]
}
}
},
// Sets up server-side Jasmine node tests
jasmine_node: {
legacy: {
verbose: false,
src: './spec/helpers',
options: {
specFolders: [
Expand All @@ -102,6 +108,7 @@ module.exports = function (grunt) {
],
useHelpers: true,
specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
helperNameMatcher: '^(?!client-).+', // load only helpers *not* containing 'client-' in their filename
match: '.*',
useRequireJs: 'spec/requirejs-setup.js',
verbose: false,
Expand All @@ -114,14 +121,14 @@ module.exports = function (grunt) {
}
},
server: {
verbose: false,
src: './spec/server-pure',
options: {
specFolders: [
'./spec/server-pure'
],
useHelpers: true,
specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
helperNameMatcher: '^(?!client-).+', // load only helpers *not* containing 'client-' in their filename
match: '.*',
verbose: false,
jUnit: {
Expand All @@ -140,6 +147,7 @@ module.exports = function (grunt) {
src: ['app/client/**/*.js', 'spec/client/**/*.js'],
options: {
reporter: require('jshint-stylish'),
reporterOutput: "",
jshintrc: true,
config: './node_modules/performanceplatform-js-style-configs/.jshintrc-browser.json'
}
Expand All @@ -149,6 +157,7 @@ module.exports = function (grunt) {
'!app/client/**/*.js', '!spec/client/**/*.js'],
options: {
reporter: require('jshint-stylish'),
reporterOutput: "",
jshintrc: true,
config: './node_modules/performanceplatform-js-style-configs/.jshintrc-node.json'
}
Expand Down Expand Up @@ -365,7 +374,9 @@ module.exports = function (grunt) {
'copy:assets',
'sass:development',
'digest',
'jasmine',
'jasmine_node',
'jshint'
]);

grunt.registerTask('test:all', [
Expand Down
4 changes: 2 additions & 2 deletions app/client/views/graph/bar.js
Expand Up @@ -36,7 +36,7 @@ function (require, Component) {
blockWidth: function () {
var x0 = this.scales.x(this.graph.getXPos(0, 0));
var x1 = this.scales.x(this.graph.getXPos(0, 1));
return x1 - x0;
return x1 - x0 > 0 ? x1 - x0 : 0;
},

barWidth: function () {
Expand Down Expand Up @@ -166,4 +166,4 @@ function (require, Component) {
});

return InterleavedBar;
});
});
6 changes: 3 additions & 3 deletions app/extensions/views/table.js
Expand Up @@ -49,13 +49,13 @@ function (View, Formatters) {
cls += (this.options.hideHeader === true) ? ' table-no-header' : '';
caption = (this.options.caption) ? '<caption class="visuallyhidden">' + this.options.caption + '</caption>' : '';
this.$el.append('<table class="' + cls + '">' + caption + '</table>');
this.$table = this.$('table')
this.$table = this.$('table');
},

render: function () {
this.prepareTable();
this.$table.append(this.renderHead())
this.$table.append(this.renderBody())
this.$table.append(this.renderHead());
this.$table.append(this.renderBody());
},

renderHead: function () {
Expand Down
2 changes: 1 addition & 1 deletion app/vendor/jquery-deparam.js
Expand Up @@ -94,4 +94,4 @@

return obj;
};
})(jQuery);
})(jQuery);

0 comments on commit 13fe55c

Please sign in to comment.