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('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'); });
describe('addLevel 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); expect(logger.debug).toEqual(jasmine.any(Function)); logger.debug('debug message'); expect(logger.log).toHaveBeenCalledWith('debug', 'debug message'); }); it('Test 006 : should not add a shortcut method fi the property with the same name already exists', function () { const logMethod = logger.log; logger.addLevel('log', 500); expect(logger.log).toBe(logMethod); // "log" method remains unchanged }); });
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 025 : should resolve wildcard config-file targets to the project, if applicable', function () { fs.copySync(ios_config_xml, temp); install_plugin(cbplugin); const platformJson = PlatformJson.load(plugins_dir, 'ios'); platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.childbrowser', {}); const spy = spyOn(fs, 'readFileSync').and.callThrough(); const munger = new configChanges.PlatformMunger('ios', temp, platformJson, pluginInfoProvider); munger.process(plugins_dir); expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf8'); });
expect(enterSpy).toHaveBeenCalledWith('1') })
expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8'); expect(fs.writeFileSync).not.toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8'); }); }); expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8'); expect(fs.writeFileSync).toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8'); }); });
stack.push(stack.createAction(third_spy, third_args, function () {}, [])); stack.process('android', android_one_project); expect(first_spy).toHaveBeenCalledWith(first_args[0]); expect(second_spy).toHaveBeenCalledWith(second_args[0]); expect(third_spy).toHaveBeenCalledWith(third_args[0]); }); it('Test 002 : should revert processed actions if an exception occurs', function () { expect(error).toEqual(process_err); expect(first_spy).toHaveBeenCalledWith(first_args[0]); expect(second_spy).toHaveBeenCalledWith(second_args[0]); expect(third_spy).not.toHaveBeenCalledWith(third_args[0]); expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]); }); });
expect(converter.toCelsius).toHaveBeenCalledWith(32, 1) expect(value).toBeConverted({ fahrenheit: 32,
expect(window.fetch).toHaveBeenCalledWith(GROUPS_API_URL) expect(res).toEqualImmutable(Immutable.fromJS(groups)) done() .then((res) => { const url = template(GROUPS_BY_ID_API_URL)({ids: ['1', '2']}) expect(window.fetch).toHaveBeenCalledWith(url) expect(res).toEqualImmutable(Immutable.fromJS(groups)) done() expect(window.fetch).toHaveBeenCalledWith(USERS_API_URL) expect(res).toEqualImmutable(Immutable.fromJS(users)) done() .then((res) => { const url = template(USERS_BY_ID_API_URL)({ids: ['1', '2']}) expect(window.fetch).toHaveBeenCalledWith(url) expect(res).toEqualImmutable(Immutable.fromJS(users)) done()
expect(logSpy).toHaveBeenCalledWith('a test message'); }); expect(logSpy).toHaveBeenCalledWith('forwarding test message'); }); expect(logSpy).toHaveBeenCalledWith('test message #1');
.progress(progressSpy) .then(function () { expect(progressSpy).toHaveBeenCalledWith({ stdout: jasmine.any(String) }); }); }); fail('Expected promise to be rejected'); }, () => { expect(progressSpy).toHaveBeenCalledWith({ stderr: jasmine.any(String) }); }); });
uuidMethod: uuidMock }); expect(loggerSpy.error).toHaveBeenCalledWith( "Notification validation failed for: ", jasmine.any(Object)
expect(window.fetch).toHaveBeenCalledWith(GROUPS_API_URL) expect(res).toEqualImmutable(Immutable.fromJS(groups)) done() .then((res) => { const url = template(GROUPS_BY_ID_API_URL)({ids: ['1', '2']}) expect(window.fetch).toHaveBeenCalledWith(url) expect(res).toEqualImmutable(Immutable.fromJS(groups)) done() expect(window.fetch).toHaveBeenCalledWith(USERS_API_URL) expect(res).toEqualImmutable(Immutable.fromJS(users)) done() .then((res) => { const url = template(USERS_BY_ID_API_URL)({ids: ['1', '2']}) expect(window.fetch).toHaveBeenCalledWith(url) expect(res).toEqualImmutable(Immutable.fromJS(users)) done()