You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2018/02/27 12:43:35 UTC
[cordova-windows] 17/26: fix unittests
This is an automated email from the ASF dual-hosted git repository.
janpio pushed a commit to branch janpio-win10only
in repository https://gitbox.apache.org/repos/asf/cordova-windows.git
commit 6a871c48bfc3097cb57d422762ee337e40dc5a5c
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Fri Feb 16 00:44:15 2018 +0100
fix unittests
---
spec/unit/AppxManifest.spec.js | 20 ++------------------
spec/unit/ConfigChanges.spec.js | 30 ++++++++++++------------------
spec/unit/Prepare.Win10.spec.js | 8 ++++----
spec/unit/package.spec.js | 8 ++++----
spec/unit/run.spec.js | 12 ++++++------
template/cordova/lib/package.js | 2 +-
6 files changed, 29 insertions(+), 51 deletions(-)
diff --git a/spec/unit/AppxManifest.spec.js b/spec/unit/AppxManifest.spec.js
index fd2cbd9..e7a7147 100644
--- a/spec/unit/AppxManifest.spec.js
+++ b/spec/unit/AppxManifest.spec.js
@@ -107,8 +107,7 @@ describe('AppxManifest', function () {
});
it('Test #009 : should detect manifest prefix based on "Package" element attributes', function () {
- expect(AppxManifest.get(WINDOWS_10_MANIFEST).prefix).toEqual('m2:');
- expect(AppxManifest.get(WINDOWS_10_MANIFEST).prefix).toEqual('m3:');
+ expect(AppxManifest.get(WINDOWS_10_MANIFEST).prefix).toEqual('uap:');
});
it('Test #010 : should instantiate either AppxManifest or Windows 10 AppxManifest based on manifest prefix', function () {
@@ -186,25 +185,10 @@ describe('AppxManifest', function () {
expect(refineColor(CSS_COLOR_NAME)).toEqual(CSS_COLOR_NAME);
});
- it('Test #017 : setForegroundText should change the ForegroundText property on non-Windows 10 platforms', function () {
- var visualElementsWindows = AppxManifest.get(WINDOWS_10_MANIFEST).getVisualElements();
+ it('Test #017 : setForegroundText do nothing on non-Windows 10 platforms', function () {
var visualElementsWindows10 = AppxManifest.get(WINDOWS_10_MANIFEST).getVisualElements();
var foregroundTextLight = 'light';
- var foregroundTextDark = 'dark';
- var foregroundTextDefault = foregroundTextLight;
-
- // Set to 'light'
- visualElementsWindows.setForegroundText(foregroundTextLight);
- expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextLight);
-
- // Set to 'dark'
- visualElementsWindows.setForegroundText(foregroundTextDark);
- expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextDark);
-
- // Simulate removal of preference, should change back to default vlaue 'light'
- visualElementsWindows.setForegroundText(undefined);
- expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextDefault);
// Returns nothing on Windows 10
visualElementsWindows10.setForegroundText(foregroundTextLight);
diff --git a/spec/unit/ConfigChanges.spec.js b/spec/unit/ConfigChanges.spec.js
index b823687..ffab2ac 100644
--- a/spec/unit/ConfigChanges.spec.js
+++ b/spec/unit/ConfigChanges.spec.js
@@ -89,15 +89,14 @@ describe('PlatformMunger', function () {
describe('Capabilities within package.windows.appxmanifest', function () {
- var testDir, windowsPlatform, windowsManifest, windowsManifest10, dummyPluginInfo, api;
+ var testDir, windowsPlatform, windows10Manifest, dummyPluginInfo, api;
beforeEach(function () {
testDir = path.join(__dirname, 'testDir');
shell.mkdir('-p', testDir);
shell.cp('-rf', windowsProject + '/*', testDir);
windowsPlatform = path.join(testDir, 'platforms/windows');
- windowsManifest = path.join(windowsPlatform, WINDOWS10_MANIFEST);
- windowsManifest10 = path.join(windowsPlatform, WINDOWS10_MANIFEST);
+ windows10Manifest = path.join(windowsPlatform, WINDOWS10_MANIFEST);
dummyPluginInfo = new PluginInfo(dummyPlugin);
api = new Api();
api.root = windowsPlatform;
@@ -127,11 +126,11 @@ describe('Capabilities within package.windows.appxmanifest', function () {
api.addPlugin(dummyPluginInfo)
.then(function () {
// There is the one default capability in manifest with 'internetClient' name
- expect(getManifestCapabilities(windowsManifest).length).toBe(getPluginCapabilities(dummyPluginInfo).length + 1);
+ expect(getManifestCapabilities(windows10Manifest).length).toBe(getPluginCapabilities(dummyPluginInfo).length + 1);
api.removePlugin(dummyPluginInfo);
})
.then(function () {
- expect(getManifestCapabilities(windowsManifest).length).toBe(1);
+ expect(getManifestCapabilities(windows10Manifest).length).toBe(1);
})
.catch(fail)
.finally(function () {
@@ -144,7 +143,7 @@ describe('Capabilities within package.windows.appxmanifest', function () {
api.addPlugin(dummyPluginInfo)
.then(function () {
// There is the one default capability in manifest with 'internetClient' name
- var manifestCapabilities = getManifestCapabilities(windowsManifest10);
+ var manifestCapabilities = getManifestCapabilities(windows10Manifest);
expect(manifestCapabilities.length).toBe(getPluginCapabilities(dummyPluginInfo).length + 1);
// Count 'uap' prefixed capabilities
@@ -156,7 +155,7 @@ describe('Capabilities within package.windows.appxmanifest', function () {
api.removePlugin(dummyPluginInfo);
})
.then(function () {
- expect(getManifestCapabilities(windowsManifest10).length).toBe(1);
+ expect(getManifestCapabilities(windows10Manifest).length).toBe(1);
})
.catch(fail)
.finally(function () {
@@ -188,13 +187,11 @@ describe('Capabilities within package.windows.appxmanifest', function () {
api.addPlugin(dummyPluginInfo)
.then(function () {
- checkCapabilitiesAfterInstall(windowsManifest);
- checkCapabilitiesAfterInstall(windowsManifest10);
+ checkCapabilitiesAfterInstall(windows10Manifest);
api.removePlugin(dummyPluginInfo);
})
.then(function () {
- checkCapabilitiesAfterRemove(windowsManifest);
- checkCapabilitiesAfterRemove(windowsManifest10);
+ checkCapabilitiesAfterRemove(windows10Manifest);
})
.catch(fail)
.finally(function () {
@@ -229,15 +226,12 @@ describe('generate_plugin_config_munge for windows project', function () {
it('should not process change w/o target package.appxmanifest', function () {
var testChanges = [
{
- target: 'package.windows.appxmanifest'
- },
- {
- target: 'package.appxmanifest'
+ target: 'package.windows10.appxmanifest'
}
];
var changes = AppxManifest.processChanges(testChanges);
- expect(changes.length).toBe(4);
+ expect(changes.length).toBe(1);
expect(changes[0].target).toBe(testChanges[0].target);
});
@@ -248,7 +242,7 @@ describe('generate_plugin_config_munge for windows project', function () {
}];
var changes = AppxManifest.processChanges(testChanges);
- expect(changes.length).toBe(3);
- expect(changes[2].target).toBe('package.windows10.appxmanifest');
+ expect(changes.length).toBe(1);
+ expect(changes[0].target).toBe('package.windows10.appxmanifest');
});
});
diff --git a/spec/unit/Prepare.Win10.spec.js b/spec/unit/Prepare.Win10.spec.js
index a9fcd68..7a01c0d 100644
--- a/spec/unit/Prepare.Win10.spec.js
+++ b/spec/unit/Prepare.Win10.spec.js
@@ -344,7 +344,7 @@ describe('Package description', function () {
var desc = mockConfig.manifest.doc.find('.//Properties/Description');
expect(desc.text).toBe('My custom description');
- desc = mockConfig.manifest.doc.find('.//Application/m2:VisualElements');
+ desc = mockConfig.manifest.doc.find('.//Application/uap:VisualElements');
expect(desc.attrib.Description).toBe('My custom description');
});
@@ -355,7 +355,7 @@ describe('Package description', function () {
var desc = mockConfig.manifest.doc.find('.//Properties/Description');
expect(desc).toBe(null);
- desc = mockConfig.manifest.doc.find('.//Application/m2:VisualElements');
+ desc = mockConfig.manifest.doc.find('.//Application/uap:VisualElements');
expect(desc.attrib.Description).toEqual(prepare.__get__('DEFAULT_DESCRIPTION'));
});
@@ -370,7 +370,7 @@ describe('Package description', function () {
var desc = mockConfig.manifest.doc.find('.//Properties/Description');
expect(desc.text.length).toBe(2048);
- desc = mockConfig.manifest.doc.find('.//Application/m2:VisualElements');
+ desc = mockConfig.manifest.doc.find('.//Application/uap:VisualElements');
expect(desc.attrib.Description.length).toBe(2048);
});
@@ -384,7 +384,7 @@ describe('Package description', function () {
var desc = mockConfig.manifest.doc.find('.//Properties/Description');
expect(desc).not.toMatch(/\n|\t/);
- desc = mockConfig.manifest.doc.find('.//Application/m2:VisualElements');
+ desc = mockConfig.manifest.doc.find('.//Application/:VisualElements');
expect(desc.attrib.Description).not.toMatch(/\n|\t/);
});
});
diff --git a/spec/unit/package.spec.js b/spec/unit/package.spec.js
index 271a777..0142990 100644
--- a/spec/unit/package.spec.js
+++ b/spec/unit/package.spec.js
@@ -47,14 +47,14 @@ describe('getPackage method', function () {
it('spec.1 should find windows anycpu debug package', function (done) {
var rejected = jasmine.createSpy();
- pkg.getPackage('windows', 'debug', 'anycpu')
+ pkg.getPackage('debug', 'anycpu')
.then(function (pkgInfo) {
- expect(pkgInfo.type).toBe('windows');
+ expect(pkgInfo.type).toBe('windows10');
expect(pkgInfo.buildtype).toBe('debug');
expect(pkgInfo.arch).toBe('anycpu');
expect(pkgInfo.script).toBeDefined();
}, function (err) {
- console.error(err);
+ console.error('foo', err);
rejected();
})
.finally(function () {
@@ -66,7 +66,7 @@ describe('getPackage method', function () {
it('spec.2 should find windows phone anycpu debug package', function (done) {
var rejected = jasmine.createSpy();
- pkg.getPackage('phone', 'debug', 'anycpu')
+ pkg.getPackage('debug', 'anycpu')
.then(function (pkgInfo) {
expect(pkgInfo.type).toBe('phone');
expect(pkgInfo.buildtype).toBe('debug');
diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js
index 82d2078..2d8f480 100644
--- a/spec/unit/run.spec.js
+++ b/spec/unit/run.spec.js
@@ -265,15 +265,15 @@ describe('run method', function () {
run.run({ nobuild: true, argv: ['--archs=arm'] })
.then(function () {
- expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'arm');
- expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+ expect(packages.getPackage).toHaveBeenCalledWith(anyString, 'arm');
+ expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString);
})
.then(function () {
return run.run({ nobuild: true, archs: 'arm' });
})
.then(function () {
- expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'arm');
- expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+ expect(packages.getPackage).toHaveBeenCalledWith(anyString, 'arm');
+ expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString);
})
.catch(fail)
.finally(function () {
@@ -295,8 +295,8 @@ describe('run method', function () {
run.run({nobuild: true})
.then(function () {
- expect(packages.getPackage).toHaveBeenCalledWith(anyString, anyString, 'anycpu');
- expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString, anyString);
+ expect(packages.getPackage).toHaveBeenCalledWith(anyString, 'anycpu');
+ expect(packages.deployToDesktop).toHaveBeenCalledWith(expectedDeployOptions, anyString);
})
.catch(fail)
.finally(function () {
diff --git a/template/cordova/lib/package.js b/template/cordova/lib/package.js
index ef0dba4..f938fc3 100644
--- a/template/cordova/lib/package.js
+++ b/template/cordova/lib/package.js
@@ -33,7 +33,7 @@ module.exports.getPackage = function (buildtype, buildArch) {
var appPackages = path.resolve(path.join(__dirname, '..', '..', 'AppPackages'));
// reject promise if AppPackages folder doesn't exist
if (!fs.existsSync(appPackages)) {
- return Q.reject('AppPackages folder doesn\'t exist');
+ return Q.reject('AppPackages folder doesn\'t exist' + appPackages);
}
// find out and resolve paths for all folders inside AppPackages
var pkgDirs = fs.readdirSync(appPackages).map(function (relative) {
--
To stop receiving notification emails like this one, please contact
janpio@apache.org.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org