Skip to content

Commit 7063462

Browse files
sgtcoolguyewanharris
authored andcommitted
test: add super simple unit tests
1 parent c7cb899 commit 7063462

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

test/unit/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const host = Ti.Platform.osname === 'android' ? '10.0.2.2' : 'localhost';
2+
const port = '3210';
3+
module.exports.url = `http://${host}:${port}`;

test/unit/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const testsContext = require.context('./specs', true, /\.spec\.js$/);
2+
3+
testsContext.keys().forEach(testsContext);

test/unit/karma.unit.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
module.exports = config => {
4+
config.set({
5+
basePath: '../..',
6+
frameworks: [ 'jasmine' ],
7+
files: [
8+
'test/unit/specs/**/*spec.js'
9+
],
10+
reporters: [ 'mocha', 'junit' ],
11+
plugins: [
12+
'karma-*'
13+
],
14+
titanium: {
15+
sdkVersion: config.sdkVersion || '9.2.0.GA'
16+
},
17+
customLaunchers: {
18+
ios: {
19+
base: 'Titanium',
20+
browserName: 'iOS Emulator',
21+
displayName: 'ios',
22+
platform: 'ios'
23+
}
24+
},
25+
browsers: [ 'ios' ],
26+
client: {
27+
jasmine: {
28+
random: false
29+
}
30+
},
31+
singleRun: true,
32+
retryLimit: 0,
33+
concurrency: 1,
34+
captureTimeout: 300000,
35+
logLevel: config.LOG_DEBUG
36+
});
37+
};

test/unit/specs/.eslintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": [ "axway/env-titanium", "plugin:jasmine/recommended"],
3+
"plugins": [ "jasmine" ],
4+
"env": {
5+
"node": true,
6+
"jasmine": true
7+
},
8+
"parserOptions": {
9+
"ecmaVersion": 2015,
10+
"sourceType": "script"
11+
},
12+
"globals": {
13+
"Ti": false,
14+
"Titanium": false,
15+
"__filename": false,
16+
"__dirname": false,
17+
"kroll": false
18+
}
19+
}

test/unit/specs/module.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const URLSession = require('com.appcelerator.urlSession');
2+
3+
describe('com.appcelerator.urlSession', () => {
4+
it('can be required', () => {
5+
expect(URLSession).toBeDefined();
6+
});
7+
8+
it('.moduleId', () => {
9+
expect(URLSession.moduleId).toBe('com.appcelerator.urlSession');
10+
});
11+
12+
describe('methods', () => {
13+
describe('#finishTasksAndInvalidate()', () => {
14+
it('is a function', () => {
15+
expect(URLSession.finishTasksAndInvalidate).toEqual(jasmine.any(Function));
16+
});
17+
});
18+
19+
describe('#invalidateAndCancel()', () => {
20+
// eslint-disable-next-line jasmine/no-spec-dupes
21+
it('is a function', () => {
22+
expect(URLSession.invalidateAndCancel).toEqual(jasmine.any(Function));
23+
});
24+
});
25+
26+
describe('#backgroundDownloadTaskWithURL()', () => {
27+
// eslint-disable-next-line jasmine/no-spec-dupes
28+
it('is a function', () => {
29+
expect(URLSession.backgroundDownloadTaskWithURL).toEqual(jasmine.any(Function));
30+
});
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)