From bf97ba8aa7d5d83a0ebe45a07d3bd9bb4a2ada42 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Jun 2020 10:16:28 -0400 Subject: [PATCH] test: migrate tests to suite --- tests/Resources/core.runtime.addontest.js | 27 ------- tests/Resources/ti.platform.addontest.js | 23 ------ tests/Resources/ti.test.js | 99 ----------------------- tests/Resources/ti.ui.picker.addontest.js | 84 ------------------- 4 files changed, 233 deletions(-) delete mode 100644 tests/Resources/core.runtime.addontest.js delete mode 100644 tests/Resources/ti.platform.addontest.js delete mode 100644 tests/Resources/ti.test.js delete mode 100644 tests/Resources/ti.ui.picker.addontest.js diff --git a/tests/Resources/core.runtime.addontest.js b/tests/Resources/core.runtime.addontest.js deleted file mode 100644 index 69cf46517b0..00000000000 --- a/tests/Resources/core.runtime.addontest.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.windowsBroken('Core', () => { - describe('Runtime', () => { - describe('Static Method Reference', () => { - - // Reference static method. - const createProxy = Ti.createProxy; - should(createProxy).be.a.Function; - - // Attempt to call static method. - const result = createProxy({}); - should(result).be.a.Object; - }); - }); -}); diff --git a/tests/Resources/ti.platform.addontest.js b/tests/Resources/ti.platform.addontest.js deleted file mode 100644 index 5d5397dd8c2..00000000000 --- a/tests/Resources/ti.platform.addontest.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Appcelerator Titanium Mobile - * Copyright (c) 2011-Present by Appcelerator, 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'; -var should = require('./utilities/assertions'), - utilities = require('./utilities/utilities'); - -describe('Titanium.Platform', function () { - - it.ios('#openURL(url, callback)', function (finish) { - Ti.Platform.openURL('randomapp://', e => finish()); - }); - - it.ios('#openURL(url, options, callback)', function (finish) { - Ti.Platform.openURL('randomapp://', {}, e => finish()); - }); - -}); diff --git a/tests/Resources/ti.test.js b/tests/Resources/ti.test.js deleted file mode 100644 index d5f711c377e..00000000000 --- a/tests/Resources/ti.test.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Appcelerator Titanium Mobile - * Copyright (c) 2011-Present by Appcelerator, 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', () => { - it('apiName', () => { - should(Ti).have.readOnlyProperty('apiName').which.is.a.String; - should(Ti.apiName).be.eql('Ti'); - }); - - it('version', () => { - should(Ti).have.readOnlyProperty('version').which.is.a.String; - should(Ti.version).not.eql('__VERSION__'); // This is the placeholder value used in iOS, let's ensure we replaced it! - should(Ti.version).match(/\d+\.\d+\.\d+/); // i.e. '9.0.0' (the short version string, no timestamp qualifier) - }); - - it('#getVersion()', () => { - should(Ti.getVersion).be.a.Function; - should(Ti.getVersion()).eql(Ti.version); - }); - - it('buildDate', () => { - should(Ti).have.readOnlyProperty('buildDate').which.is.a.String; - should(Ti.buildDate).not.eql('__TIMESTAMP__'); // This is the placeholder value used in iOS, let's ensure we replaced it! - should(Ti.buildDate).match(/[01]?\d\/[0123]\d\/20\d{2} \d{2}:\d{2}/); // i.e. '4/14/2020 18:48' - }); - - it('#getBuildDate()', () => { - should(Ti.getBuildDate).be.a.Function; - should(Ti.getBuildDate()).eql(Ti.buildDate); - }); - - it('buildHash', () => { - should(Ti).have.readOnlyProperty('buildHash').which.is.a.String; - should(Ti.buildHash).not.eql('__GITHASH__'); // This is the placeholder value used in iOS, let's ensure we replaced it! - should(Ti.buildHash).match(/[a-f0-9]{10}/); // 10-character git sha - }); - - it('#getBuildHash()', () => { - should(Ti.getBuildHash).be.a.Function; - should(Ti.getBuildHash()).eql(Ti.buildHash); - }); - - // FIXME File a ticket in JIRA. Updating V8 fixes the property read/write issues, but exposes bug in that we set userAgent as read-only on Android and it shouldn't be - it.androidBroken('userAgent', function () { - should(Ti.userAgent).be.a.String; - - const save = Ti.userAgent; - Ti.userAgent = 'Titanium_Mocha_Test'; - should(Ti.userAgent).be.eql('Titanium_Mocha_Test'); - Ti.userAgent = save; - should(Ti.userAgent).be.eql(save); - }); - - it('#getUserAgent()', () => { - should(Ti.getUserAgent).be.a.Function; - should(Ti.getUserAgent()).eql(Ti.userAgent); - }); - - // FIXME Get working on IOS/Android! - it.androidAndIosBroken('#setUserAgent()', function () { - should(Ti.setUserAgent).be.a.Function; - var save = Ti.getUserAgent(); - Ti.setUserAgent('Titanium_Mocha_Test'); - should(Ti.getUserAgent()).be.eql('Titanium_Mocha_Test'); - should(Ti.userAgent).be.eql('Titanium_Mocha_Test'); - Ti.setUserAgent(save); - should(Ti.getUserAgent()).be.eql(save); - should(Ti.userAgent).be.eql(save); - }); - - it('#addEventListener()', () => should(Ti.addEventListener).be.a.Function); - - it('#removeEventListener()', () => should(Ti.removeEventListener).be.a.Function); - - // FIXME Get working on IOS/Android! - it.androidAndIosBroken('#applyProperties()', function () { - should(Ti.applyProperties).be.a.Function; - Ti.mocha_test = undefined; - should(Ti.applyProperties({ mocha_test: 'mocha_test_value' })); - should(Ti.mocha_test !== undefined); - should(Ti.mocha_test).be.eql('mocha_test_value'); - Ti.mocha_test = undefined; - }); - - it('#createBuffer()', () => should(Ti.createBuffer).be.a.Function); - - // FIXME Is this really a method we want to expose on our API? - it('#createProxy()', () => should(Ti.createProxy).be.a.Function); - - it('#fireEvent()', () => should(Ti.fireEvent).be.a.Function); -}); diff --git a/tests/Resources/ti.ui.picker.addontest.js b/tests/Resources/ti.ui.picker.addontest.js deleted file mode 100644 index de8a913cd64..00000000000 --- a/tests/Resources/ti.ui.picker.addontest.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Appcelerator Titanium Mobile - * Copyright (c) 2011-2018 by Appcelerator, 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'; -var should = require('./utilities/assertions'); - -describe('Titanium.UI.Picker', function () { - var win; - - this.timeout(10000); - - afterEach(function (done) { - if (win) { - // If `win` is already closed, we're done. - let t = setTimeout(function () { - if (win) { - win = null; - done(); - } - }, 3000); - - win.addEventListener('close', function listener () { - clearTimeout(t); - - if (win) { - win.removeEventListener('close', listener); - } - win = null; - done(); - }); - win.close(); - } else { - win = null; - done(); - } - }); - - it('minDate/maxDate - change after open', (finish) => { - let minDate = new Date(2020, 4, 1); - let maxDate = new Date(2020, 6, 31); - const picker = Ti.UI.createPicker({ - type: Ti.UI.PICKER_TYPE_DATE, - minDate: minDate, - maxDate: maxDate, - value: new Date(2020, 5, 1) - }); - - win = Ti.UI.createWindow(); - win.addEventListener('open', () => { - try { - should(picker.minDate).be.eql(minDate); - should(picker.maxDate).be.eql(maxDate); - should(picker.value.getTime()).be.aboveOrEqual(minDate.getTime()); - should(picker.value.getTime()).be.belowOrEqual(maxDate.getTime()); - minDate = new Date(2018, 0, 1); - maxDate = new Date(2018, 2, 31); - picker.minDate = minDate; - picker.maxDate = maxDate; - picker.value = new Date(2018, 1, 1); // Used to crash Android after changing range. - } catch (err) { - finish(err); - } - - setTimeout(() => { - try { - should(picker.minDate).be.eql(minDate); - should(picker.maxDate).be.eql(maxDate); - should(picker.value.getTime()).be.aboveOrEqual(minDate.getTime()); - should(picker.value.getTime()).be.belowOrEqual(maxDate.getTime()); - finish(); - } catch (err) { - finish(err); - } - }, 1); - }); - win.add(picker); - win.open(); - }); -});