describe("Test switch register", function() { var subject = new Register(device); it("enable listener", function() { subject.register(); expect(device.buffers.pop().toString()).toEqual(new Buffer('010101', 'hex').toString()); }); });
it('Test 031 : it should remove given legacy feature id', function () { cfg.removePlugin('org.apache.cordova.legacyplugin'); const plugins = cfg.doc.findall('feature'); const pluginNames = plugins.map(function (plugin) { return plugin.attrib.name; }); expect(pluginNames).not.toContain('org.apache.cordova.legacyplugin'); });
describe('package name / android-packageName', function () { it('Test 004 : should get the android packagename', function () { expect(cfg.android_packageName()).toEqual('io.cordova.hellocordova.android'); }); });
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'); });
describe('setPreset', function() { it('should send the right preset recommended by Bosh for the BMM150 magnetometer to the device', function() { for(var i = 0; i< presets.length; i++) { magnetometer.setPreset(presets[i].preset); expect(device.send).toHaveBeenCalled(); expect(device.buffers[0]).toEqual(presets[i].expected[0]); expect(device.buffers[1]).toEqual(presets[i].expected[1]); device.reset(); } }); });
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('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); expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48)).toBeDefined(); expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48).height).toBe(48); });
describe('unsubscribe()', function() { it('should unsubscribe to the magnetometer notification', function() { magnetometer.unsubscribe(); expect(device.send).toHaveBeenCalled(); expect(device.buffers.pop()).toEqual(new Buffer([0x15,0x5,0x0])); }); });
it('Test 040 : should not append duplicate non singelton children', function () { const testXml = et.XML('<widget><preference name="fullscreen" value="true"/></widget>'); xml_helpers.mergeXml(testXml, dstXml, '', true); const testElements = dstXml.findall('preference'); expect(testElements.length).toEqual(2); });
it('Test 033 : should merge platform tags with the correct platform', function () { const testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>'); const origCfg = et.tostring(dstXml); xml_helpers.mergeXml(testXml, dstXml, 'bar', true); expect(et.tostring(dstXml)).not.toEqual(origCfg); const testElement = dstXml.find('testElement'); expect(testElement).toBeDefined(); expect(testElement.attrib.testAttrib).toEqual('value'); expect(testElement.text).toEqual('testTEXT'); });
it('should trigger the subscribtion to READOUT_PAGE_COMPLETED, READOUT_NOTIFY, READOUT_PROGRESS', function() { log.downloadLog(); expect(device.send).toHaveBeenCalledTimes(3); expect(device.buffers[0]).toEqual(new Buffer([0xb,0xd,0x1])); expect(device.buffers[1]).toEqual(new Buffer([0xb,0x7,0x1])); expect(device.buffers[2]).toEqual(new Buffer([0xb,0x8,0x1])); });
it('Test 019 : should read plugin given id', function () { const plugin = cfg.getPlugin('org.apache.cordova.justaplugin'); expect(plugin).toBeDefined(); expect(plugin.name).toEqual('org.apache.cordova.justaplugin'); expect(plugin.variables).toBeDefined(); });
it('Test 024 : should read plugin variables', function () { const plugin = cfg.getPlugin('org.apache.cordova.pluginwithvars'); expect(plugin.variables).toBeDefined(); expect(plugin.variables.var).toBeDefined(); expect(plugin.variables.var).toEqual('varvalue'); });
describe('package name / ios-CFBundleIdentifier', function () { it('Test 005 : should get the ios packagename', function () { expect(cfg.ios_CFBundleIdentifier()).toEqual('io.cordova.hellocordova.ios'); }); });