aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2018-10-16 17:47:54 +0200
committersebdet <sebastien.determe@intl.att.com>2018-10-22 09:31:31 +0200
commite442200bcfed06d52821ec735850ad817ef69dfc (patch)
tree022a360f7e36bff30c17dd8174f879b4fc5ec994
parent78fd76a76a1ba19fea56ca33b6d700e365b9d508 (diff)
Add javascript test
Add first javascript test and Jest Framework to execute the javascript testing on the clamp UI Issue-ID: CLAMP-235 Change-Id: Ie3475ebf450d0d7d4cd01de9c04eed44176932a2 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
-rw-r--r--pom.xml65
-rw-r--r--src/test/javascript/demo.test.js53
-rw-r--r--src/test/javascript/package.json46
3 files changed, 163 insertions, 1 deletions
diff --git a/pom.xml b/pom.xml
index 7e748a6cf..7f4f5d9e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,13 +69,15 @@
<camel.version>2.22.0</camel.version>
<springboot.version>2.0.3.RELEASE</springboot.version>
- <sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
<sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>${project.build.directory}/coverage-reports/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
+ <sonar.javascript.lcov.reportPaths>${project.build.directory}/clamp-ui/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
<sonar.projectVersion>${project.version}</sonar.projectVersion>
+ <sonar.sources>src/main,${project.build.directory}/clamp-ui/designer</sonar.sources>
+ <sonar.exclusions>src/main/resources/**,**/clamp-ui/designer/lib/*</sonar.exclusions>
<docker.push.registry>localhost:5000</docker.push.registry>
<docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
@@ -619,6 +621,21 @@
<filtering>false</filtering>
<targetPath>example/sdc</targetPath>
</testResource>
+
+ <!-- Copy the NPM package.json for CLAMP UI javascript testing framework -->
+ <testResource>
+ <directory>src/test/javascript</directory>
+ <includes>
+ <include>**/**.json</include>
+ </includes>
+ <filtering>true</filtering>
+ <targetPath>${project.build.directory}/clamp-ui</targetPath>
+ </testResource>
+ <testResource>
+ <directory>src/main/resources/META-INF/resources/designer</directory>
+ <filtering>false</filtering>
+ <targetPath>${project.build.directory}/clamp-ui/designer</targetPath>
+ </testResource>
</testResources>
<resources>
<!-- For AAF folder maven should not try to filter Keystores/Truststores ...
@@ -1070,6 +1087,52 @@
<artifactId>versions-maven-plugin</artifactId>
<version>1.3.1</version>
</plugin>
+
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.6</version>
+ <configuration>
+ <installDirectory>${project.build.directory}/clamp-ui</installDirectory>
+ <workingDirectory>${project.build.directory}/clamp-ui</workingDirectory>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>install_node_and_npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <nodeVersion>v8.11.1</nodeVersion>
+ <npmVersion>5.6.0</npmVersion>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm_install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm_test</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <arguments>run-script test:coverage</arguments>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/src/test/javascript/demo.test.js b/src/test/javascript/demo.test.js
new file mode 100644
index 000000000..c088957f9
--- /dev/null
+++ b/src/test/javascript/demo.test.js
@@ -0,0 +1,53 @@
+require('jquery/dist/jquery.min.js');
+require('angular/angular.min.js');
+require('angular-mocks/angular-mocks.js');
+require('angular-route/angular-route.min.js');
+require('angular-resource/angular-resource.min.js');
+require('angular-cookies/angular-cookies.min.js');
+require('angular-animate/angular-animate.min.js');
+require('angular-sanitize/angular-sanitize.min.js');
+require('angular-touch/angular-touch.min.js');
+require('popper.js/dist/umd/popper.min.js');
+require('bootstrap/dist/js/bootstrap.min.js');
+require('angular-ui-bootstrap/dist/ui-bootstrap-tpls.js');
+require('angular-loading-bar/src/loading-bar.js');
+require('angular-dialog-service/dist/dialogs.js');
+require('scripts/app.js');
+require('scripts/DashboardCtrl.js');
+
+
+describe('Dashboard ctrl tests', function() {
+
+ beforeEach(angular.mock.module('clds-app'));
+
+ var $controllerService;
+
+ beforeEach(angular.mock.inject(function(_$controller_) {
+ $controllerService = _$controller_;
+ }));
+
+ describe('$scope.showPalette', function() {
+
+ it('test showPalette', function() {
+
+ var $scopeTest = {};
+ var $rootScopeTest = {};
+ var $resourceTest = {};
+ var $httpTest = {};
+ var $timeoutTest = {};
+ var $locationTest = {};
+ var $intervalTest = function(){};
+ var $controllerDashboard = $controllerService('DashboardCtrl', {
+ '$scope' : $scopeTest,
+ '$rootScope' : $rootScopeTest,
+ '$resource' : $resourceTest,
+ '$http' : $httpTest,
+ '$timeout' : $timeoutTest,
+ '$location' : $locationTest,
+ '$interval' : $intervalTest
+ });
+ $scopeTest.showPalette();
+ expect($rootScopeTest.isModel).toEqual(true);
+ });
+ });
+}); \ No newline at end of file
diff --git a/src/test/javascript/package.json b/src/test/javascript/package.json
new file mode 100644
index 000000000..a2f0cd2eb
--- /dev/null
+++ b/src/test/javascript/package.json
@@ -0,0 +1,46 @@
+{
+ "scripts": {
+ "test": "jest",
+ "test:watch": "jest --watch",
+ "test:coverage": "jest --coverage"
+ },
+ "jest": {
+ "verbose": true,
+ "coverageDirectory": "${project.build.directory}/clamp-ui/coverage",
+ "collectCoverageFrom": [
+ "**/designer/**/*.{js,jsx}",
+ "!**/designer/lib/**"
+ ],
+ "rootDir": "${project.build.directory}/clamp-ui",
+ "roots": [
+ "${project.basedir}/src/test/javascript/",
+ "<rootDir>/designer/"
+ ],
+ "moduleDirectories": [
+ "${project.build.directory}/clamp-ui/node/node_modules",
+ "${project.build.directory}/clamp-ui/node_modules",
+ "<rootDir>/designer"
+ ],
+ "coverageReporters": [
+ "lcov"
+ ]
+ },
+ "devDependencies": {
+ "angular": "1.3.2",
+ "angular-resource": "1.3.2",
+ "angular-cookies": "1.3.2",
+ "angular-route": "1.3.2",
+ "angular-mocks": "1.3.2",
+ "angular-animate": "1.3.2",
+ "angular-sanitize": "1.3.2",
+ "angular-touch": "1.3.2",
+ "angular-dialog-service": "5.3.0",
+ "angular-loading-bar": "0.9.0",
+ "jquery": "3.3.1",
+ "popper.js": "1.14.4",
+ "bootstrap": "4.1.1",
+ "angular-ui-bootstrap": "2.5.6",
+ "jest": "^23.6.0",
+ "jest-cli": "^21.2.1"
+ }
+}