Skip to content

Commit

Permalink
Add linting, and run lint (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Feb 15, 2018
1 parent 9e6b68d commit 44f3e6f
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
@@ -0,0 +1,3 @@
{
"extends": "appium"
}
11 changes: 0 additions & 11 deletions .jscsrc

This file was deleted.

11 changes: 0 additions & 11 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright 2012-2016 JS Foundation and other contributors
Copyright 2012-2018 JS Foundation and other contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 5 additions & 6 deletions gulpfile.js
@@ -1,11 +1,11 @@
"use strict";
var teen_process = require('teen_process');
var system = require('appium-support').system;
const teen_process = require('teen_process');
const system = require('appium-support').system;

var antCmd = system.isWindows() ? 'ant.bat' : 'ant';
const antCmd = system.isWindows() ? 'ant.bat' : 'ant';

var gulp = require('gulp'),
boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);
const gulp = require('gulp');
const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);

gulp.task('ant-clean', function () {
return teen_process.exec(antCmd, ['clean'], {cwd: 'bootstrap'});
Expand All @@ -19,7 +19,6 @@ gulp.task('ant', ['ant-clean', 'ant-build']);

boilerplate({
build: 'appium-android-bootstrap',
jscs: false,
extraPrepublishTasks: ['ant'],
e2eTest: {android: true},
testTimeout: 20000
Expand Down
4 changes: 2 additions & 2 deletions lib/bootstrap.js
Expand Up @@ -78,7 +78,7 @@ class AndroidBootstrap {
});

// only return when the socket client has connected
return await new Promise ((resolve, reject) => {
return await new B((resolve, reject) => {
try {
this.socketClient = net.connect(this.systemPort);
// Windows: the socket errors out when ADB restarts. Let's catch it to avoid crashing.
Expand All @@ -105,7 +105,7 @@ class AndroidBootstrap {
throw new Error('Socket connection closed unexpectedly');
}

return await new Promise ((resolve, reject) => {
return await new B((resolve, reject) => {
let cmd = Object.assign({cmd: type}, extra);
let cmdJson = `${JSON.stringify(cmd)} \n`;
log.debug(`Sending command to android: ${_.trunc(cmdJson, 1000).trim()}`);
Expand Down
29 changes: 23 additions & 6 deletions package.json
Expand Up @@ -36,16 +36,33 @@
"teen_process": "^1.3.1"
},
"scripts": {
"prepublish": "./node_modules/.bin/gulp prepublish",
"test": "./node_modules/.bin/gulp once",
"watch": "./node_modules/.bin/gulp"
"prepublish": "gulp prepublish",
"clean": "rm -rf node_modules && npm install",
"test": "gulp once",
"watch": "gulp watch",
"mocha": "mocha",
"e2e-test": "gulp e2e-test",
"coverage": "gulp coveralls",
"build": "gulp transpile",
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
"lint": "gulp eslint",
"lint:fix": "gulp eslint --fix"
},
"devDependencies": {
"appium-adb": "^2.3.0",
"appium-gulp-plugins": "^1.3.12",
"appium-test-support": "^0.0.5",
"appium-gulp-plugins": "^2.2.0",
"appium-test-support": "^0.4.0",
"babel-eslint": "^7.1.1",
"chai": "^3.3.0",
"chai-as-promised": "^5.1.0",
"gulp": "^3.9.0"
"eslint": "^3.10.2",
"eslint-config-appium": "^2.1.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-mocha": "^4.7.0",
"eslint-plugin-promise": "^3.3.1",
"gulp": "^3.9.0",
"mocha": "^3.5.0",
"pre-commit": "^1.1.3"
}
}
22 changes: 0 additions & 22 deletions test/.jshintrc

This file was deleted.

18 changes: 9 additions & 9 deletions test/functional/bootstrap-e2e-specs.js
Expand Up @@ -15,13 +15,13 @@ const MOCHA_TIMEOUT = process.env.TRAVIS ? 240000 : 60000;

describe('Android Bootstrap', function () {
this.timeout(MOCHA_TIMEOUT);

let adb, androidBootstrap;
let rootDir = path.resolve(__dirname,
process.env.NO_PRECOMPILE ? '../..' : '../../..');
const apiDemos = path.resolve(rootDir, 'test', 'fixtures', 'ApiDemos-debug.apk');
const systemPort = 4724;
before(async () => {
before(async function () {
adb = await ADB.createADB();
const packageName = 'io.appium.android.apis',
activityName = '.ApiDemos';
Expand All @@ -31,21 +31,21 @@ describe('Android Bootstrap', function () {
androidBootstrap = new AndroidBootstrap(adb, systemPort);
await androidBootstrap.start('io.appium.android.apis', false);
});
after(async ()=> {
after(async function () {
await androidBootstrap.shutdown();
});
it("sendAction should work", async () => {
it("sendAction should work", async function () {
(await androidBootstrap.sendAction('wake')).should.equal(true);
});
it("sendCommand should work", async () => {
(await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'getDataDir'})).should
it("sendCommand should work", async function () {
(await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'getDataDir'})).should
.equal("/data");
});
it("sendCommand should correctly throw error", async () => {
await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'unknown'}).should
it("sendCommand should correctly throw error", async function () {
await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'unknown'}).should
.eventually.be.rejectedWith(errors.UnknownCommandError);
});
it("should cancel onUnexpectedShutdown promise on unexpected uiAutomator shutdown", async () => {
it("should cancel onUnexpectedShutdown promise on unexpected uiAutomator shutdown", async function () {
await androidBootstrap.sendCommand(COMMAND_TYPES.SHUTDOWN);
await androidBootstrap.onUnexpectedShutdown.should.eventually
.be.rejectedWith("Error: UiAUtomator shut down unexpectedly");
Expand Down
2 changes: 1 addition & 1 deletion test/unit/bootstrap-specs.js
Expand Up @@ -43,7 +43,7 @@ describe('AndroidBootstrap', async function () {
S.verify();
});
}));
describe("sendCommand", () => {
describe("sendCommand", function () {
it("should successfully return after receiving data from bootstrap in parts", async function () {
let conn = new events.EventEmitter();
conn.write = _.noop;
Expand Down

0 comments on commit 44f3e6f

Please sign in to comment.