fixjasmine : CB-12018 : fixed jasmine tests to work with uninstallPlugin and removed waitsFor/runs, updated promise syntax, calls.reset, and labled tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b33e222d Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b33e222d Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b33e222d Branch: refs/heads/fetch-1.0.x Commit: b33e222d9af66e3a54360625be8f19fb9c14deea Parents: 1fa012f Author: audreyso <a...@adobe.com> Authored: Mon Dec 19 09:45:27 2016 -0800 Committer: audreyso <a...@adobe.com> Committed: Tue Jan 10 11:18:54 2017 -0800 ---------------------------------------------------------------------- cordova-common/spec/ActionStack.spec.js | 16 +- .../spec/ConfigChanges/ConfigChanges.spec.js | 140 ++++---- .../spec/ConfigParser/ConfigParser.spec.js | 84 ++--- cordova-common/spec/CordovaCheck.spec.js | 14 +- cordova-common/spec/CordovaLogger.spec.js | 34 +- cordova-common/spec/FileUpdater.spec.js | 74 ++-- cordova-common/spec/PlatformJson.spec.js | 30 +- .../spec/PluginInfo/PluginInfo.spec.js | 4 +- .../spec/PluginInfo/PluginInfoProvider.spec.js | 2 +- cordova-common/spec/PluginManager.spec.js | 31 +- cordova-common/spec/events.spec.js | 6 +- cordova-common/spec/superspawn.spec.js | 6 +- cordova-common/spec/util/xml-helpers.spec.js | 86 ++--- cordova-lib/spec-cordova/HooksRunner.spec.js | 52 +-- cordova-lib/spec-cordova/build.spec.js | 22 +- cordova-lib/spec-cordova/compile.spec.js | 22 +- cordova-lib/spec-cordova/create.spec.js | 6 +- cordova-lib/spec-cordova/emulate.spec.js | 22 +- cordova-lib/spec-cordova/helpers.js | 6 +- cordova-lib/spec-cordova/lazy_load.spec.js | 26 +- .../metadata/android_parser.spec.js | 32 +- .../metadata/blackberry_parser.spec.js | 16 +- .../metadata/browser_parser.spec.js | 6 +- .../metadata/firefoxos_parser.spec.js | 26 +- .../spec-cordova/metadata/ios_parser.spec.js | 50 +-- .../metadata/parserhelper/preferences.spec.js | 10 +- .../spec-cordova/metadata/webos_parser.spec.js | 10 +- .../metadata/windows_parser.spec.js | 26 +- .../spec-cordova/metadata/wp8_parser.spec.js | 38 +- cordova-lib/spec-cordova/platform.spec.ios.js | 2 +- cordova-lib/spec-cordova/platform.spec.js | 24 +- .../platforms/PlatformApiPoly.spec.js | 28 +- .../spec-cordova/platforms/platforms.spec.js | 4 +- cordova-lib/spec-cordova/plugin.spec.js | 41 ++- cordova-lib/spec-cordova/plugin_fetch.spec.js | 50 +-- .../spec-cordova/plugin_package_parse.spec.js | 10 +- cordova-lib/spec-cordova/plugin_parser.spec.js | 4 +- cordova-lib/spec-cordova/prepare.spec.js | 49 ++- .../spec-cordova/project-metadata-apis.spec.js | 4 +- cordova-lib/spec-cordova/run.spec.js | 30 +- cordova-lib/spec-cordova/save.spec.js | 68 ++-- cordova-lib/spec-cordova/serve.spec.js | 9 +- cordova-lib/spec-cordova/util.spec.js | 54 +-- cordova-lib/spec-cordova/wrappers.spec.js | 6 +- cordova-lib/spec-plugman/add_platform.spec.js | 14 +- cordova-lib/spec-plugman/common.js | 20 +- cordova-lib/spec-plugman/config.spec.js | 2 +- cordova-lib/spec-plugman/create.spec.js | 35 +- cordova-lib/spec-plugman/fetch.spec.js | 72 ++-- cordova-lib/spec-plugman/info.spec.js | 2 +- cordova-lib/spec-plugman/install.spec.js | 311 +++++++---------- cordova-lib/spec-plugman/owner.spec.js | 2 +- .../spec-plugman/platforms/android.spec.js | 43 +-- .../spec-plugman/platforms/blackberry10.spec.js | 26 +- .../spec-plugman/platforms/common.spec.js | 36 +- cordova-lib/spec-plugman/platforms/ios.spec.js | 120 +++---- .../spec-plugman/platforms/tizen.spec.js | 4 +- .../spec-plugman/platforms/windows.spec.js | 346 +++++++++++++++---- cordova-lib/spec-plugman/platforms/wp8.spec.js | 31 +- .../spec-plugman/registry/registry.spec.js | 64 ++-- cordova-lib/spec-plugman/search.spec.js | 2 +- cordova-lib/spec-plugman/uninstall.spec.js | 168 ++++----- cordova-lib/spec-plugman/util/csproj.spec.js | 22 +- .../spec-plugman/util/dependencies.spec.js | 6 +- cordova-lib/spec-plugman/wrappers.spec.js | 6 +- 65 files changed, 1385 insertions(+), 1227 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/ActionStack.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/ActionStack.spec.js b/cordova-common/spec/ActionStack.spec.js index b432e21..e0b7d7d 100644 --- a/cordova-common/spec/ActionStack.spec.js +++ b/cordova-common/spec/ActionStack.spec.js @@ -26,7 +26,7 @@ describe('action-stack', function() { stack = new action_stack(); }); describe('processing of actions', function() { - it('should process actions one at a time until all are done', function() { + it('Test 001 : should process actions one at a time until all are done', function() { var first_spy = jasmine.createSpy(); var first_args = [1]; var second_spy = jasmine.createSpy(); @@ -41,7 +41,7 @@ describe('action-stack', function() { expect(second_spy).toHaveBeenCalledWith(second_args[0]); expect(third_spy).toHaveBeenCalledWith(third_args[0]); }); - it('should revert processed actions if an exception occurs', function() { + it('Test 002 : should revert processed actions if an exception occurs', function(done) { spyOn(console, 'log'); var first_spy = jasmine.createSpy(); var first_args = [1]; @@ -59,11 +59,11 @@ describe('action-stack', function() { stack.push(stack.createAction(third_spy, third_args, function(){}, [])); // process should throw var error; - runs(function() { - stack.process('android', android_one_project).fail(function(err) { error = err; }); - }); - waitsFor(function(){ return error; }, 'process promise never resolved', 500); - runs(function() { + stack.process('android', android_one_project) + .then(function(something){ + expect(false).toBe(true); + }).fail(function(err){ + error = err; expect(error).toEqual(process_err); // first two actions should have been called, but not the third expect(first_spy).toHaveBeenCalledWith(first_args[0]); @@ -71,7 +71,7 @@ describe('action-stack', function() { expect(third_spy).not.toHaveBeenCalledWith(third_args[0]); // first reverter should have been called after second action exploded expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]); - }); + }).fin(done); }); }); }); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js b/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js index 11651a2..a615b21 100644 --- a/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js +++ b/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js @@ -68,14 +68,14 @@ describe('config-changes module', function() { describe('queue methods', function() { describe('addInstalledPluginToPrepareQueue', function() { - it('should append specified plugin to platform.json', function() { + it('Test 001 : should append specified plugin to platform.json', function() { var platformJson = new PlatformJson(null, 'android', null); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {}); var json = platformJson.root; expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin'); expect(json.prepare_queue.installed[0].vars).toEqual({}); }); - it('should append specified plugin with any variables to platform.json', function() { + it('Test 002 : should append specified plugin with any variables to platform.json', function() { var platformJson = new PlatformJson(null, 'android', null); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {'dude':'man'}); var json = platformJson.root; @@ -85,7 +85,7 @@ describe('config-changes module', function() { }); describe('addUninstalledPluginToPrepareQueue', function() { - it('should append specified plugin to platform.json', function() { + it('Test 003 : should append specified plugin to platform.json', function() { var platformJson = new PlatformJson(null, 'android', null); platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin'); var json = platformJson.root; @@ -95,14 +95,14 @@ describe('config-changes module', function() { }); describe('load method', function() { - it('should return an empty config json object if file doesn\'t exist', function() { + it('Test 004 : should return an empty config json object if file doesn\'t exist', function() { var platformJson = PlatformJson.load(plugins_dir, 'android'); expect(platformJson.root).toBeDefined(); expect(platformJson.root.prepare_queue).toBeDefined(); expect(platformJson.root.config_munge).toBeDefined(); expect(platformJson.root.installed_plugins).toBeDefined(); }); - it('should return the json file if it exists', function() { + it('Test 005 : should return the json file if it exists', function() { var filepath = path.join(plugins_dir, 'android.json'); var json = { prepare_queue: {installed: [], uninstalled: []}, @@ -116,7 +116,7 @@ describe('config-changes module', function() { }); describe('save method', function() { - it('should write out specified json', function() { + it('Test 006 : should write out specified json', function() { var filepath = path.join(plugins_dir, 'android.json'); var platformJson = new PlatformJson(filepath, 'android', {foo:true}); platformJson.save(); @@ -129,7 +129,7 @@ describe('config-changes module', function() { beforeEach(function() { shell.cp('-rf', android_two_project, temp); }); - it('should return a flat config hierarchy for simple, one-off config changes', function() { + it('Test 007 : should return a flat config hierarchy for simple, one-off config changes', function() { var xml; var dummy_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(dummyplugin, 'plugin.xml'), 'utf-8'))); var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); @@ -150,7 +150,7 @@ describe('config-changes module', function() { xml = innerXML(xml); expect(get_munge_change(munge, 'res/xml/config.xml', '/cordova/plugins', xml).count).toEqual(1); }); - it('should split out multiple children of config-file elements into individual leaves', function() { + it('Test 008 : should split out multiple children of config-file elements into individual leaves', function() { var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME: 'com.alunny.childapp'}); expect(munge.files['AndroidManifest.xml']).toBeDefined(); @@ -165,23 +165,23 @@ describe('config-changes module', function() { expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.alunny.childapp.permission.C2D_MESSAGE" />')).toBeDefined(); expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />')).toBeDefined(); }); - it('should not use xml comments as config munge leaves', function() { + it('Test 009 : should not use xml comments as config munge leaves', function() { var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {}); expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!--library-->')).not.toBeDefined(); expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!-- GCM connects to Google Services. -->')).not.toBeDefined(); }); - it('should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function() { + it('Test 010 : should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function() { var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(configplugin), {}); expect(get_munge_change(munge, 'res/xml/config.xml', '/widget', '<poop />').count).toEqual(2); }); - it('should take into account interpolation variables', function() { + it('Test 011 : should take into account interpolation variables', function() { var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME:'ca.filmaj.plugins'}); expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="ca.filmaj.plugins.permission.C2D_MESSAGE" />')).toBeDefined(); }); - it('should create munges for platform-agnostic config.xml changes', function() { + it('Test 012 : should create munges for platform-agnostic config.xml changes', function() { var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider); var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {}); expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="build.phonegap.com" />')).toBeDefined(); @@ -194,12 +194,12 @@ describe('config-changes module', function() { beforeEach(function() { shell.cp('-rf', dummyplugin, plugins_dir); }); - it('should generate config munges for queued plugins', function() { + it('Test 014 : should generate config munges for queued plugins', function() { shell.cp('-rf', android_two_project, temp); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}]; var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); - var spy = spyOn(munger, 'generate_plugin_config_munge').andReturn({}); + var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({}); munger.process(plugins_dir); expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {}); }); @@ -208,96 +208,96 @@ describe('config-changes module', function() { beforeEach(function() { shell.cp('-rf', android_two_project, temp); }); - it('should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function() { + it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function() { var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}]; - var spy = spyOn(xml_helpers, 'graftXML').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(4); - expect(spy.argsForCall[0][2]).toEqual('/*'); - expect(spy.argsForCall[1][2]).toEqual('/*'); - expect(spy.argsForCall[2][2]).toEqual('/manifest/application'); - expect(spy.argsForCall[3][2]).toEqual('/cordova/plugins'); + expect(spy.calls.count()).toEqual(4); + expect(spy.calls.argsFor(0)[2]).toEqual('/*'); + expect(spy.calls.argsFor(1)[2]).toEqual('/*'); + expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application'); + expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins'); }); - it('should not call graftXML for a config munge that already exists from another plugin', function() { + it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function() { shell.cp('-rf', configplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.configtest', {}); - var spy = spyOn(xml_helpers, 'graftXML').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(1); + expect(spy.calls.count()).toEqual(1); }); - it('should not call graftXML for a config munge targeting a config file that does not exist', function() { + it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function() { var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {}); - var spy = spyOn(fs, 'readFileSync').andCallThrough(); + var spy = spyOn(fs, 'readFileSync').and.callThrough(); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8'); }); - it('should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function() { + it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function() { shell.cp('-rf', editconfigplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); - var spy = spyOn(xml_helpers, 'graftXMLMerge').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(1); - expect(spy.argsForCall[0][2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); + expect(spy.calls.count()).toEqual(1); + expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); }); - it('should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function() { + it('Test 019 : should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function() { shell.cp('-rf', editconfigplugin, plugins_dir); shell.cp('-rf', editconfigplugin_two, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true); - var spy = spyOn(xml_helpers, 'graftXMLMerge').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(3); - expect(spy.argsForCall[0][2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); - expect(spy.argsForCall[1][2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); - expect(spy.argsForCall[2][2]).toEqual('/manifest/uses-sdk'); + expect(spy.calls.count()).toEqual(3); + expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); + expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); + expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/uses-sdk'); }); - it('should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function() { + it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function() { shell.cp('-rf', editconfigplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); - var spy = spyOn(xml_helpers, 'graftXMLOverwrite').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(1); - expect(spy.argsForCall[0][2]).toEqual('/manifest/application/activity'); + expect(spy.calls.count()).toEqual(1); + expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity'); }); - it('should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function() { + it('Test 021 : should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function() { shell.cp('-rf', editconfigplugin, plugins_dir); shell.cp('-rf', editconfigplugin_two, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true); - var spy = spyOn(xml_helpers, 'graftXMLOverwrite').andReturn(true); + var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true); var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(2); - expect(spy.argsForCall[0][2]).toEqual('/manifest/application/activity'); - expect(spy.argsForCall[1][2]).toEqual('/manifest/application/activity[@android:name=\'ChildApp\']'); + expect(spy.calls.count()).toEqual(2); + expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity'); + expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'ChildApp\']'); }); - it('should not install plugin when there are edit-config conflicts', function() { + it('Test 022 : should not install plugin when there are edit-config conflicts', function() { shell.cp('-rf', editconfigplugin, plugins_dir); shell.cp('-rf', editconfigplugin_two, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); @@ -309,7 +309,7 @@ describe('config-changes module', function() { }); }); describe('of plist config files', function() { - it('should write empty string nodes with no whitespace', function() { + it('Test 023 : should write empty string nodes with no whitespace', function() { shell.cp('-rf', ios_config_xml, temp); shell.cp('-rf', varplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'ios'); @@ -317,7 +317,7 @@ describe('config-changes module', function() { configChanges.process(plugins_dir, temp, 'ios', platformJson, pluginInfoProvider); expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n <string\/>/m); }); - it('should merge dictionaries and arrays, removing duplicates', function() { + it('Test 024 : should merge dictionaries and arrays, removing duplicates', function() { shell.cp('-rf', ios_config_xml, temp); shell.cp('-rf', plistplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'ios'); @@ -328,18 +328,18 @@ describe('config-changes module', function() { expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/); }); }); - it('should resolve wildcard config-file targets to the project, if applicable', function() { + it('Test 025 : should resolve wildcard config-file targets to the project, if applicable', function() { shell.cp('-rf', ios_config_xml, temp); shell.cp('-rf', cbplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'ios'); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.childbrowser', {}); - var spy = spyOn(fs, 'readFileSync').andCallThrough(); + var spy = spyOn(fs, 'readFileSync').and.callThrough(); var munger = new configChanges.PlatformMunger('ios', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'SampleApp-Info.plist').replace(/\\/g, '/'), 'utf8'); }); - it('should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function() { + it('Test 026 : should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function() { shell.cp('-rf', android_two_project, temp); shell.cp('-rf', varplugin, plugins_dir); var platformJson = PlatformJson.load(plugins_dir, 'android'); @@ -355,7 +355,7 @@ describe('config-changes module', function() { }); describe(': uninstallation', function() { - it('should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function() { + it('Test 027 : should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function() { shell.cp('-rf', android_two_project, temp); // Run through an "install" @@ -366,15 +366,15 @@ describe('config-changes module', function() { // Now set up an uninstall and make sure prunexml is called properly platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin'); - var spy = spyOn(xml_helpers, 'pruneXML').andReturn(true); + var spy = spyOn(xml_helpers, 'pruneXML').and.returnValue(true); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(4); - expect(spy.argsForCall[0][2]).toEqual('/*'); - expect(spy.argsForCall[1][2]).toEqual('/*'); - expect(spy.argsForCall[2][2]).toEqual('/manifest/application'); - expect(spy.argsForCall[3][2]).toEqual('/cordova/plugins'); + expect(spy.calls.count()).toEqual(4); + expect(spy.calls.argsFor(0)[2]).toEqual('/*'); + expect(spy.calls.argsFor(1)[2]).toEqual('/*'); + expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application'); + expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins'); }); - it('should generate a config munge that interpolates variables into config changes, if applicable', function() { + it('Test 028 : should generate a config munge that interpolates variables into config changes, if applicable', function() { shell.cp('-rf', android_two_project, temp); shell.cp('-rf', varplugin, plugins_dir); // Run through an "install" @@ -385,14 +385,14 @@ describe('config-changes module', function() { // Now set up an uninstall and make sure prunexml is called properly platformJson.addUninstalledPluginToPrepareQueue('com.adobe.vars'); - var spy = spyOn(munger, 'generate_plugin_config_munge').andReturn({}); + var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({}); munger.process(plugins_dir); - var munge_params = spy.mostRecentCall.args; + var munge_params = spy.calls.argsFor(0); expect(munge_params[0]).toEqual(jasmine.any(PluginInfo)); expect(munge_params[0].dir).toEqual(path.join(plugins_dir, 'com.adobe.vars')); expect(munge_params[1]['API_KEY']).toEqual('canucks'); }); - it('should not call pruneXML for a config munge that another plugin depends on', function() { + it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function() { shell.cp('-rf', android_two_no_perms_project, temp); shell.cp('-rf', childrenplugin, plugins_dir); shell.cp('-rf', shareddepsplugin, plugins_dir); @@ -413,7 +413,7 @@ describe('config-changes module', function() { expect(permission).toBeDefined(); expect(permission.attrib['android:name']).toEqual('android.permission.INTERNET'); }); - it('should not call pruneXML for a config munge targeting a config file that does not exist', function() { + it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function() { shell.cp('-rf', android_two_project, temp); // install a plugin var platformJson = PlatformJson.load(plugins_dir, 'android'); @@ -424,12 +424,12 @@ describe('config-changes module', function() { // set up an uninstall for the same plugin platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin'); - var spy = spyOn(fs, 'readFileSync').andCallThrough(); + var spy = spyOn(fs, 'readFileSync').and.callThrough(); munger.process(plugins_dir); expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8'); }); - it('should remove uninstalled plugins from installed plugins list', function() { + it('Test 031 : should remove uninstalled plugins from installed plugins list', function() { shell.cp('-rf', android_two_project, temp); shell.cp('-rf', varplugin, plugins_dir); // install the var plugin @@ -445,7 +445,7 @@ describe('config-changes module', function() { expect(platformJson.root.prepare_queue.uninstalled.length).toEqual(0); expect(platformJson.root.installed_plugins['com.adobe.vars']).not.toBeDefined(); }); - it('should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function() { + it('Test 032 : should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function() { shell.cp('-rf', android_two_project, temp); shell.cp('-rf', editconfigplugin, plugins_dir); @@ -457,12 +457,12 @@ describe('config-changes module', function() { // Now set up an uninstall and make sure pruneXMLMerge is called properly platformJson.addUninstalledPluginToPrepareQueue('org.test.editconfigtest'); - var spy = spyOn(xml_helpers, 'pruneXMLRestore').andReturn(true); + var spy = spyOn(xml_helpers, 'pruneXMLRestore').and.returnValue(true); munger.process(plugins_dir); - expect(spy.calls.length).toEqual(2); - expect(spy.argsForCall[0][1]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); - expect(spy.argsForCall[1][1]).toEqual('/manifest/application/activity'); + expect(spy.calls.count()).toEqual(2); + expect(spy.calls.argsFor(0)[1]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']'); + expect(spy.calls.argsFor(1)[1]).toEqual('/manifest/application/activity'); }); }); }); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/ConfigParser/ConfigParser.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/ConfigParser/ConfigParser.spec.js b/cordova-common/spec/ConfigParser/ConfigParser.spec.js index 22fbc99..240db17 100644 --- a/cordova-common/spec/ConfigParser/ConfigParser.spec.js +++ b/cordova-common/spec/ConfigParser/ConfigParser.spec.js @@ -25,10 +25,10 @@ var path = require('path'), describe('config.xml parser', function () { var readFile; beforeEach(function() { - readFile = spyOn(fs, 'readFileSync').andReturn(xml_contents); + readFile = spyOn(fs, 'readFileSync').and.returnValue(xml_contents); }); - it('should create an instance based on an xml file', function() { + it('Test 001 : should create an instance based on an xml file', function() { var cfg; expect(function () { cfg = new ConfigParser(xml); @@ -44,78 +44,78 @@ describe('config.xml parser', function () { }); describe('package name / id', function() { - it('should get the (default) packagename', function() { + it('Test 002 : should get the (default) packagename', function() { expect(cfg.packageName()).toEqual('io.cordova.hellocordova'); }); - it('should allow setting the packagename', function() { + it('Test 003 : should allow setting the packagename', function() { cfg.setPackageName('this.is.bat.country'); expect(cfg.packageName()).toEqual('this.is.bat.country'); }); }); describe('package name / android-packageName', function() { - it('should get the android packagename', function() { + it('Test 004 : should get the android packagename', function() { expect(cfg.android_packageName()).toEqual('io.cordova.hellocordova.android'); }); }); describe('package name / ios-CFBundleIdentifier', function() { - it('should get the ios packagename', function() { + it('Test 005 : should get the ios packagename', function() { expect(cfg.ios_CFBundleIdentifier()).toEqual('io.cordova.hellocordova.ios'); }); }); describe('version', function() { - it('should get the version', function() { + it('Test 006 : should get the version', function() { expect(cfg.version()).toEqual('0.0.1'); }); - it('should allow setting the version', function() { + it('Test 007 : should allow setting the version', function() { cfg.setVersion('2.0.1'); expect(cfg.version()).toEqual('2.0.1'); }); }); describe('app name', function() { - it('should get the (default) app name', function() { + it('Test 008 : should get the (default) app name', function() { expect(cfg.name()).toEqual('Hello Cordova'); }); - it('should allow setting the app name', function() { + it('Test 009 : should allow setting the app name', function() { cfg.setName('this.is.bat.country'); expect(cfg.name()).toEqual('this.is.bat.country'); }); }); describe('preference', function() { - it('should return the value of a global preference', function() { + it('Test 010 : should return the value of a global preference', function() { expect(cfg.getPreference('fullscreen')).toEqual('true'); }); - it('should return the value of a platform-specific preference', function() { + it('Test 011 : should return the value of a platform-specific preference', function() { expect(cfg.getPreference('android-minSdkVersion', 'android')).toEqual('10'); }); - it('should return an empty string for a non-existing preference', function() { + it('Test 012 : should return an empty string for a non-existing preference', function() { expect(cfg.getPreference('zimzooo!')).toEqual(''); }); }); describe('global preference', function() { - it('should return the value of a global preference', function() { + it('Test 013 : should return the value of a global preference', function() { expect(cfg.getGlobalPreference('orientation')).toEqual('portrait'); }); - it('should return an empty string for a non-existing preference', function() { + it('Test 014 : should return an empty string for a non-existing preference', function() { expect(cfg.getGlobalPreference('foobar')).toEqual(''); }); }); describe('platform-specific preference', function() { - it('should return the value of a platform specific preference', function() { + it('Test 015 : should return the value of a platform specific preference', function() { expect(cfg.getPlatformPreference('orientation', 'android')).toEqual('landscape'); }); - it('should return an empty string when querying for a non-existing preference', function() { + it('Test 016 : should return an empty string when querying for a non-existing preference', function() { expect(cfg.getPlatformPreference('foobar', 'android')).toEqual(''); }); - it('should return an empty string when querying with unsupported platform', function() { + it('Test 017 : should return an empty string when querying with unsupported platform', function() { expect(cfg.getPlatformPreference('orientation', 'foobar')).toEqual(''); }); }); describe('plugin',function(){ - it('should read plugin id list', function() { + it('Test 018 : should read plugin id list', function() { var expectedList = [ 'org.apache.cordova.pluginwithvars', 'org.apache.cordova.pluginwithurl', @@ -132,35 +132,35 @@ describe('config.xml parser', function () { expect(list).toContain(plugin); }); }); - it('should read plugin given id', function(){ + it('Test 019 : should read plugin given id', function(){ var plugin = cfg.getPlugin('org.apache.cordova.justaplugin'); expect(plugin).toBeDefined(); expect(plugin.name).toEqual('org.apache.cordova.justaplugin'); expect(plugin.variables).toBeDefined(); }); - it('should not read plugin given undefined id', function(){ + it('Test 020 : should not read plugin given undefined id', function(){ var plugin = cfg.getPlugin('org.apache.cordova.undefinedplugin'); expect(plugin).not.toBeDefined(); }); - it('should read plugin with src and store it in spec field', function(){ + it('Test 021 : should read plugin with src and store it in spec field', function(){ var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurl'); expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurl'); }); - it('should read plugin with version and store it in spec field', function(){ + it('Test 022 : should read plugin with version and store it in spec field', function(){ var plugin = cfg.getPlugin('org.apache.cordova.pluginwithversion'); expect(plugin.spec).toEqual('1.1.1'); }); - it('should read plugin with source and version and store source in spec field', function(){ + it('Test 023 : should read plugin with source and version and store source in spec field', function(){ var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurlandversion'); expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurlandversion'); }); - it('should read plugin variables', function () { + it('Test 024 : should read plugin variables', function () { var plugin = cfg.getPlugin('org.apache.cordova.pluginwithvars'); expect(plugin.variables).toBeDefined(); expect(plugin.variables.var).toBeDefined(); expect(plugin.variables.var).toEqual('varvalue'); }); - it('should allow adding a new plugin', function(){ + it('Test 025 : should allow adding a new plugin', function(){ cfg.addPlugin({name:'myplugin'}); var plugins = cfg.doc.findall('plugin'); var pluginNames = plugins.map(function(plugin){ @@ -168,7 +168,7 @@ describe('config.xml parser', function () { }); expect(pluginNames).toContain('myplugin'); }); - it('should allow adding features with params', function(){ + it('Test 026 : should allow adding features with params', function(){ cfg.addPlugin({name:'aplugin'}, [{name:'paraname',value:'paravalue'}]); // Additional check for new parameters syntax cfg.addPlugin({name:'bplugin'}, {paraname: 'paravalue'}); @@ -183,7 +183,7 @@ describe('config.xml parser', function () { expect(variables[0].attrib.value).toEqual('paravalue'); }); }); - it('should be able to read legacy feature entries with a version', function(){ + it('Test 027 : should be able to read legacy feature entries with a version', function(){ var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversion'); expect(plugin).toBeDefined(); expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversion'); @@ -191,19 +191,19 @@ describe('config.xml parser', function () { expect(plugin.variables).toBeDefined(); expect(plugin.variables.aVar).toEqual('aValue'); }); - it('should be able to read legacy feature entries with a url', function(){ + it('Test 028 : should be able to read legacy feature entries with a url', function(){ var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureurl'); expect(plugin).toBeDefined(); expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureurl'); expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureurl'); }); - it('should be able to read legacy feature entries with a version and a url', function(){ + it('Test 029 : should be able to read legacy feature entries with a version and a url', function(){ var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversionandurl'); expect(plugin).toBeDefined(); expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversionandurl'); expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureversionandurl'); }); - it('it should remove given plugin', function(){ + it('Test 030 : it should remove given plugin', function(){ cfg.removePlugin('org.apache.cordova.justaplugin'); var plugins = cfg.doc.findall('plugin'); var pluginNames = plugins.map(function(plugin){ @@ -211,7 +211,7 @@ describe('config.xml parser', function () { }); expect(pluginNames).not.toContain('org.apache.cordova.justaplugin'); }); - it('it should remove given legacy feature id', function(){ + it('Test 031 : it should remove given legacy feature id', function(){ cfg.removePlugin('org.apache.cordova.legacyplugin'); var plugins = cfg.doc.findall('feature'); var pluginNames = plugins.map(function(plugin){ @@ -219,15 +219,15 @@ describe('config.xml parser', function () { }); expect(pluginNames).not.toContain('org.apache.cordova.legacyplugin'); }); - it('it should read <access> tag entries', function(){ + it('Test 032 : it should read <access> tag entries', function(){ var accesses = cfg.getAccesses(); expect(accesses.length).not.toEqual(0); }); - it('it should read <allow-navigation> tag entries', function(){ + it('Test 033 : it should read <allow-navigation> tag entries', function(){ var navigations = cfg.getAllowNavigations(); expect(navigations.length).not.toEqual(0); }); - it('it should read <allow-intent> tag entries', function(){ + it('Test 034 : it should read <allow-intent> tag entries', function(){ var intents = cfg.getAllowIntents(); expect(intents.length).not.toEqual(0); }); @@ -239,35 +239,35 @@ describe('config.xml parser', function () { var hasDensityPropertyDefined = function (e) { return !!e.density; }; var hasPlatformPropertyUndefined = function (e) { return !e.platform; }; - it('should fetch shared resources if platform parameter is not specified', function() { + it('Test 035 : should fetch shared resources if platform parameter is not specified', function() { expect(cfg.getStaticResources(null, 'icon').length).toBe(2); expect(cfg.getStaticResources(null, 'icon').every(hasPlatformPropertyUndefined)).toBeTruthy(); }); - it('should fetch platform-specific resources along with shared if platform parameter is specified', function() { + it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function() { expect(cfg.getStaticResources('android', 'icon').length).toBe(5); expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).length).toBe(3); expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyUndefined)).toBeTruthy(); }); - it('should parse resources\' attributes', function() { + it('Test 037 : should parse resources\' attributes', function() { expect(cfg.getStaticResources(null, 'icon').every(hasSrcPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('windows', 'icon').filter(hasPlatformPropertyDefined).every(hasTargetPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy(); }); - it('should have defaultResource property', function() { + it('Test 038 : should have defaultResource property', function() { expect(cfg.getStaticResources(null, 'icon').defaultResource).toBeDefined(); expect(cfg.getStaticResources(null, 'icon').defaultResource.src).toBe('icon.png'); }); - it('should have getDefault method returning defaultResource property', function() { + it('Test 039 : should have getDefault method returning defaultResource property', function() { expect(cfg.getStaticResources(null, 'icon').defaultResource).toEqual(cfg.getStaticResources(null, 'icon').getDefault()); }); - it('should have getBySize method returning resource with size specified or null', function() { + it('Test 040 : should have getBySize method returning resource with size specified or null', function() { expect(cfg.getStaticResources('windows', 'icon').getBySize(128)).toBe(null); expect(cfg.getStaticResources('windows', 'icon').getBySize(72)).toBeDefined(); expect(cfg.getStaticResources('windows', 'icon').getBySize(72).width).toBe(72); @@ -275,7 +275,7 @@ describe('config.xml parser', function () { expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48).height).toBe(48); }); - it('should have getByDensity method returning resource with density specified or null', function() { + it('Test 041 : should have getByDensity method returning resource with density specified or null', function() { expect(cfg.getStaticResources('android', 'icon').getByDensity('hdpi')).toBe(null); expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi')).toBeDefined(); expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi').src).toBe('logo-android.png'); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/CordovaCheck.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/CordovaCheck.spec.js b/cordova-common/spec/CordovaCheck.spec.js index c075f7a..abaaa14 100644 --- a/cordova-common/spec/CordovaCheck.spec.js +++ b/cordova-common/spec/CordovaCheck.spec.js @@ -33,17 +33,17 @@ describe('findProjectRoot method', function() { function removeDir(someDirectory) { shell.rm('-rf', someDirectory); } - it('should return false if it hits the home directory', function() { + it('Test 001 : should return false if it hits the home directory', function() { var somedir = path.join(home, 'somedir'); removeDir(somedir); shell.mkdir(somedir); expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false); }); - it('should return false if it cannot find a .cordova directory up the directory tree', function() { + it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function() { var somedir = path.join(home, '..'); expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false); }); - it('should return the first directory it finds with a .cordova folder in it', function() { + it('Test 003 : should return the first directory it finds with a .cordova folder in it', function() { var somedir = path.join(home,'somedir'); var anotherdir = path.join(somedir, 'anotherdir'); removeDir(somedir); @@ -51,7 +51,7 @@ function removeDir(someDirectory) { shell.mkdir('-p', path.join(somedir, 'www', 'config.xml')); expect(CordovaCheck.findProjectRoot(somedir)).toEqual(somedir); }); - it('should ignore PWD when its undefined', function() { + it('Test 004 : should ignore PWD when its undefined', function() { delete process.env.PWD; var somedir = path.join(home,'somedir'); var anotherdir = path.join(somedir, 'anotherdir'); @@ -62,7 +62,7 @@ function removeDir(someDirectory) { process.chdir(anotherdir); expect(CordovaCheck.findProjectRoot()).toEqual(somedir); }); - it('should use PWD when available', function() { + it('Test 005 : should use PWD when available', function() { var somedir = path.join(home,'somedir'); var anotherdir = path.join(somedir, 'anotherdir'); removeDir(somedir); @@ -72,7 +72,7 @@ function removeDir(someDirectory) { process.chdir(path.sep); expect(CordovaCheck.findProjectRoot()).toEqual(somedir); }); - it('should use cwd as a fallback when PWD is not a cordova dir', function() { + it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function() { var somedir = path.join(home,'somedir'); var anotherdir = path.join(somedir, 'anotherdir'); removeDir(somedir); @@ -82,7 +82,7 @@ function removeDir(someDirectory) { process.chdir(anotherdir); expect(CordovaCheck.findProjectRoot()).toEqual(somedir); }); - it('should ignore platform www/config.xml', function() { + it('Test 007 : should ignore platform www/config.xml', function() { var somedir = path.join(home,'somedir'); var anotherdir = path.join(somedir, 'anotherdir'); removeDir(somedir); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/CordovaLogger.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/CordovaLogger.spec.js b/cordova-common/spec/CordovaLogger.spec.js index 035d717..fb46e73 100644 --- a/cordova-common/spec/CordovaLogger.spec.js +++ b/cordova-common/spec/CordovaLogger.spec.js @@ -24,11 +24,11 @@ var EventEmitter = require('events').EventEmitter; var DEFAULT_LEVELS = ['verbose', 'normal', 'warn', 'info', 'error', 'results']; describe('CordovaLogger class', function() { - it('should be constructable', function () { + it('Test 001 : should be constructable', function () { expect(new CordovaLogger()).toEqual(jasmine.any(CordovaLogger)); }); - it('should expose default levels as constants', function () { + it('Test 002 : should expose default levels as constants', function () { DEFAULT_LEVELS.forEach(function (level) { var constant = level.toUpperCase(); expect(CordovaLogger[constant]).toBeDefined(); @@ -36,7 +36,7 @@ describe('CordovaLogger class', function() { }); }); - it('should return the same instance via "get" method', function () { + it('Test 003 : should return the same instance via "get" method', function () { expect(CordovaLogger.get()).toBeDefined(); expect(CordovaLogger.get()).toBe(CordovaLogger.get()); expect(CordovaLogger.get()).toEqual(jasmine.any(CordovaLogger)); @@ -50,7 +50,7 @@ describe('CordovaLogger class', function() { logger = new CordovaLogger(); }); - it('should have defaults levels', function () { + it('Test 004 : should have defaults levels', function () { DEFAULT_LEVELS.forEach(function (level) { expect(logger.levels[level]).toBeDefined(); expect(logger.levels[level]).toEqual(jasmine.any(Number)); @@ -61,7 +61,7 @@ describe('CordovaLogger class', function() { }); describe('addLevel method', function () { - it('should add a new level and a corresponding shortcut method', function () { + it('Test 005 : should add a new level and a corresponding shortcut method', function () { spyOn(logger, 'log'); logger.addLevel('debug', 100000, 'grey'); expect(logger.levels.debug).toBe(100000); @@ -71,7 +71,7 @@ describe('CordovaLogger class', function() { expect(logger.log).toHaveBeenCalledWith('debug', 'debug message'); }); - it('should not add a shortcut method fi the property with the same name already exists', function () { + it('Test 006 : should not add a shortcut method fi the property with the same name already exists', function () { var logMethod = logger.log; logger.addLevel('log', 500); expect(logger.log).toBe(logMethod); // "log" method remains unchanged @@ -79,19 +79,19 @@ describe('CordovaLogger class', function() { }); describe('setLevel method', function () { - it('should set logger\'s level to \'NORMAL\' if provided level does not exist', function () { + it('Test 007 : should set logger\'s level to \'NORMAL\' if provided level does not exist', function () { logger.setLevel('debug'); expect(logger.logLevel).toBe(CordovaLogger.NORMAL); // default value }); }); describe('subscribe method', function () { - it('should throw if called without EventEmitter instance', function () { + it('Test 008 : should throw if called without EventEmitter instance', function () { expect(function () { logger.subscribe(); }).toThrow(); expect(function () { logger.subscribe(123); }).toThrow(); }); - it('should attach corresponding listeners to supplied emitter', function () { + it('Test 009 : should attach corresponding listeners to supplied emitter', function () { var eventNamesExclusions = { log: 'normal', @@ -128,41 +128,41 @@ describe('CordovaLogger class', function() { logger.stderrCursor = new CursorSpy('stderrCursor'); }); - it('should ignore message if severity is less than logger\'s level', function () { + it('Test 010 : should ignore message if severity is less than logger\'s level', function () { logger.setLevel('error').log('verbose', 'some_messgge'); expect(logger.stdoutCursor.write).not.toHaveBeenCalled(); expect(logger.stderrCursor.write).not.toHaveBeenCalled(); }); - it('should log everything except error messages to stdout', function () { + it('Test 011 : should log everything except error messages to stdout', function () { logger.setLevel('verbose'); DEFAULT_LEVELS.forEach(function (level) { logger.log(level, 'message'); }); // Multiply calls number to 2 because 'write' method is get called twice (with message and EOL) - expect(logger.stdoutCursor.write.calls.length).toBe((DEFAULT_LEVELS.length - 1) * 2); - expect(logger.stderrCursor.write.calls.length).toBe(1 * 2); + expect(logger.stdoutCursor.write.calls.count()).toBe((DEFAULT_LEVELS.length - 1) * 2); + expect(logger.stderrCursor.write.calls.count()).toBe(1 * 2); }); - it('should log Error objects to stderr despite of loglevel', function () { + it('Test 012 : should log Error objects to stderr despite of loglevel', function () { logger.setLevel('verbose').log('verbose', new Error()); expect(logger.stdoutCursor.write).not.toHaveBeenCalled(); expect(logger.stderrCursor.write).toHaveBeenCalled(); }); - it('should handle CordovaError instances separately from Error ones', function () { + it('Test 013 : should handle CordovaError instances separately from Error ones', function () { var errorMock = new CordovaError(); spyOn(errorMock, 'toString').and.returnValue('error_message'); logger.setLevel('verbose').log('verbose', errorMock); expect(errorMock.toString).toHaveBeenCalled(); - expect(logger.stderrCursor.write.calls[0].args[0]).toBe('Error: error_message'); + expect(logger.stderrCursor.write.calls.argsFor(0)).toMatch('Error: error_message'); }); }); describe('adjustLevel method', function () { - it('should properly adjust log level', function () { + it('Test 014 : should properly adjust log level', function () { var resetLogLevel = function() { logger.setLevel('normal'); }; http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b33e222d/cordova-common/spec/FileUpdater.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/FileUpdater.spec.js b/cordova-common/spec/FileUpdater.spec.js index 5cdab8c..21659d3 100644 --- a/cordova-common/spec/FileUpdater.spec.js +++ b/cordova-common/spec/FileUpdater.spec.js @@ -129,7 +129,7 @@ describe('FileUpdater class', function() { }); describe('updatePathWithStats method', function () { - it('should do nothing when a directory exists at source and target', function () { + it('Test 001 : should do nothing when a directory exists at source and target', function () { var updated = FileUpdater.updatePathWithStats( testSourceDir, mockDirStats(), testTargetDir, mockDirStats(), null, nullLogger); @@ -137,7 +137,7 @@ describe('FileUpdater class', function() { expect(mockFs.mkdirPaths.length).toBe(0); expect(mockFs.rmPaths.length).toBe(0); }); - it('should create a directory that exists at source and not at target', function () { + it('Test 002 : should create a directory that exists at source and not at target', function () { var updated = FileUpdater.updatePathWithStats( testSourceDir, mockDirStats(), testTargetDir, null, null, nullLogger); @@ -146,7 +146,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.mkdirPaths[0]).toBe(testTargetDir); }); - it('should remove a directory that exists at target and not at source', function () { + it('Test 003 : should remove a directory that exists at target and not at source', function () { var updated = FileUpdater.updatePathWithStats( testSourceDir, null, testTargetDir, mockDirStats(), null, nullLogger); @@ -156,7 +156,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths[0]).toBe(testTargetDir); }); - it('should copy when a file exists at source and target and times are the same', + it('Test 004 : should copy when a file exists at source and target and times are the same', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now), @@ -166,7 +166,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should copy when a file exists at source and target and target is older', + it('Test 005 : should copy when a file exists at source and target and target is older', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo), @@ -176,7 +176,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should do nothing when a file exists at source and target and target is newer', + it('Test 006 : should do nothing when a file exists at source and target and target is newer', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now), @@ -185,7 +185,7 @@ describe('FileUpdater class', function() { expect(mockFs.cpPaths.length).toBe(0); expect(mockFs.rmPaths.length).toBe(0); }); - it('should copy when a file exists at source and target and forcing update', function () { + it('Test 007 : should copy when a file exists at source and target and forcing update', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now), { all: true }, nullLogger); @@ -194,7 +194,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should copy when a file exists at source and target and target is newer ' + + it('Test 008 : should copy when a file exists at source and target and target is newer ' + 'and forcing update', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now), @@ -204,7 +204,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should copy when a file exists at source and target and source is newer', function () { + it('Test 009 : should copy when a file exists at source and target and source is newer', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo), null, nullLogger); @@ -213,7 +213,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should copy when a file exists at source and not at target', function () { + it('Test 010 : should copy when a file exists at source and not at target', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, null, null, nullLogger); @@ -222,7 +222,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths.length).toBe(0); expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should remove when a file exists at target and not at source', function () { + it('Test 011 : should remove when a file exists at target and not at source', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, null, testTargetFile, mockFileStats(now), null, nullLogger); @@ -232,7 +232,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths[0]).toBe(testTargetFile); }); - it('should remove and mkdir when source is a directory and target is a file', function () { + it('Test 012 : should remove and mkdir when source is a directory and target is a file', function () { var updated = FileUpdater.updatePathWithStats( testSourceDir, mockDirStats(), testTargetDir, mockFileStats(now), null, nullLogger); @@ -243,7 +243,7 @@ describe('FileUpdater class', function() { expect(mockFs.rmPaths[0]).toBe(testTargetDir); expect(mockFs.mkdirPaths[0]).toBe(testTargetDir); }); - it('should remove and copy when source is a file and target is a directory', function () { + it('Test 013 : should remove and copy when source is a file and target is a directory', function () { var updated = FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, mockDirStats(), null, nullLogger); @@ -255,7 +255,7 @@ describe('FileUpdater class', function() { expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]); }); - it('should join the paths when a rootDir is specified', function () { + it('Test 014 : should join the paths when a rootDir is specified', function () { FileUpdater.updatePathWithStats( testSourceFile, mockFileStats(now), testTargetFile, null, { rootDir: testRootDir }, nullLogger); @@ -265,7 +265,7 @@ describe('FileUpdater class', function() { [path.join(testRootDir, testSourceFile), path.join(testRootDir, testTargetFile)]); }); - it('should log dir creation', function () { + it('Test 015 : should log dir creation', function () { var loggedSource = 0; var loggedTarget = 0; var loggedRoot = 0; @@ -280,7 +280,7 @@ describe('FileUpdater class', function() { expect(loggedTarget).toBe(1); expect(loggedRoot).toBe(0); }); - it('should log dir removal', function () { + it('Test 016 : should log dir removal', function () { var loggedSource = 0; var loggedTarget = 0; var loggedRoot = 0; @@ -295,7 +295,7 @@ describe('FileUpdater class', function() { expect(loggedTarget).toBe(1); expect(loggedRoot).toBe(0); }); - it('should log file copy', function () { + it('Test 017 : should log file copy', function () { var loggedSource = 0; var loggedTarget = 0; var loggedRoot = 0; @@ -310,7 +310,7 @@ describe('FileUpdater class', function() { expect(loggedTarget).toBe(1); expect(loggedRoot).toBe(0); }); - it('should log file removal', function () { + it('Test 018: should log file removal', function () { var loggedSource = 0; var loggedTarget = 0; var loggedRoot = 0; @@ -330,7 +330,7 @@ describe('FileUpdater class', function() { }); describe('mapDirectory method', function () { - it('should map an empty directory', function () { + it('Test 019 : should map an empty directory', function () { mockFs.statMap[path.join(testRootDir, testSourceDir)] = testDirStats; mockFs.dirMap[path.join(testRootDir, testSourceDir)] = []; var dirMap = FileUpdater.mapDirectory(testRootDir, testSourceDir, ['**'], []); @@ -338,7 +338,7 @@ describe('FileUpdater class', function() { expect(dirMap[''].subDir).toBe(testSourceDir); expect(dirMap[''].stats).toBe(testDirStats); }); - it('should map a directory with a file', function () { + it('Test 020 : should map a directory with a file', function () { mockFs.statMap[path.join(testRootDir, testSourceDir)] = testDirStats; mockFs.dirMap[path.join(testRootDir, testSourceDir)] = [testSourceFile]; mockFs.statMap[path.join(testRootDir, testSourceDir, testSourceFile)] = testFileStats; @@ -349,7 +349,7 @@ describe('FileUpdater class', function() { expect(dirMap[testSourceFile].subDir).toBe(testSourceDir); expect(dirMap[testSourceFile].stats).toBe(testFileStats); }); - it('should map a directory with a subdirectory', function () { + it('Test 021 : should map a directory with a subdirectory', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSubDir]; mockFs.statMap[path.join(testSourceDir, testSubDir)] = testDirStats; @@ -361,7 +361,7 @@ describe('FileUpdater class', function() { expect(dirMap[testSubDir].subDir).toBe(testSourceDir); expect(dirMap[testSubDir].stats).toBe(testDirStats); }); - it('should map a directory with a file in a nested subdirectory', function () { + it('Test 022 : should map a directory with a file in a nested subdirectory', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSubDir]; mockFs.statMap[path.join(testSourceDir, testSubDir)] = testDirStats; @@ -388,7 +388,7 @@ describe('FileUpdater class', function() { testFileStats); }); - it('should include files that match include globs', function () { + it('Test 023 : should include files that match include globs', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSourceFile, testSourceFile2]; mockFs.statMap[path.join(testSourceDir, testSourceFile)] = testFileStats; @@ -400,7 +400,7 @@ describe('FileUpdater class', function() { expect(dirMap[testSourceFile].subDir).toBe(testSourceDir); expect(dirMap[testSourceFile].stats).toBe(testFileStats); }); - it('should include files in a subdirectory that match include globs', function () { + it('Test 024 : should include files in a subdirectory that match include globs', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSubDir]; mockFs.statMap[path.join(testSourceDir, testSubDir)] = testDirStats; @@ -418,7 +418,7 @@ describe('FileUpdater class', function() { expect(dirMap[path.join(testSubDir, testSourceFile)].subDir).toBe(testSourceDir); expect(dirMap[path.join(testSubDir, testSourceFile)].stats).toBe(testFileStats); }); - it('should exclude paths that match exclude globs', function () { + it('Test 025 : should exclude paths that match exclude globs', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSourceFile, testSourceFile2]; mockFs.statMap[path.join(testSourceDir, testSourceFile)] = testFileStats; @@ -430,7 +430,7 @@ describe('FileUpdater class', function() { expect(dirMap[testSourceFile].subDir).toBe(testSourceDir); expect(dirMap[testSourceFile].stats).toBe(testFileStats); }); - it('should exclude paths that match both exclude and include globs', function () { + it('Test 026 : should exclude paths that match both exclude and include globs', function () { mockFs.statMap[testSourceDir] = testDirStats; mockFs.dirMap[testSourceDir] = [testSubDir]; mockFs.statMap[path.join(testSourceDir, testSubDir)] = testDirStats; @@ -451,7 +451,7 @@ describe('FileUpdater class', function() { var testSourceFileStats = mockFileStats(now); var testSourceFileStats2 = mockFileStats(now); var testSourceFileStats3 = mockFileStats(now); - it('should prepend the target directory on target paths', function () { + it('Test 027 : should prepend the target directory on target paths', function () { var mergedPathMap = FileUpdater.mergePathMaps( [{ '': { subDir: testSourceDir, stats: testDirStats }, @@ -474,7 +474,7 @@ describe('FileUpdater class', function() { path.join(testSourceDir, testTargetFile)); expect(mergedPathMap[testTargetFile].sourceStats).toBe(testSourceFileStats); }); - it('should handle missing source files', function () { + it('Test 028 : should handle missing source files', function () { var mergedPathMap = FileUpdater.mergePathMaps( [{}], { @@ -488,7 +488,7 @@ describe('FileUpdater class', function() { expect(mergedPathMap[testTargetFile].sourcePath).toBeNull(); expect(mergedPathMap[testTargetFile].sourceStats).toBeNull(); }); - it('should handle missing target files', function () { + it('Tets 029 : should handle missing target files', function () { var mergedPathMap = FileUpdater.mergePathMaps( [{ testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }, @@ -503,7 +503,7 @@ describe('FileUpdater class', function() { path.join(testSourceDir, testTargetFile)); expect(mergedPathMap[testTargetFile].sourceStats).toBe(testSourceFileStats); }); - it('should merge three source maps', function () { + it('Test 030 : should merge three source maps', function () { var mergedPathMap = FileUpdater.mergePathMaps( [ { @@ -547,7 +547,7 @@ describe('FileUpdater class', function() { }); describe('updatePath method', function () { - it('should update a path', function () { + it('Test 031 : should update a path', function () { mockFs.statMap[testRootDir] = testDirStats; mockFs.statMap[path.join(testRootDir, testTargetFile)] = testFileStats; mockFs.statMap[path.join(testRootDir, testSourceFile)] = testFileStats2; @@ -562,7 +562,7 @@ describe('FileUpdater class', function() { expect(FileUpdater.updatePathWithStatsCalls[0][4]).toEqual( {rootDir: testRootDir, all: true }); }); - it('should update a path without a separate root directory', function () { + it('Test 032 : should update a path without a separate root directory', function () { mockFs.statMap[testTargetFile] = testFileStats; mockFs.statMap[testSourceFile] = testFileStats2; FileUpdater.updatePathWithStatsResult = false; @@ -575,7 +575,7 @@ describe('FileUpdater class', function() { expect(FileUpdater.updatePathWithStatsCalls[0][3]).toEqual(testFileStats); expect(FileUpdater.updatePathWithStatsCalls[0][4]).toBeUndefined(); }); - it('should update a path when the source doesn\'t exist', function () { + it('Test 033 : should update a path when the source doesn\'t exist', function () { mockFs.statMap[testTargetFile] = testFileStats; var updated = FileUpdater.updatePath(null, testTargetFile); expect(updated).toBe(true); @@ -586,7 +586,7 @@ describe('FileUpdater class', function() { expect(FileUpdater.updatePathWithStatsCalls[0][3]).toEqual(testFileStats); expect(FileUpdater.updatePathWithStatsCalls[0][4]).toBeUndefined(); }); - it('should update a path when the target doesn\'t exist', function () { + it('Test 034 : should update a path when the target doesn\'t exist', function () { mockFs.statMap[testSourceFile] = testFileStats2; var updated = FileUpdater.updatePath(testSourceFile, testTargetFile); expect(updated).toBe(true); @@ -597,7 +597,7 @@ describe('FileUpdater class', function() { expect(FileUpdater.updatePathWithStatsCalls[0][3]).toBeNull(); expect(FileUpdater.updatePathWithStatsCalls[0][4]).toBeUndefined(); }); - it('should create the target\'s parent directory if it doesn\'t exist', + it('Test 035 : should create the target\'s parent directory if it doesn\'t exist', function () { mockFs.statMap[path.join(testRootDir, testSourceFile)] = testFileStats2; var updated = FileUpdater.updatePath( @@ -615,7 +615,7 @@ describe('FileUpdater class', function() { }); describe('mergeAndUpdateDir method', function () { - it('should update files from merged source directories', function () { + it('Test 036 : should update files from merged source directories', function () { mockFs.statMap[testTargetDir] = testDirStats; mockFs.dirMap[testTargetDir] = [testSubDir]; mockFs.statMap[path.join(testTargetDir, testSubDir)] = testDirStats; @@ -686,7 +686,7 @@ describe('FileUpdater class', function() { null); }); - it('should update files from merged source directories - with a rootDir', function () { + it('Test 037 : should update files from merged source directories - with a rootDir', function () { var rootDir = path.join('Users', 'me'); mockFs.statMap[rootDir] = testDirStats; mockFs.dirMap[rootDir] = [testSourceDir, testSourceDir2, testTargetDir]; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org