describe('When `sri` generates a hash in prod', () => { beforeAll((done) => { runWebpack(done, getConfig({ prod: true, sri: 'jasmine' })); }); it('should output the right assets (js)', () => { expect(jsSri).toEqual(['sha384-GVSvp94Rbje0r89j7JfSj0QfDdJ9BkFy7YUaUZUgKNc4R6ibqFHWgv+eD1oufzAu']); }); it('should output the right assets (css)', () => { expect(cssSri).toEqual(['sha384-2c0TqAkCN1roP60Rv0mi/hGc4f/Wcgf55C348nsOdphbp3YncSDjfSLBTO/IbRVh']); }); });
it('should trigger the log READOUT specifying the correct number of entries to be notified for 0.05 notification progress', function() { var data = new Buffer([0x68,0x8,0x0,0x0]); log.downloadLog(); expect(device.send.calls.any()).toBe(true); device.send.calls.reset(); device.emitter.emit([MODULE, LENGTH], data, MODULE.toString(16), LENGTH.toString(16)); expect(device.send).toHaveBeenCalled(); expect(device.buffers.pop()).toEqual(new Buffer([0xb,0x6,0x68,0x8,0x0,0x0,0x6b,0x0,0x0,0x0])); });
it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function () { const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }]; 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(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 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'); });
it('should exec async', function (jasmineDone) { perfy.destroyAll().exec(function (done) { setTimeout(function () { var result = done(); expect(result).toBeDefined(); expect(result.time).toBeGreaterThan(1); expect(result.name).toEqual(''); expect(perfy.count()).toEqual(0); jasmineDone(); }, 1100); }); });
it('should save/exec named sync', function () { var name = 'sync-op', result = perfy.exec(name, function () { var i = 0; while (i < 10000) { i += 1; } }); expect(result).toBeDefined(); expect(result.time).toEqual(jasmine.any(Number)); expect(perfy.result(name)).toBeDefined(); expect(perfy.exists(name)).toEqual(true); });
describe('save method', function () { it('Test 006 : should write out specified json', function () { const filepath = path.join(plugins_dir, 'android.json'); const platformJson = new PlatformJson(filepath, 'android', { foo: true }); platformJson.save(); expect(JSON.parse(fs.readFileSync(filepath, 'utf-8'))).toEqual(platformJson.root); }); });
describe('enableAxisSampling()', function() { it('should enable sampling on the magnetometer', function() { magnetometer.enableAxisSampling(); expect(device.send).toHaveBeenCalled(); expect(device.buffers.pop()).toEqual(new Buffer([0x15,0x2,0x1,0x0])); }); });
it('should trigger the reading the length of the log', function() { log.downloadLog(); expect(device.sendRead).toHaveBeenCalled(); expect(device.buffers[4]).toEqual(new Buffer([0xb,0x85])); });
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\']'); });
describe( 'Number parser', () => { it( 'recognizes x and X as marker', function () { expect( buttons.numbersFromCoords( ':x.X.x.X.x.X.' ) ).toEqual( [ 0, 2, 4, 6, 8, 10 ] ); expect( buttons.numbersFromCoords( 'xx.X.x.X.x.X.' ) ).toEqual( [ 8, 0, 2, 4, 6, 8, 10 ] ); } ); it( 'returns empty array for empty/invalid args', () => { expect( buttons.numbersFromCoords( 'asdf' ) ).toEqual( [] ); expect( buttons.numbersFromCoords( '' ) ).toEqual( [] ); expect( buttons.numbersFromCoords( undefined ) ).toEqual( [] ); } ); } );
describe('start()', function() { it('should power on the magnetometer', function() { magnetometer.start(); expect(device.send).toHaveBeenCalled(); expect(device.buffers.pop()).toEqual(new Buffer([0x15,0x1,0x1])); }); });
describe('When `crossOrigin` is set', () => { beforeAll((done) => { runWebpack(done, getConfig({ prod: true, crossOrigin: 'anonymous' })); }); it('should output the right assets (css)', () => { expect(cssCrossOrigin).toEqual([false, true, true]); }); it('should output the right assets (js)', () => { expect(jsCrossOrigin).toEqual([false, true, true, true, false]); }); });