Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
feat(unit-tests): Basic unit tests
Browse files Browse the repository at this point in the history
see #2
  • Loading branch information
hypery2k committed Mar 14, 2017
1 parent b773b9e commit fdf9bf7
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ __build__/**
/doc/

# IDE #
.babelrc
.idea/
*.swp
*.tgz
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.vscode
.babelrc
build.xcconfig
app/
demo/
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ script:
- export ANDROID_HOME=/usr/local/opt/android-sdk
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools
- npm run build
- npm run test
before_install:
- export ANDROID_HOME=/usr/local/opt/android-sdk
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ node('nativescript') {
}

stage('Test') {
//sh "PLATFORM=android npm run test"
//junit 'test/android/build/reports/TEST-*.xml'
sh "npm run test"
junit 'target/junit-report/junitresults-*.xml'
}

stage('Publish NPM snapshot') {
Expand Down
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "0.1.0",
"description": "Register custom URLs for your NativeScript app",
"scripts": {
"clean": "npm i rimraf && rimraf node_modules lib hooks platforms target '**/*.js' '**/*.js.map' 'app/**/*.js' 'app/**/*.js.map' && npm i",
"clean": "npm i rimraf && rimraf node_modules lib hooks platforms target '*.js' '*.js.map' 'app/**/*.js' 'app/**/*.js.map' && npm i",
"prebuild": "npm run tslint",
"build": "npm run tsc",
"tsc": "tsc",
"tslint": "tslint \"*.ts\"",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "npm run tslint && npm run jasmine",
"jasmine": "babel-node spec/run.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"changelog:add": "git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md'",
"release:pre": "npm run clean && npm run test",
Expand All @@ -25,14 +26,22 @@
"ios": "2.3.0"
}
},
"dependencies": {
},
"dependencies": {},
"peerDependencies": {
"tns-core-modules": "^2.3.1"
},
"devDependencies": {
"@types/jasmine": "2.5.45",
"babel-cli": "6.24.0",
"babel-core": "6.24.0",
"babel-preset-es2015": "6.24.0",
"babel-traverse": "6.18.0",
"babel-types": "6.18.0",
"conventional-changelog-cli": "1.3.1",
"jasmine": "2.5.3",
"jasmine-core": "2.5.2",
"jasmine-reporters": "2.2.0",
"mockery": "2.0.0",
"nativescript-dev-typescript": "0.3.7",
"rimraf": "2.6.1",
"tns-core-modules": "2.5.1",
Expand Down
15 changes: 15 additions & 0 deletions spec/mocks/general.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import mockery from "mockery";
mockery.enable();
mockery.warnOnUnregistered(false);
mockery.registerMock("application", {
android:{
on:function (){

}
},
AndroidApplication:{
activityResumedEvent:{}
}
});
mockery.registerMock("platform", {});
mockery.registerMock("utils/utils", {});
10 changes: 10 additions & 0 deletions spec/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Jasmine from 'jasmine';
import jasmineReporters from 'jasmine-reporters';
var jasmine = new Jasmine();
var junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: './target/junit-report',
consolidateAll: false
});
jasmine.loadConfigFile('spec/support/jasmine.json');
jasmine.addReporter(junitReporter);
jasmine.execute();
11 changes: 11 additions & 0 deletions spec/support/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
10 changes: 10 additions & 0 deletions spec/urlhandler.android.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import './mocks/general.mock';
import {
handleOpenURL
} from '../urlhandler.android';

describe('Android', function () {
it('handleOpenURL', function () {
expect(handleOpenURL).toBeDefined();
});
});
6 changes: 6 additions & 0 deletions target/junit-report/junitresults-Android.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="Android" timestamp="2017-03-14T09:07:37" hostname="localhost" time="0.002" errors="0" tests="1" skipped="0" disabled="0" failures="0">
<testcase classname="Android" name="handleOpenURL" time="0.002" />
</testsuite>
</testsuites>
2 changes: 1 addition & 1 deletion urlhandler.android.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as application from 'application';
import { getCallback, extractAppURL } from './urlhandler.common';

export { handleOpenURL } from './urlhandler.common';
declare var android: any;

application.android.on(application.AndroidApplication.activityResumedEvent, (args) => {
Expand Down
1 change: 1 addition & 0 deletions urlhandler.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import * as application from 'application';
import { getCallback, extractAppURL } from './urlhandler.common';
export { handleOpenURL } from './urlhandler.common';

export class UrlHandlerAppDelegate extends UIResponder implements UIApplicationDelegate {

Expand Down

0 comments on commit fdf9bf7

Please sign in to comment.