Skip to content

Commit

Permalink
Finished upgrading dependencies.
Browse files Browse the repository at this point in the history
Karma modified so that only vendor files are referenced from the build directory.
Karma config moved to buildConfig/.

Unit tests were added for the automated vendor services/

Also fixed a bug that has broken audio download links.
  • Loading branch information
atruskie committed Oct 30, 2014
1 parent 7f3d10e commit 13c3f88
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 15 deletions.
8 changes: 5 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,19 +788,21 @@ module.exports = function (grunt) {

/**
* In order to avoid having to specify manually the files needed for karma to
* run, we use grunt to manage the list for us. The `karma/*` files are
* run, we use grunt to manage the list for us. The `buildConfig/karma-unit.tpl.js` files are
* compiled as grunt templates for use by Karma. Yay!
*/
grunt.registerMultiTask('karmaconfig', 'Process karma config templates', function () {
var jsFiles = filterForJS(this.filesSrc);
var usePhantomJs = grunt.config('usePhantomJs');
var vendorFiles = grunt.config("vendor_files.js");

grunt.file.copy('karma/karma-unit.tpl.js', grunt.config('build_dir') + '/karma-unit.js', {
grunt.file.copy('buildConfig/karma-unit.tpl.js', grunt.config('build_dir') + '/karma-unit.js', {
process: function (contents, path) {
return grunt.template.process(contents, {
data: {
usePhantomJs: usePhantomJs,
scripts: jsFiles
scripts: jsFiles,
vendorFiles: vendorFiles,
}
});
}
Expand Down
11 changes: 9 additions & 2 deletions karma/karma-unit.tpl.js → buildConfig/karma-unit.tpl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = function (config) {

var fileJson = '[<% scripts.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]',
vendorJson = '[<% vendorFiles.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]',
browserToUse = "<%= usePhantomJs ? 'PhantomJS' : 'Chrome' %>",
useLineCov = "<%= usePhantomJs %>" === "true";

Expand All @@ -12,7 +13,7 @@ module.exports = function (config) {
/**
* From where to look for files, starting with the location of this file.
*/
configObject.basePath = '../build';
configObject.basePath = '../';

/**
* This is the list of file patterns to load into the browser during testing.
Expand All @@ -22,9 +23,15 @@ module.exports = function (config) {
"vendor/jasmine-expect/dist/jasmine-matchers.js"
].concat(JSON.parse(fileJson).concat([
'src/**/*.js',
'../src/**/*.spec.js'
'src/**/*.spec.js'
]));

// HACK!: use vendor files out of the build directory since they undergo a transform on build
var transformedVendorFiles = JSON.parse(vendorJson);
configObject.files = configObject.files.map(function (value) {
return transformedVendorFiles.indexOf(value) >= 0 ? "build/" + value : value;
});

configObject.exclude = [
'src/assets/**/*.js'
];
Expand Down
4 changes: 0 additions & 4 deletions src/app/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ describe('AppCtrl', function() {
it('should pass a dummy test', function() {
expect(true).toBeTruthy();
});

it("checks bowser is on the global scope", function() {
expect(window.bowser).toBeDefined();
});
});
12 changes: 6 additions & 6 deletions src/app/listen/listen.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ <h1 id="chunkInfo" class="row">
ng-href="{{model.media.spectrogram.url}}"
title="Download the spectrogram">Spectrogram</a>&nbsp;|&nbsp;
<a target="_blank"
ng-class="{disabled: !model.media.availableAudioFormats['wav'].url}"
ng-href="{{model.media.availableAudioFormats['wav'].url}}"
title="{{ model.media.availableAudioFormats['wav'].url && 'Download the .wav file' || 'This file format is not available' }}"
ng-class="{disabled: !model.media.available.audio['wav'].url}"
ng-href="{{model.media.available.audio['wav'].url}}"
title="{{ model.media.available.audio['wav'].url && 'Download the .wav file' || 'This file format is not available' }}"
>Audio (WAV)</a>&nbsp;|&nbsp;
<a target="_blank"
ng-class="{disabled: !model.media.availableAudioFormats['mp3'].url}"
ng-href="{{model.media.availableAudioFormats['mp3'].url}}"
title="{{ model.media.availableAudioFormats['mp3'].url && 'Download the .mp3 file' || 'This file format is not available' }}"
ng-class="{disabled: !model.media.available.audio['mp3'].url}"
ng-href="{{model.media.available.audio['mp3'].url}}"
title="{{ model.media.available.audio['mp3'].url && 'Download the .mp3 file' || 'This file format is not available' }}"
>Audio (MP3)</a>&nbsp;|&nbsp;
<a target="_blank"
ng-class="{disabled: !downloadAnnotationsLink}"
Expand Down
50 changes: 50 additions & 0 deletions src/components/services/vendorServices/externals.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe("The vendor services", function () {

beforeEach(module("bawApp.vendorServices"));

beforeEach(inject([function () {


}]));

it("checks that bawApp.vendorServices.auto has been created", function () {
var vendorServicesAutoModule = angular.module("bawApp.vendorServices.auto");
expect(vendorServicesAutoModule).not.toBeNull();
});

it("checks bowser is not on the global scope", function () {
expect(window.bowser).not.toBeDefined();
});

it("checks the bowser auto service was created",
inject(["bowser", function (bowser) {
expect(bowser).toBeDefined();
}]));

it("checks moment is not on the global scope", function () {
expect(window.moment).not.toBeDefined();
});

it("checks the moment auto service was created",
inject(["moment", function (moment) {
expect(moment).toBeDefined();
}]));

it("checks lodash is not on the global scope", function () {
expect(window._).not.toBeDefined();
});

it("checks the lodash auto service was created",
inject(["lodash", function (lodash) {
expect(lodash).toBeDefined();
}]));

it("checks humanizeDuration is not on the global scope", function () {
expect(window.humanizeDuration).not.toBeDefined();
});

it("checks the humanizeDuration auto service was created",
inject(["humanize-duration", function (humanizeDuration) {
expect(humanizeDuration).toBeDefined();
}]));
});

0 comments on commit 13c3f88

Please sign in to comment.