UNPKG

@johnf/react-native-owl

Version:
96 lines (95 loc) 4.16 kB
"use strict"; var _execa = _interopRequireDefault(require("execa")); var adb = _interopRequireWildcard(require("./adb.js")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } describe('adb.ts', () => { jest.spyOn(process, 'cwd').mockReturnValue('/Users/johndoe/Projects/my-project'); const execKillMock = { kill: jest.fn() }; const execMock = jest.spyOn(_execa.default, 'command').mockReturnValue(execKillMock); beforeEach(() => { execMock.mockReset(); }); describe('adbInstall', () => { it('installs an app with default config', async () => { await adb.adbInstall({}); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb install -r /Users/johndoe/Projects/my-project/android/app/build/outputs/apk/release/app-release.apk', { stdio: 'ignore' }); }); it('installs an app with debugging', async () => { await adb.adbInstall({ debug: true }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb install -r /Users/johndoe/Projects/my-project/android/app/build/outputs/apk/release/app-release.apk', { stdio: 'inherit' }); }); it('installs an app with custom buildType', async () => { await adb.adbInstall({ buildType: 'Debug' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb install -r /Users/johndoe/Projects/my-project/android/app/build/outputs/apk/debug/app-debug.apk', { stdio: 'ignore' }); }); it('installs an app with custom binaryPath', async () => { await adb.adbInstall({ binaryPath: '/custom/path/app.apk' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb install -r /custom/path/app.apk', { stdio: 'ignore' }); }); }); describe('adbTerminate', () => { it('terminates an app', async () => { await adb.adbTerminate({ packageName: 'com.name.app' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb shell am force-stop com.name.app', { stdio: 'ignore' }); }); it('terminates an app with debugging', async () => { await adb.adbTerminate({ debug: true, packageName: 'com.name.app' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb shell am force-stop com.name.app', { stdio: 'inherit' }); }); }); describe('adbLaunch', () => { it('launches an app', async () => { await adb.adbLaunch({ packageName: 'com.name.app' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb shell monkey -p "com.name.app" -c android.intent.category.LAUNCHER 1', { stdio: 'ignore' }); }); it('launches an app with debugging', async () => { await adb.adbLaunch({ debug: true, packageName: 'com.name.app' }); expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith('adb shell monkey -p "com.name.app" -c android.intent.category.LAUNCHER 1', { stdio: 'inherit' }); }); }); }); //# sourceMappingURL=adb.test.js.map