Skip to content

Commit

Permalink
Created Component Level Testing
Browse files Browse the repository at this point in the history
- Completed remaining versions.js testing for full coverage
- Added Jasmine Coverage Configuration
- Added component test execution to npm test
  • Loading branch information
erisu committed Jan 16, 2019
1 parent 55b702f commit 07854ab
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions tests/spec/component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"spec_dir": "tests/spec",
"spec_files": [
"component/**/*[sS]pec.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
63 changes: 63 additions & 0 deletions tests/spec/component/versions.spec.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
});
}
9 changes: 9 additions & 0 deletions tests/spec/coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"spec_dir": "tests/spec",
"spec_files": [
"unit/**/*[sS]pec.js",
"component/**/*[sS]pec.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
File renamed without changes.
37 changes: 0 additions & 37 deletions tests/spec/unit/versions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
});
}

0 comments on commit 07854ab

Please sign in to comment.