it('should call graftXMLOverwrite for every new config.xml config munge with mode \'overwrite\' it introduces', function () { const platformJson = PlatformJson.load(plugins_dir, 'android'); const spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true); const munger = new configChanges.PlatformMunger('android', temp, platformJson); munger.add_config_changes(cfg, true); expect(spy.calls.count()).toEqual(1); expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk'); });
it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function () { fs.copySync(android_two_project, temp); // install a plugin const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {}); const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); // set up an uninstall for the same plugin platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin'); const spy = spyOn(fs, 'readFileSync').and.callThrough(); munger.process(plugins_dir); expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8'); });
it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function () { const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {}); const spy = spyOn(fs, 'readFileSync').and.callThrough(); const 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 validate the transferAmount in the formData is big enough', inject([SendPageDataService], (service: SendPageDataService) => { //minTransferAmount is ok spyOn(service, 'getMinTransferAmount').and.returnValue(5) this.testDataBundle.transferAmount = 10 service.validateFormData(this.testDataBundle) expect(this.testDataBundle.errors.indexOf('transferTooSmall')).toBe(-1) //minTransferAmount is not ok this.testDataBundle.transferAmount = 1 service.validateFormData(this.testDataBundle) expect(this.testDataBundle.errors.indexOf('transferTooSmall')).toBe(0) }));
describe('resolveResourceUrl', function () { let fakeEvent = {}; const resolvedBasePath = 'http://resolved/to/path'; beforeEach(function () { spyOn(sut, 'getResourceUrlFromEvent').and.returnValue(resolvedBasePath); }); it('returns a resolved resource URL with resource UUID', function () { let uuid = '80A04C5B-8B2C-407D-8060-A9B4150DDFE5'; expect(sut.resolveResourceUrl(fakeEvent, uuid)).toEqual(resolvedBasePath + '/' + uuid); }); });
it('Test 014 : should generate config munges for queued plugins', function () { fs.copySync(android_two_project, temp); const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }]; const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); const spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({}); munger.process(plugins_dir); expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {}); });
it('should be able to clear it\'s data', inject([SendPageDataService], (service: SendPageDataService) => { this.blankBundle = service.dataBundle service.dataBundle = this.testDataBundle //fill with data spyOn(service.dataSubject, 'next').and.stub() service.clearData(true) expect(service.dataBundle).toEqual({errors: []}) expect(service.dataSubject.next).toHaveBeenCalledWith(service.dataBundle) }));
it('should pass data into the dataSubject', inject([SendPageDataService], (service: SendPageDataService) => { spyOn(service.dataSubject, 'next').and.stub() service.dataBundle = this.testDataBundle service.dataStored = false service.getData() expect(service.dataSubject.next).not.toHaveBeenCalled() service.dataStored = true service.getData() expect(service.dataSubject.next).toHaveBeenCalledWith(service.dataBundle) }));
it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function () { install_plugin(editconfigplugin); const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); const spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true); const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); expect(spy.calls.count()).toEqual(1); expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity'); });
it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function () { install_plugin(configplugin); const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.configtest', {}); const spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true); const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); expect(spy.calls.count()).toEqual(1); });
it('should validate the transferAmount in a the formData is a number', inject([SendPageDataService], (service: SendPageDataService) => { spyOn(service, 'getMinTransferAmount').and.returnValue(0) //Is a number this.testDataBundle.transferAmount = 1 service.validateFormData(this.testDataBundle) expect(this.testDataBundle.errors.indexOf('invalidTransferAmount')).toBe(-1) //Not a number this.testDataBundle.transferAmount = 'five' service.validateFormData(this.testDataBundle) expect(this.testDataBundle.errors.indexOf('invalidTransferAmount')).toBe(0) }));
it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function () { install_plugin(editconfigplugin); const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {}); const spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true); const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); 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 for every new config.xml config munge with mode \'merge\' it introduces', function () { const platformJson = PlatformJson.load(plugins_dir, 'android'); const spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true); const munger = new configChanges.PlatformMunger('android', temp, platformJson); munger.add_config_changes(cfg, true); expect(spy.calls.count()).toEqual(1); expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk'); });