Skip to content

Commit

Permalink
Merge pull request #52 from alechenninger/unit-tests
Browse files Browse the repository at this point in the history
Run Javascript unit tests in maven build (fixes #39)
  • Loading branch information
luan-cestari committed Mar 3, 2015
2 parents a834dd9 + 71b5d8d commit a6fc718
Show file tree
Hide file tree
Showing 31 changed files with 1,169 additions and 817 deletions.
3 changes: 3 additions & 0 deletions data-mgmt/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "src/main/webapp/bower_components/"
}
2 changes: 2 additions & 0 deletions data-mgmt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node/
node_modules/
17 changes: 3 additions & 14 deletions data-mgmt/src/main/webapp/bower.json → data-mgmt/bower.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
{
"name": "lightblue-data-mgmt",
"version": "0.1.0-SNAPSHOT",
"authors": [
"Alec Henninger <ahenning@redhat.com>"
],
"description": "lightblue data management application",
"main": "index.html",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": ">=1.3.0",
"angular-mocks": "~1.3.x",
"jquery": "1.11.1",
"bootstrap": "~3.2.x",
"angular-route": "~1.3.x",
Expand All @@ -25,6 +11,9 @@
"jsoneditor": "~3.1.2",
"angular-strap": "~2.1.6"
},
"devDependencies": {
"angular-mocks": "~1.3.4"
},
"resolutions": {
"angular": ">=1.3.0"
}
Expand Down
15 changes: 15 additions & 0 deletions data-mgmt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "lightblue-data-mgmt",
"scripts": {
"tdd": "karma start src/test/resources/karma.conf.js"
},
"devDependencies": {
"jasmine-core": "^2.1.2",
"karma": "^0.12.28",
"karma-chrome-launcher": "^0.1.5",
"karma-cli": "0.0.4",
"karma-firefox-launcher": "^0.1.3",
"karma-jasmine": "^0.3.1",
"karma-phantomjs-launcher": "^0.1.4"
}
}
37 changes: 37 additions & 0 deletions data-mgmt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,43 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.20</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<!-- See nodejs.org for latest -->
<nodeVersion>v0.10.33</nodeVersion>
<!-- See changelogs of latest node version for npm version used -->
<npmVersion>1.4.28</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>javascript tests</id>
<goals>
<goal>karma</goal>
</goals>
<configuration>
<karmaConfPath>src/test/resources/karma.conf.ci.js</karmaConfPath>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "angular-mocks",
"version": "1.3.2",
"version": "1.3.4",
"main": "./angular-mocks.js",
"ignore": [],
"dependencies": {
"angular": "1.3.2"
"angular": "1.3.4"
},
"homepage": "https://github.com/angular/bower-angular-mocks",
"_release": "1.3.2",
"_release": "1.3.4",
"_resolution": {
"type": "version",
"tag": "v1.3.2",
"commit": "3195cfb260587620e66e2f66fb04a86542f414cf"
"tag": "v1.3.4",
"commit": "15dd7c6bed51102fadc68ce02fcced2a8391ef34"
},
"_source": "git://github.com/angular/bower-angular-mocks.git",
"_target": "~1.3.x",
"_originalSource": "angular-mocks"
"_target": "~1.3.4",
"_originalSource": "angular-mocks",
"_direct": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license AngularJS v1.3.2
* @license AngularJS v1.3.4
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
Expand Down Expand Up @@ -117,7 +117,7 @@ angular.mock.$Browser = function() {
self.defer.now += delay;
} else {
if (self.deferredFns.length) {
self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
self.defer.now = self.deferredFns[self.deferredFns.length - 1].time;
} else {
throw new Error('No deferred tasks to be flushed');
}
Expand Down Expand Up @@ -428,7 +428,7 @@ angular.mock.$LogProvider = function() {
});
});
if (errors.length) {
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or "+
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or " +
"an expected log message was not checked and removed:");
errors.push('');
throw new Error(errors.join('\n---------\n'));
Expand Down Expand Up @@ -461,17 +461,17 @@ angular.mock.$LogProvider = function() {
* @returns {promise} A promise which will be notified on each iteration.
*/
angular.mock.$IntervalProvider = function() {
this.$get = ['$rootScope', '$q',
function($rootScope, $q) {
this.$get = ['$browser', '$rootScope', '$q', '$$q',
function($browser, $rootScope, $q, $$q) {
var repeatFns = [],
nextRepeatId = 0,
now = 0;

var $interval = function(fn, delay, count, invokeApply) {
var deferred = $q.defer(),
promise = deferred.promise,
iteration = 0,
skipApply = (angular.isDefined(invokeApply) && !invokeApply);
var iteration = 0,
skipApply = (angular.isDefined(invokeApply) && !invokeApply),
deferred = (skipApply ? $$q : $q).defer(),
promise = deferred.promise;

count = (angular.isDefined(count)) ? count : 0;
promise.then(null, null, fn);
Expand All @@ -494,7 +494,11 @@ angular.mock.$IntervalProvider = function() {
}
}

if (!skipApply) $rootScope.$apply();
if (skipApply) {
$browser.defer.flush();
} else {
$rootScope.$apply();
}
}

repeatFns.push({
Expand Down Expand Up @@ -581,10 +585,10 @@ function jsonStringToDate(string) {
tzMin = int(match[9] + match[11]);
}
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
date.setUTCHours(int(match[4]||0) - tzHour,
int(match[5]||0) - tzMin,
int(match[6]||0),
int(match[7]||0));
date.setUTCHours(int(match[4] || 0) - tzHour,
int(match[5] || 0) - tzMin,
int(match[6] || 0),
int(match[7] || 0));
return date;
}
return string;
Expand Down Expand Up @@ -663,7 +667,7 @@ angular.mock.TzDate = function(offset, timestamp) {
}

var localOffset = new Date(timestamp).getTimezoneOffset();
self.offsetDiff = localOffset*60*1000 - offset*1000*60*60;
self.offsetDiff = localOffset * 60 * 1000 - offset * 1000 * 60 * 60;
self.date = new Date(timestamp + self.offsetDiff);

self.getTime = function() {
Expand Down Expand Up @@ -815,7 +819,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
animate.queue.push({
event: method,
element: arguments[0],
options: arguments[arguments.length-1],
options: arguments[arguments.length - 1],
args: arguments
});
return $delegate[method].apply($delegate, arguments);
Expand Down Expand Up @@ -1770,7 +1774,7 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
}

var length = queue.length;
for (var i=0;i<length;i++) {
for (var i = 0; i < length; i++) {
queue[i]();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "angular-mocks",
"version": "1.3.2",
"version": "1.3.4",
"main": "./angular-mocks.js",
"ignore": [],
"dependencies": {
"angular": "1.3.2"
"angular": "1.3.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-mocks",
"version": "1.3.2",
"version": "1.3.4",
"description": "AngularJS mocks for testing",
"main": "angular-mocks.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "angular-route",
"version": "1.3.2",
"version": "1.3.4",
"main": "./angular-route.js",
"ignore": [],
"dependencies": {
"angular": "1.3.2"
"angular": "1.3.4"
},
"homepage": "https://github.com/angular/bower-angular-route",
"_release": "1.3.2",
"_release": "1.3.4",
"_resolution": {
"type": "version",
"tag": "v1.3.2",
"commit": "2d45594a73d6b64e3e8e464bbd84369ff72b788a"
"tag": "v1.3.4",
"commit": "f5b509929b7d7e779ead20512fd5d405829baf3e"
},
"_source": "git://github.com/angular/bower-angular-route.git",
"_target": "~1.3.x",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license AngularJS v1.3.2
* @license AngularJS v1.3.4
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
Expand Down Expand Up @@ -41,7 +41,7 @@ var ngRouteModule = angular.module('ngRoute', ['ng']).
*/
function $RouteProvider() {
function inherit(parent, extra) {
return angular.extend(new (angular.extend(function() {}, {prototype:parent}))(), extra);
return angular.extend(Object.create(parent), extra);
}

var routes = {};
Expand Down Expand Up @@ -151,16 +151,19 @@ function $RouteProvider() {
if (angular.isUndefined(routeCopy.reloadOnSearch)) {
routeCopy.reloadOnSearch = true;
}
if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) {
routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch;
}
routes[path] = angular.extend(
routeCopy,
path && pathRegExp(path, routeCopy)
);

// create redirection for trailing slashes
if (path) {
var redirectPath = (path[path.length-1] == '/')
? path.substr(0, path.length-1)
: path +'/';
var redirectPath = (path[path.length - 1] == '/')
? path.substr(0, path.length - 1)
: path + '/';

routes[redirectPath] = angular.extend(
{redirectTo: path},
Expand All @@ -171,6 +174,17 @@ function $RouteProvider() {
return this;
};

/**
* @ngdoc property
* @name $routeProvider#caseInsensitiveMatch
* @description
*
* A boolean property indicating if routes defined
* using this provider should be matched using a case sensitive
* algorithm. Defaults to `false`.
*/
this.caseInsensitiveMatch = false;

/**
* @param path {string} path
* @param opts {Object} options
Expand Down Expand Up @@ -639,11 +653,11 @@ function $RouteProvider() {
*/
function interpolate(string, params) {
var result = [];
angular.forEach((string||'').split(':'), function(segment, i) {
angular.forEach((string || '').split(':'), function(segment, i) {
if (i === 0) {
result.push(segment);
} else {
var segmentMatch = segment.match(/(\w+)(.*)/);
var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/);
var key = segmentMatch[1];
result.push(params[key]);
result.push(segmentMatch[2] || '');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a6fc718

Please sign in to comment.