aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/gulpfile.js18
-rw-r--r--vid-app-common/jest.config.js16
-rw-r--r--vid-app-common/package.json28
-rwxr-xr-xvid-app-common/pom.xml31
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js1
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js33
-rw-r--r--vid-app-common/test-config.js4
7 files changed, 130 insertions, 1 deletions
diff --git a/vid-app-common/gulpfile.js b/vid-app-common/gulpfile.js
new file mode 100644
index 000000000..898f84fe4
--- /dev/null
+++ b/vid-app-common/gulpfile.js
@@ -0,0 +1,18 @@
+var gulp = require("gulp");
+var jest = require("jest");
+
+// -------------- Run Jest Tests --------------
+
+gulp.task("test", function() {
+ return jest.runCLI({}, ".")
+ .then((result) => {
+ if (!result.results.success){
+ console.error("Execution of js tests failed with status 1");
+ process.exit(1);
+ }
+ });
+});
+
+// -------------- Default Task --------------
+
+gulp.task("default", gulp.parallel(["test"])); \ No newline at end of file
diff --git a/vid-app-common/jest.config.js b/vid-app-common/jest.config.js
new file mode 100644
index 000000000..e9ca59b11
--- /dev/null
+++ b/vid-app-common/jest.config.js
@@ -0,0 +1,16 @@
+module.exports = {
+ verbose: true,
+ roots: [
+ "<rootDir>/src/main/webapp/app"
+ ],
+ modulePaths: [
+ "<rootDir>/src/main/webapp/app/vid/external"
+ ],
+ setupFilesAfterEnv: ["<rootDir>/test-config.js"],
+ collectCoverage: true,
+ collectCoverageFrom: [
+ "src/**/*.js",
+ "!**/node_modules/**",
+ "!**/vendor/**"
+ ]
+}; \ No newline at end of file
diff --git a/vid-app-common/package.json b/vid-app-common/package.json
new file mode 100644
index 000000000..fb8d5d762
--- /dev/null
+++ b/vid-app-common/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "vid-app-common",
+ "version": "4.0.0-SNAPSHOT",
+ "dependencies": {
+ "angular-bootstrap-multiselect": "^1.1.11",
+ "angular-feature-flags": "1.6.1",
+ "angular-moment": "^1.3.0",
+ "components-bootstrap": "3.3.7",
+ "glyphicons-only-bootstrap": "^1.0.1",
+ "lodash": "^4.17.11",
+ "moment": "^2.24.0",
+ "ng-file-upload": "^12.2.13"
+ },
+ "scripts": {
+ "prebuild": "npm install",
+ "build": "gulp"
+ },
+ "devDependencies": {
+ "angular-mocks": "1.2.19",
+ "gulp": "^4.0.0",
+ "gulp-inject": "^5.0.2",
+ "gulp-jest": "^4.0.2",
+ "gulp-uglify": "^3.0.1",
+ "jest": "^24.0.0",
+ "jest-mock": "^24.0.0",
+ "stream-series": "^0.1.1"
+ }
+}
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 7cd30a21f..1ea069137 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -37,6 +37,9 @@
<kotlin.version>1.3.11</kotlin.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
+ <eirslett.version>1.6</eirslett.version>
+ <node.version>v6.16.0</node.version>
+
</properties>
@@ -158,6 +161,34 @@
</plugin>
<plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>${eirslett.version}</version>
+ <executions>
+ <execution>
+ <id>install node and npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <nodeVersion>${node.version}</nodeVersion>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm run-script build</id>
+ <configuration>
+ <arguments>run-script build</arguments>
+ </configuration>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
index bb3acad1b..3bf05ea1a 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
@@ -1583,7 +1583,6 @@ appDS2.controller('TreeCtrl', ['$scope', function ($scope) {
$scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL);
};
-
}]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
new file mode 100644
index 000000000..4af9a2982
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
@@ -0,0 +1,33 @@
+require('./aaiSubscriberController');
+const jestMock = require('jest-mock');
+
+describe('TreeCtrl testing', () => {
+ let $scope;
+ beforeEach(
+ angular.mock.module('app')
+ );
+
+ beforeEach(inject(function (_$controller_) {
+ $scope = {};
+ _$controller_('TreeCtrl', {
+ $scope: $scope
+ });
+ }));
+
+ test('Verify expandAll calls broadcast with expand-all parameter', () => {
+ // given
+ const broadcast = jestMock.fn();
+ $scope.$broadcast = broadcast;
+ FIELD = {
+ ID: {
+ ANGULAR_UI_TREE_EXPANDALL: "angular-ui-tree:expand-all"
+ }
+ };
+ // when
+ $scope.expandAll();
+ // then
+ expect(broadcast).toHaveBeenCalledWith("angular-ui-tree:expand-all");
+ });
+
+});
+
diff --git a/vid-app-common/test-config.js b/vid-app-common/test-config.js
new file mode 100644
index 000000000..32bac3873
--- /dev/null
+++ b/vid-app-common/test-config.js
@@ -0,0 +1,4 @@
+require("angular-feature-flags/demo/vendor/angular.min");
+require("angular-mocks");
+
+global.appDS2=angular.module("app", []);