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

Commit fdf9bf7

Browse files
committed
feat(unit-tests): Basic unit tests
see #2
1 parent b773b9e commit fdf9bf7

12 files changed

Lines changed: 72 additions & 7 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ __build__/**
5252
/doc/
5353

5454
# IDE #
55+
.babelrc
5556
.idea/
5657
*.swp
5758
*.tgz

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
.vscode
3+
.babelrc
34
build.xcconfig
45
app/
56
demo/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ script:
1616
- export ANDROID_HOME=/usr/local/opt/android-sdk
1717
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools
1818
- npm run build
19+
- npm run test
1920
before_install:
2021
- export ANDROID_HOME=/usr/local/opt/android-sdk
2122
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ node('nativescript') {
2626
}
2727

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

3333
stage('Publish NPM snapshot') {

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "0.1.0",
44
"description": "Register custom URLs for your NativeScript app",
55
"scripts": {
6-
"clean": "npm i rimraf && rimraf node_modules lib hooks platforms target '**/*.js' '**/*.js.map' 'app/**/*.js' 'app/**/*.js.map' && npm i",
6+
"clean": "npm i rimraf && rimraf node_modules lib hooks platforms target '*.js' '*.js.map' 'app/**/*.js' 'app/**/*.js.map' && npm i",
77
"prebuild": "npm run tslint",
88
"build": "npm run tsc",
99
"tsc": "tsc",
1010
"tslint": "tslint \"*.ts\"",
11-
"test": "echo \"Error: no test specified\" && exit 1",
11+
"test": "npm run tslint && npm run jasmine",
12+
"jasmine": "babel-node spec/run.js",
1213
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
1314
"changelog:add": "git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md'",
1415
"release:pre": "npm run clean && npm run test",
@@ -25,14 +26,22 @@
2526
"ios": "2.3.0"
2627
}
2728
},
28-
"dependencies": {
29-
},
29+
"dependencies": {},
3030
"peerDependencies": {
3131
"tns-core-modules": "^2.3.1"
3232
},
3333
"devDependencies": {
3434
"@types/jasmine": "2.5.45",
35+
"babel-cli": "6.24.0",
36+
"babel-core": "6.24.0",
37+
"babel-preset-es2015": "6.24.0",
38+
"babel-traverse": "6.18.0",
39+
"babel-types": "6.18.0",
3540
"conventional-changelog-cli": "1.3.1",
41+
"jasmine": "2.5.3",
42+
"jasmine-core": "2.5.2",
43+
"jasmine-reporters": "2.2.0",
44+
"mockery": "2.0.0",
3645
"nativescript-dev-typescript": "0.3.7",
3746
"rimraf": "2.6.1",
3847
"tns-core-modules": "2.5.1",

spec/mocks/general.mock.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import mockery from "mockery";
2+
mockery.enable();
3+
mockery.warnOnUnregistered(false);
4+
mockery.registerMock("application", {
5+
android:{
6+
on:function (){
7+
8+
}
9+
},
10+
AndroidApplication:{
11+
activityResumedEvent:{}
12+
}
13+
});
14+
mockery.registerMock("platform", {});
15+
mockery.registerMock("utils/utils", {});

spec/run.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Jasmine from 'jasmine';
2+
import jasmineReporters from 'jasmine-reporters';
3+
var jasmine = new Jasmine();
4+
var junitReporter = new jasmineReporters.JUnitXmlReporter({
5+
savePath: './target/junit-report',
6+
consolidateAll: false
7+
});
8+
jasmine.loadConfigFile('spec/support/jasmine.json');
9+
jasmine.addReporter(junitReporter);
10+
jasmine.execute();

spec/support/jasmine.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"spec_dir": "spec",
3+
"spec_files": [
4+
"**/*[sS]pec.js"
5+
],
6+
"helpers": [
7+
"helpers/**/*.js"
8+
],
9+
"stopSpecOnExpectationFailure": false,
10+
"random": false
11+
}

spec/urlhandler.android.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import './mocks/general.mock';
2+
import {
3+
handleOpenURL
4+
} from '../urlhandler.android';
5+
6+
describe('Android', function () {
7+
it('handleOpenURL', function () {
8+
expect(handleOpenURL).toBeDefined();
9+
});
10+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<testsuites>
3+
<testsuite name="Android" timestamp="2017-03-14T09:07:37" hostname="localhost" time="0.002" errors="0" tests="1" skipped="0" disabled="0" failures="0">
4+
<testcase classname="Android" name="handleOpenURL" time="0.002" />
5+
</testsuite>
6+
</testsuites>

0 commit comments

Comments
 (0)