http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/platforms/windows.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/platforms/windows.spec.js b/cordova-lib/spec-plugman/platforms/windows.spec.js index 03e5602..6759bc3 100644 --- a/cordova-lib/spec-plugman/platforms/windows.spec.js +++ b/cordova-lib/spec-plugman/platforms/windows.spec.js @@ -50,18 +50,25 @@ function copyArray(arr) { } beforeEach(function () { - this.addMatchers({ - toContainXmlPath: function (xpath) { - var xml = this.actual; - var notText = this.isNot ? 'not ' : ''; - this.message = function () { - return 'Expected xml \'' + et.tostring(xml) + '\' ' + notText + 'to contain elements matching \'' + xpath + '\'.'; - }; - - return xml.find(xpath) !== null; - } }); + jasmine.addMatchers({ + toContainXmlPath: function () { + return { + compare: function(actual, expected) { + var xml = actual; + var result = {}; + result.pass = xml.find(expected) !== null; + + if(result.pass) { + result.message = 'Expected xml \'' + et.tostring(xml) + '\' ' +' not to contain elements matching \'' + expected + '\'.'; + } else { + result.message = 'Expected xml \'' + et.tostring(xml) + '\' ' +' to contain elements matching \'' + expected + '\'.'; + } + return result; + } + } + } + }); }); - ['windows', 'windows8'].forEach(function (platform) { var windows_project = path.join(__dirname, '..', 'projects', platform); @@ -93,21 +100,24 @@ beforeEach(function () { }); describe('www_dir method', function () { - it('should return cordova-windows project www location using www_dir', function () { + it('Test 001 : should return cordova-windows project www location using www_dir', function (done) { expect(windows.www_dir(path.sep)).toEqual(path.sep + 'www'); + done(); }); }); describe('package_name method', function () { - it('should return a windows project\'s proper package name', function () { + it('Test 002 : should return a windows project\'s proper package name', function (done) { expect(windows.package_name(windows_project)).toEqual('CordovaApp'); + done(); }); }); describe('parseProjectFile method', function () { - it('should throw if project is not an windows project', function () { + it('Test 003 : should throw if project is not an windows project', function (done) { expect(function () { windows.parseProjectFile(cordovaProjectWindowsPlatformDir); - }).toThrow(windows.InvalidProjectPathError); + }).toThrow(new Error (windows.InvalidProjectPathError)); + done(); }); }); @@ -121,7 +131,8 @@ beforeEach(function () { }); function validateInstalledProjects(tag, elementToInstall, xpath, supportedPlatforms) { - jasmine.getEnv().currentSpec.removeAllSpies(); + //jasmine.getEnv().currentSpec.removeAllSpies(); + var projects = copyArray(proj_files.projects); if (platform === 'windows') { @@ -182,7 +193,7 @@ beforeEach(function () { projects.forEach(function (project) { if (projectsAddedTo.indexOf(path.basename(project.location)) > -1) { - projectsAddedToSpies.push(spyOn(project, 'appendToRoot').andCallFake(appendToRootFake)); + projectsAddedToSpies.push(spyOn(project, 'appendToRoot').and.callFake(appendToRootFake)); } else { projectsNotAddedToSpies.push(spyOn(project, 'appendToRoot')); } @@ -192,34 +203,39 @@ beforeEach(function () { projectsAddedToSpies.forEach(function (spy) { expect(spy).toHaveBeenCalled(); + spy.calls.reset(); }); projectsNotAddedToSpies.forEach(function (spy) { expect(spy).not.toHaveBeenCalled(); + spy.calls.reset(); }); } describe('of <source-file> elements', function () { - it('should copy stuff from one location to another by calling common.copyFile', function () { + it('Test 004 : should copy stuff from one location to another by calling common.copyFile', function (done) { var source = copyArray(valid_source); var s = spyOn(common, 'copyFile'); windows['source-file'].install(source[0], dummyplugin, cordovaProjectWindowsPlatformDir, dummy_id, null, proj_files); expect(s).toHaveBeenCalledWith(dummyplugin, 'src/windows/dummer.js', cordovaProjectWindowsPlatformDir, path.join('plugins', 'org.test.plugins.dummyplugin', 'dummer.js'), false); + done(); }); - it('should throw if source-file src cannot be found', function () { + it('Test 005 : should throw if source-file src cannot be found', function (done) { var source = copyArray(invalid_source); expect(function () { windows['source-file'].install(source[1], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('"' + path.resolve(faultyplugin, 'src/windows/NotHere.js') + '" not found!'); + }).toThrow(new Error ('"' + path.resolve(faultyplugin, 'src/windows/NotHere.js') + '" not found!')); + done(); }); - it('should throw if source-file target already exists', function () { + it('Test 006 : should throw if source-file target already exists', function (done) { var source = copyArray(valid_source); var target = path.join(cordovaProjectWindowsPlatformDir, 'plugins', dummy_id, 'dummer.js'); shell.mkdir('-p', path.dirname(target)); fs.writeFileSync(target, 'some bs', 'utf-8'); expect(function () { windows['source-file'].install(source[0], dummyplugin, cordovaProjectWindowsPlatformDir, dummy_id, null, proj_files); - }).toThrow('"' + target + '" already exists!'); + }).toThrow(new Error ('"' + target + '" already exists!')); + done(); }); }); @@ -229,32 +245,43 @@ beforeEach(function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should write to correct project files when conditions are specified', function () { + it('Test 007 : should write to correct project files when conditions are specified', function (done) { var xpath = 'Content[@Include="' + resourceFiles[0].target + '"][@Condition="\'$(Platform)\'==\'x86\'"]'; validateInstalledProjects('resource-file', resourceFiles[0], xpath, ['all']); + done(); + }); - xpath = 'Content[@Include="' + resourceFiles[1].target + '"]'; + it('Test 008 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Content[@Include="' + resourceFiles[1].target + '"]'; validateInstalledProjects('resource-file', resourceFiles[1], xpath, ['windows', 'phone', 'windows10']); + done(); + }); - xpath = 'Content[@Include="' + resourceFiles[2].target + '"]'; + it('Test 009 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Content[@Include="' + resourceFiles[2].target + '"]'; validateInstalledProjects('resource-file', resourceFiles[2], xpath, ['phone']); + done(); + }); - xpath = 'Content[@Include="' + resourceFiles[3].target + '"][@Condition="\'$(Platform)\'==\'x64\'"]'; + it('Test 010 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Content[@Include="' + resourceFiles[3].target + '"][@Condition="\'$(Platform)\'==\'x64\'"]'; validateInstalledProjects('resource-file', resourceFiles[3], xpath, ['windows8']); + done(); }); - it('should throw if conditions are invalid', function () { + it('Test 011 : should throw if conditions are invalid', function (done) { expect(function () { windows['resource-file'].install(invalidResourceFiles[0], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85'); + }).toThrow(new Error ('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85')); expect(function () { windows['resource-file'].install(invalidResourceFiles[1], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid versions attribute (must be a valid semantic version range): 8.0a'); + }).toThrow(new Error ('Invalid versions attribute (must be a valid semantic version range): 8.0a')); expect(function () { windows['resource-file'].install(invalidResourceFiles[2], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne'); + }).toThrow(new Error ('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne')); + done(); }); }); @@ -264,32 +291,50 @@ beforeEach(function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should write to correct project files when conditions are specified', function () { + it('Test 012 : should write to correct project files when conditions are specified', function (done) { var xpath = 'SDKReference[@Include="TestSDK1, Version=1.0"][@Condition="\'$(Platform)\'==\'x86\'"]'; validateInstalledProjects('lib-file', libfiles[0], xpath, ['all']); + done(); + }); - xpath = 'SDKReference[@Include="TestSDK2, Version=1.0"]'; + it('Test 013 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'SDKReference[@Include="TestSDK2, Version=1.0"]'; validateInstalledProjects('lib-file', libfiles[1], xpath, ['windows', 'phone', 'windows10']); - - xpath = 'SDKReference[@Include="TestSDK3, Version=1.0"]'; + done(); + }); + + it('Test 014 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'SDKReference[@Include="TestSDK3, Version=1.0"]'; validateInstalledProjects('lib-file', libfiles[2], xpath, ['phone']); + done(); + }); - xpath = 'SDKReference[@Include="TestSDK4, Version=1.0"]'; + it('Test 015 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'SDKReference[@Include="TestSDK4, Version=1.0"]'; validateInstalledProjects('lib-file', libfiles[3], xpath, ['windows8']); + done(); }); - it('should throw if conditions are invalid', function () { + it('Test 016 : should throw if conditions are invalid', function (done) { expect(function () { windows['lib-file'].install(invalidLibFiles[0], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85'); + }).toThrow(new Error('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85')); + done(); + }); + + it('Test 017 : should throw if conditions are invalid', function (done) { expect(function () { windows['lib-file'].install(invalidLibFiles[1], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid versions attribute (must be a valid semantic version range): 8.0a'); - + }).toThrow(new Error ('Invalid versions attribute (must be a valid semantic version range): 8.0a')); + done(); + }); + + it('Test 018 : should throw if conditions are invalid', function (done) { expect(function () { windows['lib-file'].install(invalidLibFiles[2], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files); - }).toThrow('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne'); + }).toThrow(new Error ('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne')); + done(); }); }); @@ -298,42 +343,67 @@ beforeEach(function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should write to correct project files when conditions are specified', function () { + it('Test 019 : should write to correct project files when conditions are specified', function (done) { var xpath = 'Reference[@Include="dummy1"][@Condition="\'$(Platform)\'==\'x64\'"]/HintPath'; validateInstalledProjects('framework', frameworks[0], xpath, ['all']); - - xpath = 'Reference[@Include="dummy2"]/HintPath'; + done(); + }); + it('Test 020 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Reference[@Include="dummy2"]/HintPath'; validateInstalledProjects('framework', frameworks[1], xpath, ['all']); - - xpath = 'Reference[@Include="dummy3"]/HintPath'; + done(); + }); + + it('Test 021 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Reference[@Include="dummy3"]/HintPath'; validateInstalledProjects('framework', frameworks[2], xpath, ['windows', 'windows8', 'windows10']); - - xpath = 'Reference[@Include="dummy4"][@Condition="\'$(Platform)\'==\'ARM\'"]/HintPath'; + done(); + }); + + it('Test 022 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Reference[@Include="dummy4"][@Condition="\'$(Platform)\'==\'ARM\'"]/HintPath'; validateInstalledProjects('framework', frameworks[3], xpath, ['phone']); + done(); + }); - xpath = 'Reference[@Include="dummy5"]/HintPath'; + it('Test 023 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Reference[@Include="dummy5"]/HintPath'; validateInstalledProjects('framework', frameworks[4], xpath, ['phone']); + done(); + }); - xpath = 'Reference[@Include="dummy6"]/HintPath'; + it('Test 024 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'Reference[@Include="dummy6"]/HintPath'; validateInstalledProjects('framework', frameworks[5], xpath, ['windows', 'windows10', 'phone']); + done(); }); }); describe('of <framework> elements of type \'projectReference\'', function () { var frameworks = copyArray(valid_frameworks); - it('should write to correct project files when conditions are specified', function () { + it('Test 025 : should write to correct project files when conditions are specified', function (done) { var xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy1.vcxproj') + '"][@Condition="\'$(Platform)\'==\'x64\'"]'; validateInstalledProjects('framework', frameworks[6], xpath, ['all']); - - xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy2.vcxproj') + '"]'; + done(); + }); + + it('Test 026 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy2.vcxproj') + '"]'; validateInstalledProjects('framework', frameworks[7], xpath, ['windows8']); - - xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy3.vcxproj') + '"]'; + done(); + }); + + it('Test 027 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy3.vcxproj') + '"]'; validateInstalledProjects('framework', frameworks[8], xpath, ['windows', 'windows8', 'windows10']); - - xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy4.vcxproj') + '"][@Condition="\'$(Platform)\'==\'x86\'"]'; + done(); + }); + + it('Test 028 : should write to correct project files when conditions are specified', function (done) { + var xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy4.vcxproj') + '"][@Condition="\'$(Platform)\'==\'x86\'"]'; validateInstalledProjects('framework', frameworks[9], xpath, ['windows', 'phone']); + done(); }); }); }); @@ -349,7 +419,7 @@ beforeEach(function () { }); function validateUninstalledProjects(tag, elementToUninstall, xmlPath, incText, targetConditions, supportedPlatforms) { - jasmine.getEnv().currentSpec.removeAllSpies(); + //jasmine.getEnv().currentSpec.removeAllSpies(); var projects = copyArray(proj_files.projects); if (platform === 'windows') { @@ -369,6 +439,8 @@ beforeEach(function () { projects.forEach(function (project) { var spy = spyOn(project, 'removeItemGroupElement'); + + if (projectsAddedTo.indexOf(path.basename(project.location)) > -1) { projectsAddedToSpies.push(spy); } else { @@ -380,15 +452,17 @@ beforeEach(function () { projectsAddedToSpies.forEach(function (spy) { expect(spy).toHaveBeenCalledWith(xmlPath, incText, targetConditions); + spy.calls.reset(); }); projectsNotAddedToSpies.forEach(function (spy) { expect(spy).not.toHaveBeenCalled(); + spy.calls.reset(); }); } describe('of <source-file> elements', function () { - it('should remove stuff by calling common.removeFile', function (done) { + it('Test 029 : should remove stuff by calling common.removeFile', function (done) { var s = spyOn(common, 'removeFile'); install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) @@ -404,7 +478,7 @@ beforeEach(function () { describe('of <resource-file> elements', function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should remove from correct project files when conditions specified', function (done) { + it('Test 030 : should remove from correct project files when conditions specified', function (done) { var resourcefiles = copyArray(valid_resourceFiles); install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) @@ -414,14 +488,43 @@ beforeEach(function () { var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x86'}; validateUninstalledProjects('resource-file', resourcefiles[0], path, incText, targetConditions, ['all']); + done(); + }); + }); + it('Test 031 : should remove from correct project files when conditions specified', function (done) { + var resourcefiles = copyArray(valid_resourceFiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Content'; + incText = resourcefiles[1].target; targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined}; validateUninstalledProjects('resource-file', resourcefiles[1], path, incText, targetConditions, ['windows', 'phone', 'windows10']); + done(); + }); + }); + it('Test 032 : should remove from correct project files when conditions specified', function (done) { + var resourcefiles = copyArray(valid_resourceFiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Content'; + incText = resourcefiles[2].target; targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined}; validateUninstalledProjects('resource-file', resourcefiles[2], path, incText, targetConditions, ['phone']); + done(); + }); + }); + it('Test 033 : should remove from correct project files when conditions specified', function (done) { + var resourcefiles = copyArray(valid_resourceFiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Content'; incText = resourcefiles[3].target; targetConditions = {versions: '8.0', deviceTarget: 'windows', arch: 'x64'}; validateUninstalledProjects('resource-file', resourcefiles[3], path, incText, targetConditions, ['windows8']); @@ -434,7 +537,7 @@ beforeEach(function () { describe('of <lib-file> elements', function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should remove from correct project files when conditions specified', function (done) { + it('Test 034 : should remove from correct project files when conditions specified', function (done) { var libfiles = copyArray(valid_libfiles); install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) @@ -443,15 +546,43 @@ beforeEach(function () { var incText = 'TestSDK1, Version=1.0'; var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x86'}; validateUninstalledProjects('lib-file', libfiles[0], path, incText, targetConditions, ['all']); + done(); + }); + }); + it('Test 035 : should remove from correct project files when conditions specified', function (done) { + var libfiles = copyArray(valid_libfiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/SDKReference'; incText = 'TestSDK2, Version=1.0'; targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined}; validateUninstalledProjects('lib-file', libfiles[1], path, incText, targetConditions, ['windows', 'phone', 'windows10']); + done(); + }); + }); + it('Test 036 : should remove from correct project files when conditions specified', function (done) { + var libfiles = copyArray(valid_libfiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/SDKReference'; incText = 'TestSDK3, Version=1.0'; targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined}; validateUninstalledProjects('lib-file', libfiles[2], path, incText, targetConditions, ['phone']); + done(); + }); + }); + + it('Test 037 : should remove from correct project files when conditions specified', function (done) { + var libfiles = copyArray(valid_libfiles); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/SDKReference'; incText = 'TestSDK4, Version=1.0'; targetConditions = {versions: '8.0', deviceTarget: 'windows', arch: 'x86'}; validateUninstalledProjects('lib-file', libfiles[3], path, incText, targetConditions, ['windows8']); @@ -464,7 +595,7 @@ beforeEach(function () { describe('of <framework> elements', function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should remove from correct project files when conditions specified', function (done) { + it('Test 038 : should remove from correct project files when conditions specified', function (done) { var frameworks = copyArray(valid_frameworks); install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) @@ -474,59 +605,136 @@ beforeEach(function () { var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x64'}; validateUninstalledProjects('framework', frameworks[0], path, incText, targetConditions, ['all']); + done(); + }); + }, 6000); + + it('Test 039 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Reference'; incText = 'dummy2'; targetConditions = {versions: '>=8.0', deviceTarget: undefined, arch: undefined}; validateUninstalledProjects('framework', frameworks[1], path, incText, targetConditions, ['all']); + done(); + }); + }, 6000); + + it('Test 040 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Reference'; incText = 'dummy3'; targetConditions = {versions: undefined, deviceTarget: 'windows', arch: undefined}; validateUninstalledProjects('framework', frameworks[2], path, incText, targetConditions, ['windows', 'windows8', 'windows10']); + done(); + }); + }, 6000); + + it('Test 041 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Reference'; incText = 'dummy4'; targetConditions = {versions: '8.1', deviceTarget: 'phone', arch: 'ARM'}; validateUninstalledProjects('framework', frameworks[3], path, incText, targetConditions, ['phone']); + done(); + }); + }, 6000); + + it('Test 042 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Reference'; incText = 'dummy5'; targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined}; validateUninstalledProjects('framework', frameworks[4], path, incText, targetConditions, ['phone']); + done(); + }); + }, 6000); + + it('Test 043 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var path = 'ItemGroup/Reference'; incText = 'dummy6'; targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined}; validateUninstalledProjects('framework', frameworks[5], path, incText, targetConditions, ['windows', 'windows10', 'phone']); done(); }); - }); + }, 6000); }); describe('of <framework> elements of type \'projectReference\'', function () { // This could be separated into individual specs, but that results in a lot of copying and deleting the // project files, which is not needed. - it('should remove from correct project files when conditions specified', function (done) { + it('Test 044 : should remove from correct project files when conditions specified', function (done) { var frameworks = copyArray(valid_frameworks); - install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + return install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) .then(function () { var xmlPath = 'ItemGroup/ProjectReference'; var incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy1.vcxproj'); var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x64'}; validateUninstalledProjects('framework', frameworks[6], xmlPath, incText, targetConditions, ['all']); + done(); + }); + }, 60000); + + it('Test 045 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); - incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy2.vcxproj'); + return install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var xmlPath = 'ItemGroup/ProjectReference'; + var incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy2.vcxproj'); targetConditions = {versions: '<8.1', deviceTarget: undefined, arch: undefined}; validateUninstalledProjects('framework', frameworks[7], xmlPath, incText, targetConditions, ['windows8']); + done(); + }); + }, 60000); - incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy3.vcxproj'); + it('Test 046 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + return install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var xmlPath = 'ItemGroup/ProjectReference'; + var incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy3.vcxproj'); targetConditions = {versions: undefined, deviceTarget: 'win', arch: undefined}; validateUninstalledProjects('framework', frameworks[8], xmlPath, incText, targetConditions, ['windows', 'windows8', 'windows10']); - incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy4.vcxproj'); + done(); + }); + }, 60000); + + it('Test 047 : should remove from correct project files when conditions specified', function (done) { + var frameworks = copyArray(valid_frameworks); + + return install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {}) + .then(function () { + var xmlPath = 'ItemGroup/ProjectReference'; + var incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy4.vcxproj'); targetConditions = {versions: '8.1', deviceTarget: 'all', arch: 'x86'}; validateUninstalledProjects('framework', frameworks[9], xmlPath, incText, targetConditions, ['windows', 'phone']); - done(); }); - }); + }, 60000); }); }); });
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/platforms/wp8.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/platforms/wp8.spec.js b/cordova-lib/spec-plugman/platforms/wp8.spec.js index 24cd1af..93d4b22 100644 --- a/cordova-lib/spec-plugman/platforms/wp8.spec.js +++ b/cordova-lib/spec-plugman/platforms/wp8.spec.js @@ -60,21 +60,21 @@ describe('wp8 project handler', function() { }); describe('www_dir method', function() { - it('should return cordova-wp8 project www location using www_dir', function() { + it('Test 001 : should return cordova-wp8 project www location using www_dir', function() { expect(wp8.www_dir(path.sep)).toEqual(path.sep + 'www'); }); }); describe('package_name method', function() { - it('should return a wp8 project\'s proper package name', function() { + it('Test 002 : should return a wp8 project\'s proper package name', function() { expect(wp8.package_name(wp8_project)).toEqual('{F3A8197B-6B16-456D-B5F4-DD4F04AC0BEC}'); }); }); describe('parseProjectFile method', function() { - it('should throw if project is not an wp8 project', function() { + it('Test 003 : should throw if project is not an wp8 project', function() { expect(function() { wp8.parseProjectFile(temp); - }).toThrow('does not appear to be a Windows Phone project (no .csproj file)'); + }).toThrow(new Error ('does not appear to be a Windows Phone project (no .csproj file)')); }); }); @@ -94,41 +94,40 @@ describe('wp8 project handler', function() { beforeEach(function() { shell.cp('-rf', path.join(wp8_project, '*'), temp); }); - it('should copy stuff from one location to another by calling common.copyFile', function() { + it('Test 004 : should copy stuff from one location to another by calling common.copyFile', function() { var source = copyArray(valid_source); var s = spyOn(common, 'copyFile'); wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, null, proj_files); expect(s).toHaveBeenCalledWith(dummyplugin, 'src/wp8/DummyPlugin.cs', temp, path.join('Plugins', 'org.test.plugins.dummyplugin', 'DummyPlugin.cs'), false); }); - it('should throw if source-file src cannot be found', function() { + it('Test 005 : should throw if source-file src cannot be found', function() { var source = copyArray(invalid_source); expect(function() { wp8['source-file'].install(source[1], faultyplugin, temp, faulty_id, null, proj_files); - }).toThrow('"' + path.resolve(faultyplugin, 'src/wp8/NotHere.cs') + '" not found!'); + }).toThrow(new Error('"' + path.resolve(faultyplugin, 'src/wp8/NotHere.cs') + '" not found!')); }); - it('should throw if source-file target already exists', function() { + it('Test 006 : should throw if source-file target already exists', function() { var source = copyArray(valid_source); var target = path.join(temp, 'Plugins', dummy_id, 'DummyPlugin.cs'); shell.mkdir('-p', path.dirname(target)); fs.writeFileSync(target, 'some bs', 'utf-8'); expect(function() { wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, null, proj_files); - }).toThrow('"' + target + '" already exists!'); + }).toThrow(new Error ('"' + target + '" already exists!')); }); }); describe('of <config-changes> elements', function() { beforeEach(function() { shell.cp('-rf', path.join(wp8_project, '*'), temp); }); - it('should process and pass the after parameter to graftXML', function () { - var graftXML = spyOn(xml_helpers, 'graftXML').andCallThrough(); - - runs(function () { installPromise(install('wp8', temp, dummyplugin, plugins_dir, {})); }); - waitsFor(function () { return done; }, 'install promise never resolved', 500); - runs(function () { + it('Test 007 : should process and pass the after parameter to graftXML', function (done) { + var graftXML = spyOn(xml_helpers, 'graftXML').and.callThrough(); + return install('wp8', temp, dummyplugin, plugins_dir, {}) + .then(function() { expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), '/Deployment/App', 'Tokens'); expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), '/Deployment/App/Extensions', 'Extension'); expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), '/Deployment/App/Extensions', 'FileTypeAssociation;Extension'); + done(); }); }); }); @@ -144,7 +143,7 @@ describe('wp8 project handler', function() { shell.rm('-rf', temp); }); describe('of <source-file> elements', function() { - it('should remove stuff by calling common.removeFile', function(done) { + it('Test 009 : should remove stuff by calling common.removeFile', function(done) { var s = spyOn(common, 'removeFile'); install('wp8', temp, dummyplugin, plugins_dir, {}) .then(function() { http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/registry/registry.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/registry/registry.spec.js b/cordova-lib/spec-plugman/registry/registry.spec.js index aa2d419..71c9318 100644 --- a/cordova-lib/spec-plugman/registry/registry.spec.js +++ b/cordova-lib/spec-plugman/registry/registry.spec.js @@ -29,12 +29,13 @@ describe('registry', function() { beforeEach(function() { done = false; }); + function registryPromise(shouldSucceed, f) { - waitsFor(function() { return done; }, 'promise never resolved', 500); - return f.then(function() { + return f + .then(function() { done = true; expect(shouldSucceed).toBe(true); - }, function(err) { + }).fail(function(err){ done = err; expect(shouldSucceed).toBe(false); }); @@ -52,33 +53,44 @@ describe('registry', function() { afterEach(function() { shell.rm('-rf', tmp_plugin); }); - it('should generate a package.json from a plugin.xml', function() { - registryPromise(true, manifest.generatePackageJsonFromPluginXml(tmp_plugin).then(function() { + it('Test 001 : should generate a package.json from a plugin.xml', function(done) { + return registryPromise(true, manifest.generatePackageJsonFromPluginXml(tmp_plugin)) + .then(function() { expect(fs.existsSync(tmp_package_json)); var packageJson = JSON.parse(fs.readFileSync(tmp_package_json)); expect(packageJson.name).toEqual('com.cordova.engine'); expect(packageJson.version).toEqual('1.0.0'); expect(packageJson.engines).toEqual( [ { name : 'cordova', version : '>=2.3.0' }, { name : 'cordova-plugman', version : '>=0.10.0' }, { name : 'mega-fun-plugin', version : '>=1.0.0' }, { name : 'mega-boring-plugin', version : '>=3.0.0' } ]); - })); - }); - it('should raise an error if name does not follow com.domain.* format', function() { + done(); + }); + }, 6000); + it('Test 002 : should raise an error if name does not follow com.domain.* format', function(done) { var xmlData = fs.readFileSync(tmp_plugin_xml).toString().replace('id="com.cordova.engine"', 'id="engine"'); fs.writeFileSync(tmp_plugin_xml, xmlData); - registryPromise(false, manifest.generatePackageJsonFromPluginXml(tmp_plugin)); + return registryPromise(false, manifest.generatePackageJsonFromPluginXml(tmp_plugin)) + .then(function(){ + done(); + }) }); - it('should generate a package.json if name uses org.apache.cordova.* for a whitelisted plugin', function() { + // Expect the package.json to NOT exist + it('Test 003 : should generate a package.json if name uses org.apache.cordova.* for a whitelisted plugin', function(done) { var xmlData = fs.readFileSync(tmp_plugin_xml).toString().replace('id="com.cordova.engine"', 'id="org.apache.cordova.camera"'); fs.writeFileSync(tmp_plugin_xml, xmlData); - registryPromise(true, manifest.generatePackageJsonFromPluginXml(tmp_plugin).then(function() { - expect(!fs.existsSync(tmp_package_json)); - })); - }); - it('should raise an error if name uses org.apache.cordova.* for a non-whitelisted plugin', function() { + return registryPromise(true, manifest.generatePackageJsonFromPluginXml(tmp_plugin)) + .then(function(result) { + expect(fs.existsSync(tmp_package_json)).toBe(true); + done(); + }); + }, 6000); + it('Test 004 : should raise an error if name uses org.apache.cordova.* for a non-whitelisted plugin', function(done) { var xmlData = fs.readFileSync(tmp_plugin_xml).toString().replace('id="com.cordova.engine"', 'id="org.apache.cordova.myinvalidplugin"'); fs.writeFileSync(tmp_plugin_xml, xmlData); - registryPromise(false, manifest.generatePackageJsonFromPluginXml(tmp_plugin)); - }); + return registryPromise(false, manifest.generatePackageJsonFromPluginXml(tmp_plugin)) + .then(function(){ + done(); + }) + }, 6000); }); describe('actions', function() { var fakeLoad, fakeNPMCommands; @@ -99,11 +111,11 @@ describe('registry', function() { }; registry.settings = fakeSettings; - fakeLoad = spyOn(npm, 'load').andCallFake(function () { arguments[arguments.length - 1](null, true); }); + fakeLoad = spyOn(npm, 'load').and.callFake(function () { arguments[arguments.length - 1](null, true); }); fakeNPMCommands = {}; ['config', 'adduser', 'cache', 'publish', 'unpublish', 'search'].forEach(function(cmd) { - fakeNPMCommands[cmd] = jasmine.createSpy(cmd).andCallFake(fakeNPM); + fakeNPMCommands[cmd] = jasmine.createSpy(cmd).and.callFake(fakeNPM); }); npm.commands = fakeNPMCommands; @@ -111,19 +123,21 @@ describe('registry', function() { npm.config.get = function(){}; npm.config.del = function(){}; }); - it('should run config', function() { + it('Test 005 : should run config', function(done) { var params = ['set', 'registry', 'http://registry.cordova.io']; - registryPromise(true, registry.config(params).then(function() { + return registryPromise(true, registry.config(params).then(function() { expect(fakeLoad).toHaveBeenCalledWith(jasmine.any(Object),jasmine.any(Function)); expect(fakeNPMCommands.config).toHaveBeenCalledWith(params, jasmine.any(Function)); + done(); })); - }); - it('should run search', function() { + }, 6000); + it('Test 006 : should run search', function(done) { var params = ['dummyplugin', 'plugin']; - registryPromise(true, registry.search(params).then(function() { + return registryPromise(true, registry.search(params).then(function() { expect(fakeLoad).toHaveBeenCalledWith(jasmine.any(Object),jasmine.any(Function)); expect(fakeNPMCommands.search).toHaveBeenCalledWith(params, true, jasmine.any(Function)); + done(); })); - }); + }, 6000); }); }); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/search.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/search.spec.js b/cordova-lib/spec-plugman/search.spec.js index f2acb01..1d96e84 100644 --- a/cordova-lib/spec-plugman/search.spec.js +++ b/cordova-lib/spec-plugman/search.spec.js @@ -21,7 +21,7 @@ var search = require('../src/plugman/search'), registry = require('../src/plugman/registry/registry'); describe('search', function() { - it('should search a plugin', function() { + it('Test 001 : should search a plugin', function() { var sSearch = spyOn(registry, 'search').and.returnValue(Q()); search(new Array('myplugin', 'keyword')); expect(sSearch).toHaveBeenCalledWith(['myplugin', 'keyword']); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/uninstall.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/uninstall.spec.js b/cordova-lib/spec-plugman/uninstall.spec.js index 95e0b2b..2e8e862 100644 --- a/cordova-lib/spec-plugman/uninstall.spec.js +++ b/cordova-lib/spec-plugman/uninstall.spec.js @@ -50,7 +50,6 @@ var uninstall = require('../src/plugman/uninstall'), 'A' : path.join(plugins_dir, 'dependencies', 'A'), 'C' : path.join(plugins_dir, 'dependencies', 'C') }, - promise, dummy_id = 'org.test.plugins.dummyplugin'; var dummyPluginInfo = new PluginInfo(plugins['org.test.plugins.dummyplugin']); @@ -71,10 +70,6 @@ var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' + ' <access origin="*" />\n' + '</widget>\n'; -function uninstallPromise(f) { - return f.then(function() { done = true; }, function(err) { done = err; }); -} - describe('plugman uninstall start', function() { beforeEach(function () { var origParseElementtreeSync = xmlHelpers.parseElementtreeSync.bind(xmlHelpers); @@ -84,17 +79,14 @@ describe('plugman uninstall start', function() { }); }); - it('plugman uninstall start', function() { + it('Test 001 : plugman uninstall start', function(done) { shell.rm('-rf', project, project2, project3); shell.cp('-R', path.join(srcProject, '*'), project); shell.cp('-R', path.join(srcProject, '*'), project2); shell.cp('-R', path.join(srcProject, '*'), project3); - done = false; - promise = Q() - .then(function(){ - return install('android', project, plugins['org.test.plugins.dummyplugin']); - }).then(function(){ + return install('android', project, plugins['org.test.plugins.dummyplugin']) + .then(function(result){ return install('android', project, plugins['A']); }).then( function(){ return install('android', project2, plugins['C']); @@ -104,15 +96,12 @@ describe('plugman uninstall start', function() { return install('android', project3, plugins['A']); }).then(function(){ return install('android', project3, plugins['C']); - }).then(function(){ - done = true; - }, function(err) { - done = err.stack; - }); - waitsFor(function() { return done; }, 'promise never resolved', 2000); - runs(function() { - expect(done).toBe(true); - }); + }).then(function(result){ + expect(result).toEqual(true); + done(); + }).fail(function(err){ + expect(err).toBeUndefined(); + }, 60000); }); }); @@ -129,7 +118,7 @@ describe('uninstallPlatform', function() { }); describe('success', function() { - it('should get PlatformApi instance for platform and invoke its\' removePlugin method', function(done) { + it('Test 002 : should get PlatformApi instance for platform and invoke its\' removePlugin method', function(done) { var platformApi = { removePlugin: jasmine.createSpy('removePlugin').and.returnValue(Q()) }; var getPlatformApi = spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi); @@ -137,12 +126,14 @@ describe('uninstallPlatform', function() { .then(function() { expect(getPlatformApi).toHaveBeenCalledWith('android', project); expect(platformApi.removePlugin).toHaveBeenCalled(); - }, function(err) { + done(); + }).fail(function (err) { expect(err).toBeUndefined(); - }).fin(done); - }); + done(); + }); + }, 6000); - it('should return propagate value returned by PlatformApi removePlugin method', function(done) { + it('Test 003 : should return propagate value returned by PlatformApi removePlugin method', function(done) { var platformApi = { removePlugin: jasmine.createSpy('removePlugin') }; spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi); @@ -157,7 +148,8 @@ describe('uninstallPlatform', function() { function validateReturnedResultFor(values, expectedResult) { return values.reduce(function (promise, value) { - return promise.then(function () { + return promise + .then(function () { platformApi.removePlugin.and.returnValue(Q(value)); return uninstall.uninstallPlatform('android', project, dummy_id, null, { pluginInfoProvider: fakeProvider, platformVersion: '9.9.9' }); @@ -177,41 +169,37 @@ describe('uninstallPlatform', function() { .fin(done); }); - describe('with dependencies', function() { + describe('with dependencies', function() { var emit; beforeEach(function() { emit = spyOn(events, 'emit'); }); - it('should uninstall "dangling" dependencies', function(done) { - runs(function() { - uninstallPromise(uninstall.uninstallPlatform('android', project, 'A')); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { - expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2 dependent plugins.'); - }); + uninstall.uninstallPlatform('android', project, 'A') + .then(function(result) { + expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2 dependent plugins.'); + done(); }); }); }); describe('failure', function() { - it('should throw if platform is unrecognized', function(done) { - uninstall.uninstallPlatform('atari', project, 'SomePlugin').then(function(result){ + it('Test 004 : should throw if platform is unrecognized', function(done) { + uninstall.uninstallPlatform('atari', project, 'SomePlugin') + .then(function(result){ expect(false).toBe(true); done(); - }, - function err(errMsg) { + }).fail(function err (errMsg) { expect(errMsg.toString()).toContain('atari not supported.'); done(); }); }, 6000); - it('should throw if plugin is missing', function(done) { - uninstall.uninstallPlatform('android', project, 'SomePluginThatDoesntExist').then(function(result){ + it('Test 005 : should throw if plugin is missing', function(done) { + uninstall.uninstallPlatform('android', project, 'SomePluginThatDoesntExist') + .then(function(result){ expect(false).toBe(true); done(); - }, - function err(errMsg) { + }).fail(function err (errMsg) { expect(errMsg.toString()).toContain('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?'); done(); }); @@ -231,71 +219,60 @@ describe('uninstallPlugin', function() { }); describe('with dependencies', function() { - it('should delete all dependent plugins', function() { - runs(function() { - uninstallPromise( uninstall.uninstallPlugin('A', plugins_install_dir) ); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { + it('Test 006 : should delete all dependent plugins', function(done) { + uninstall.uninstallPlugin('A', plugins_install_dir) + .then(function(result) { var del = common.spy.getDeleted(emit); - expect(del).toEqual([ 'Deleted "C"', 'Deleted "D"', 'Deleted "A"' ]); + done(); }); }); - it('should fail if plugin is a required dependency', function(done) { - runs(function() { - uninstallPromise( uninstall.uninstallPlugin('C', plugins_install_dir) ); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { - expect(done.message).toBe('"C" is required by (A) and cannot be removed (hint: use -f or --force)'); + it('Test 007 : should fail if plugin is a required dependency', function(done) { + uninstall.uninstallPlugin('C', plugins_install_dir) + .then(function(result){ + expect(false).toBe(true); + done(); + }).fail(function err (errMsg) { + expect(errMsg.toString()).toEqual('"C" is required by (A) and cannot be removed (hint: use -f or --force)'); + done(); }); - }); + }, 6000); - it('allow forcefully removing a plugin', function() { - runs(function() { - uninstallPromise( uninstall.uninstallPlugin('C', plugins_install_dir, {force: true}) ); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { - expect(done).toBe(true); + it('Test 008 : allow forcefully removing a plugin', function(done) { + uninstall.uninstallPlugin('C', plugins_install_dir, {force: true}) + .then(function() { var del = common.spy.getDeleted(emit); expect(del).toEqual(['Deleted "C"']); + done(); }); }); - it('never remove top level plugins if they are a dependency', function() { - runs(function() { - uninstallPromise( uninstall.uninstallPlugin('A', plugins_install_dir2) ); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { + it('Test 009 : never remove top level plugins if they are a dependency', function(done) { + uninstall.uninstallPlugin('A', plugins_install_dir2) + .then(function() { var del = common.spy.getDeleted(emit); - expect(del).toEqual([ 'Deleted "D"', 'Deleted "A"' ]); + done(); }); }); - it('should not remove dependent plugin if it was installed after as top-level', function(done) { - runs(function() { - uninstallPromise( uninstall.uninstallPlugin('A', plugins_install_dir3) ); - }); - waitsFor(function() { return done; }, 'promise never resolved', 200); - runs(function() { + it('Test 010 : should not remove dependent plugin if it was installed after as top-level', function(done) { + uninstall.uninstallPlugin('A', plugins_install_dir3) + .then(function() { var del = common.spy.getDeleted(emit); - expect(del).toEqual([ 'Deleted "D"', 'Deleted "A"' ]); + done(); }); }); }); @@ -309,26 +286,25 @@ describe('uninstall', function() { rm = spyOn(shell, 'rm').and.returnValue(true); done = false; }); - + describe('failure', function() { - it('should throw if platform is unrecognized', function(done) { - uninstall('atari', project, 'SomePlugin').then(function(result){ + it('Test 011 : should throw if platform is unrecognized', function(done) { + return uninstall('atari', project, 'SomePlugin') + .then(function(result){ expect(false).toBe(true); done(); - }, - function err(errMsg) { - expect(clone).toHaveBeenCalledWith(url, temp, dir, ref, undefined); - expect(save_metadata).toHaveBeenCalled(); + }).fail(function err (errMsg) { + expect(errMsg.toString()).toContain('atari not supported.'); done(); }); }, 6000); - it('should throw if plugin is missing', function(done) { - uninstall('android', project, 'SomePluginThatDoesntExist').then(function(result){ + it('Test 012 : should throw if plugin is missing', function(done) { + uninstall('android', project, 'SomePluginThatDoesntExist') + .then(function(result){ expect(false).toBe(true); done(); - }, - function err(errMsg) { + }).fail(function err (errMsg) { expect(errMsg.toString()).toContain('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?'); done(); }); @@ -337,11 +313,9 @@ describe('uninstall', function() { }); describe('end', function() { - it('end', function() { - done = false; - promise.then(function(){ - return uninstall('android', project, plugins['org.test.plugins.dummyplugin']); - }).then(function(){ + it('Test 013 : end', function(done) { + return uninstall('android', project, plugins['org.test.plugins.dummyplugin']) + .then(function(){ // Fails... A depends on return uninstall('android', project, plugins['C']); }).fail(function(err) { @@ -352,10 +326,8 @@ describe('end', function() { }).fin(function(err){ if(err) plugman.emit('error', err); - shell.rm('-rf', project, project2, project3); - done = true; + done(); }); - waitsFor(function() { return done; }, 'promise never resolved', 500); }); }); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/util/csproj.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/util/csproj.spec.js b/cordova-lib/spec-plugman/util/csproj.spec.js index 2b18715..5e1af7a 100644 --- a/cordova-lib/spec-plugman/util/csproj.spec.js +++ b/cordova-lib/spec-plugman/util/csproj.spec.js @@ -23,12 +23,12 @@ var wp8_project = path.join(__dirname, '..', 'projects', 'wp8'), example_csproj = path.join(wp8_project, 'CordovaAppProj.csproj'); describe('csproj', function() { - it('should throw if passed in an invalid xml file path ref', function() { + it('Test 001 : should throw if passed in an invalid xml file path ref', function() { expect(function() { new csproj('blahblah'); }).toThrow(); }); - it('should successfully parse a valid csproj file into an xml document', function() { + it('Test 002 : should successfully parse a valid csproj file into an xml document', function() { var doc; expect(function() { doc = new csproj(example_csproj); @@ -50,22 +50,22 @@ describe('csproj', function() { describe('add method', function() { var test_csproj = new csproj(example_csproj); - it('should properly add .xaml files', function() { + it('Test 003 : should properly add .xaml files', function() { test_csproj.addSourceFile(page_test); expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]')).toBeTruthy(); expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/Generator').text).toEqual('MSBuild:Compile'); expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]/SubType').text).toEqual('Designer'); }); - it('should properly add .xaml.cs files', function() { + it('Test 004 : should properly add .xaml.cs files', function() { test_csproj.addSourceFile(page_test_cs); expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]')).toBeTruthy(); expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]/DependentUpon').text).toEqual('PageTest.xaml'); }); - it('should properly add .cs files', function() { + it('Test 005 : should properly add .cs files', function() { test_csproj.addSourceFile(file_test); expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\FileTest.cs"]')).toBeTruthy(); }); - it('should properly add content files', function() { + it('Test 006 : should properly add content files', function() { test_csproj.addSourceFile(content_test); expect(test_csproj.xml.getroot().find('.//Content[@Include="src\\Content.img"]')).toBeTruthy(); }); @@ -73,23 +73,23 @@ describe('csproj', function() { describe('remove method', function() { var test_csproj = new csproj(example_csproj); - it('should properly remove .xaml pages', function() { + it('Test 007 : should properly remove .xaml pages', function() { test_csproj.removeSourceFile(page_test); expect(test_csproj.xml.getroot().find('.//Page[@Include="src\\UI\\PageTest.xaml"]')).toBeFalsy(); }); - it('should properly remove .xaml.cs files', function() { + it('Test 008 : should properly remove .xaml.cs files', function() { test_csproj.removeSourceFile(page_test_cs); expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\UI\\PageTest.xaml.cs"]')).toBeFalsy(); }); - it('should properly remove .cs files', function() { + it('Test 009 : should properly remove .cs files', function() { test_csproj.removeSourceFile(file_test); expect(test_csproj.xml.getroot().find('.//Compile[@Include="src\\FileTest.cs"]')).toBeFalsy(); }); - it('should properly remove content files', function() { + it('Test 010 : should properly remove content files', function() { test_csproj.removeSourceFile(content_test); expect(test_csproj.xml.getroot().find('.//Content[@Include="src\\Content.img"]')).toBeFalsy(); }); - it('should remove all empty ItemGroup\'s', function() { + it('Test 011 : should remove all empty ItemGroup\'s', function() { test_csproj.removeSourceFile(page_test); test_csproj.removeSourceFile(page_test_cs); test_csproj.removeSourceFile(lib_test); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/util/dependencies.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/util/dependencies.spec.js b/cordova-lib/spec-plugman/util/dependencies.spec.js index 2dd581a..5ad9f36 100644 --- a/cordova-lib/spec-plugman/util/dependencies.spec.js +++ b/cordova-lib/spec-plugman/util/dependencies.spec.js @@ -24,7 +24,7 @@ var PluginInfoProvider = require('cordova-common').PluginInfoProvider; describe('dependency module', function() { describe('generateDependencyInfo method', function() { - it('should return a list of top-level plugins based on what is inside a platform.json file', function() { + it('Test 001 : should return a list of top-level plugins based on what is inside a platform.json file', function() { var tlps = { 'hello':'', 'isitme':'', @@ -38,11 +38,11 @@ describe('dependency module', function() { Object.keys(tlps).forEach(function(k) { pluginInfoProvider.put({id:k, dir: path.join('plugins_dir', k), getDependencies: function() {return[];}}); }); - spyOn(xml_helpers, 'parseElementtreeSync').andReturn({findall:function(){}}); + spyOn(xml_helpers, 'parseElementtreeSync').and.returnValue({findall:function(){}}); var obj = dependencies.generateDependencyInfo(platformJson, 'plugins_dir', pluginInfoProvider); expect(obj.top_level_plugins).toEqual(Object.keys(tlps)); }); - it('should return a dependency graph for the plugins', function() { + it('Test 002 : should return a dependency graph for the plugins', function() { var tlps = { 'A':'', 'B':'' http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-lib/spec-plugman/wrappers.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/wrappers.spec.js b/cordova-lib/spec-plugman/wrappers.spec.js index 30218be..b5877f8 100644 --- a/cordova-lib/spec-plugman/wrappers.spec.js +++ b/cordova-lib/spec-plugman/wrappers.spec.js @@ -33,13 +33,13 @@ describe('callback wrapper', function() { raw = spyOn(plugman.raw, call); }); - it('should work with no callback and success', function() { + it('Test 001 : should work with no callback and success', function() { raw.and.returnValue(Q()); plugman[call](); expect(raw).toHaveBeenCalled(); }); - it('should call the callback on success', function(done) { + it('Test 002 : should call the callback on success', function(done) { raw.and.returnValue(Q(1)); plugman[call](function(err) { expect(err).toBeUndefined(); @@ -47,7 +47,7 @@ describe('callback wrapper', function() { }); }); - it('should call the callback with the error on failure', function(done) { + it('Test 003 : should call the callback with the error on failure', function(done) { var err = new Error('junk'); raw.and.callFake(function() { return Q.reject(err); }); plugman[call](function(err) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org