From 07854ab31a29f537d3b3a85ed797ebd4cdefefbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Sat, 4 Aug 2018 00:39:11 +0900 Subject: [PATCH] Created Component Level Testing - Completed remaining versions.js testing for full coverage - Added Jasmine Coverage Configuration - Added component test execution to npm test --- .travis.yml | 3 +- package.json | 7 +-- tests/spec/component.json | 8 ++++ tests/spec/component/versions.spec.js | 63 ++++++++++++++++++++++++++ tests/spec/coverage.json | 9 ++++ tests/spec/{jasmine.json => unit.json} | 0 tests/spec/unit/versions.spec.js | 37 --------------- 7 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 tests/spec/component.json create mode 100644 tests/spec/component/versions.spec.js create mode 100644 tests/spec/coverage.json rename tests/spec/{jasmine.json => unit.json} (100%) diff --git a/.travis.yml b/.travis.yml index a915fe10c7..cb32333bf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,13 @@ install: script: - node --version - npm --version + - npm run eslint - npm run unit-tests + - npm run test:component - npm run e2e-tests - open -b com.apple.iphonesimulator - npm run objc-tests - npm run cover - - npm run eslint after_script: - codecov diff --git a/package.json b/package.json index 94daac8a10..dfdfed91d3 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,16 @@ "cordova:platform" ], "scripts": { - "test": "npm run e2e-tests && npm run objc-tests && npm run unit-tests", + "test": "npm run unit-tests && npm run test:component && npm run objc-tests && npm run e2e-tests", + "test:component": "jasmine --config=tests/spec/component.json", "posttest": "npm run eslint", - "cover": "nyc npm run unit-tests", + "cover": "nyc jasmine --config=tests/spec/coverage.json", "e2e-tests": "jasmine tests/spec/create.spec.js", "objc-tests": "npm run objc-tests-lib && npm run objc-tests-framework", "objc-tests-lib": "xcodebuild test -workspace tests/cordova-ios.xcworkspace -scheme CordovaLibTests -destination \"platform=iOS Simulator,name=iPhone 5\" CONFIGURATION_BUILD_DIR=\"`mktemp -d 2>/dev/null || mktemp -d -t 'cordova-ios'`\"", "objc-tests-framework": "xcodebuild test -workspace tests/cordova-ios.xcworkspace -scheme CordovaFrameworkApp -destination \"platform=iOS Simulator,name=iPhone 5\" CONFIGURATION_BUILD_DIR=\"`mktemp -d 2>/dev/null || mktemp -d -t 'cordova-ios'`\"", "preobjc-tests": "tests/scripts/killsim.js", - "unit-tests": "jasmine --config=tests/spec/jasmine.json", + "unit-tests": "jasmine --config=tests/spec/unit.json", "eslint": "eslint bin tests" }, "author": "Apache Software Foundation", diff --git a/tests/spec/component.json b/tests/spec/component.json new file mode 100644 index 0000000000..d8a708abe3 --- /dev/null +++ b/tests/spec/component.json @@ -0,0 +1,8 @@ +{ + "spec_dir": "tests/spec", + "spec_files": [ + "component/**/*[sS]pec.js" + ], + "stopSpecOnExpectationFailure": false, + "random": false +} diff --git a/tests/spec/component/versions.spec.js b/tests/spec/component/versions.spec.js new file mode 100644 index 0000000000..fbc8dc25a8 --- /dev/null +++ b/tests/spec/component/versions.spec.js @@ -0,0 +1,63 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +var rewire = require('rewire'); +var versions = rewire('../../../bin/templates/scripts/cordova/lib/versions'); + +// These tests can not run on windows. +if (process.platform === 'darwin') { + describe('versions', function () { + describe('get_tool_version method', () => { + it('should not have found tool by name.', (done) => { + versions.get_tool_version('unknown').catch((error) => { + expect(error).toContain('is not valid tool name'); + done(); + }); + }); + + it('should find xcodebuild version.', (done) => { + versions.get_tool_version('xcodebuild').then((version) => { + expect(version).not.toBe(undefined); + done(); + }); + }); + + it('should find ios-sim version.', (done) => { + versions.get_tool_version('ios-sim').then((version) => { + expect(version).not.toBe(undefined); + done(); + }); + }); + + it('should find ios-deploy version.', (done) => { + versions.get_tool_version('ios-deploy').then((version) => { + expect(version).not.toBe(undefined); + done(); + }); + }); + + it('should find pod version.', (done) => { + versions.get_tool_version('pod').then((version) => { + expect(version).not.toBe(undefined); + done(); + }); + }); + }); + }); +} diff --git a/tests/spec/coverage.json b/tests/spec/coverage.json new file mode 100644 index 0000000000..2ec72bbfc8 --- /dev/null +++ b/tests/spec/coverage.json @@ -0,0 +1,9 @@ +{ + "spec_dir": "tests/spec", + "spec_files": [ + "unit/**/*[sS]pec.js", + "component/**/*[sS]pec.js" + ], + "stopSpecOnExpectationFailure": false, + "random": false +} diff --git a/tests/spec/jasmine.json b/tests/spec/unit.json similarity index 100% rename from tests/spec/jasmine.json rename to tests/spec/unit.json diff --git a/tests/spec/unit/versions.spec.js b/tests/spec/unit/versions.spec.js index e128d49625..e921820f6f 100644 --- a/tests/spec/unit/versions.spec.js +++ b/tests/spec/unit/versions.spec.js @@ -50,42 +50,5 @@ if (process.platform === 'darwin') { }); }); }); - - describe('get_tool_version method', () => { - it('should not have found tool by name.', (done) => { - versions.get_tool_version('unknown').catch((error) => { - expect(error).toContain('is not valid tool name'); - done(); - }); - }); - - it('should find xcodebuild version.', (done) => { - versions.get_tool_version('xcodebuild').then((version) => { - expect(version).not.toBe(undefined); - done(); - }); - }); - - it('should find ios-sim version.', (done) => { - versions.get_tool_version('ios-sim').then((version) => { - expect(version).not.toBe(undefined); - done(); - }); - }); - - it('should find ios-deploy version.', (done) => { - versions.get_tool_version('ios-deploy').then((version) => { - expect(version).not.toBe(undefined); - done(); - }); - }); - - it('should find pod version.', (done) => { - versions.get_tool_version('pod').then((version) => { - expect(version).not.toBe(undefined); - done(); - }); - }); - }); }); }