Skip to content

Commit

Permalink
test: include Shortcut tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Jun 10, 2020
1 parent 6f6f81f commit 8616fb7
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/Resources/ti.ui.shortcut.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2020 by Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';

const should = require('./utilities/assertions');

describe('Titanium.UI.Shortcut', () => {

it('Ti.UI.Shortcut', () => {
should(Ti.UI.Shortcut).not.be.undefined();
});

it('createShortcut', () => {
should(Ti.UI.createShortcutItem).not.be.undefined();
should(Ti.UI.createShortcut).be.a.Function();

// Create shortcut.
const shortcut = Ti.UI.createShortcut();
should(shortcut).be.a.Object();

// Verify `apiName`.
should(shortcut).have.readOnlyProperty('apiName').which.is.a.String();
should(shortcut.apiName).be.eql('Ti.UI.Shortcut');

// ONLY compatible with Android 7.1+, end test early.
if (Ti.Platform.osname === 'Android') {
const version = Ti.Platform.version.split('.');
if (parseInt(`${version[0]}${version[1]}`) < 71) {
return;
}
}

// Verify `add()`.
should(shortcut.add).not.be.undefined();
should(shortcut.add).be.a.Function();

// Verify `remove()`.
should(shortcut.remove).not.be.undefined();
should(shortcut.remove).be.a.Function();

// Verify `removeAll()`.
should(shortcut.removeAll).not.be.undefined();
should(shortcut.removeAll).be.a.Function();
});
});
48 changes: 48 additions & 0 deletions tests/Resources/ti.ui.shortcutitem.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2020 by Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';

const should = require('./utilities/assertions');

describe('Titanium.UI.ShortcutItem', () => {

it('Ti.UI.ShortcutItem', () => {
should(Ti.UI.ShortcutItem).not.be.undefined();
});

it('createShortcutItem', () => {
should(Ti.UI.createShortcutItem).not.be.undefined();
should(Ti.UI.createShortcutItem).be.a.Function();

// Create shortcut item.
const item = Ti.UI.createShortcutItem({
id: 'test_shortcut',
title: 'Test Shortcut',
description: 'Test shortcut description',
data: { test_data: 'data' }
});
should(item).be.a.Object();

// Verify `apiName`.
should(item).have.readOnlyProperty('apiName').which.is.a.String();
should(item.apiName).be.eql('Ti.UI.ShortcutItem');

// Verify `id`.
should(item.id).be.eql('test_shortcut');

// Verify `title`.
should(item.title).be.eql('Test Shortcut');

// Verify `description`.
should(item.description).be.eql('Test shortcut description');

// Verify `data`.
should(item.data).be.a.Object();
});
});

0 comments on commit 8616fb7

Please sign in to comment.