Skip to content

Commit

Permalink
Update to lodash 4
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Dec 27, 2017
1 parent ddd636a commit 26eca8d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/android-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ helpers.getDeviceInfoFromCaps = async function (opts = {}) {

// udid was given, lets try to init with that device
if (udid) {
if (!_.contains(_.pluck(devices, 'udid'), udid)) {
if (!_.includes(_.map(devices, 'udid'), udid)) {
logger.errorAndThrow(`Device ${udid} was not in the list ` +
`of connected devices`);
}
Expand Down Expand Up @@ -538,7 +538,7 @@ helpers.truncateDecimals = function (number, digits) {
};

helpers.isChromeBrowser = function (browser) {
return _.contains(CHROME_BROWSERS, browser);
return _.includes(CHROME_BROWSERS, browser);
};

helpers.getChromePkg = function (browser) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands.setContext = async function (name) {
}
let contexts = await this.getContexts();
// if the context we want doesn't exist, fail
if (!_.contains(contexts, name)) {
if (!_.includes(contexts, name)) {
throw new errors.NoSuchContextError();
}
// if we're already in the context we want, do nothing
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,21 @@ commands.performTouch = async function (gestures) {
swipeOpts.endY, swipeOpts.duration, swipeOpts.touchCount,
swipeOpts.element);
}
let actions = _.pluck(gestures, "action");
let actions = _.map(gestures, "action");

if (actions[0] === 'longPress' && actions[1] === 'moveTo' && actions[2] === 'release') {
// some things are special
return await this.doTouchDrag(gestures);
} else {
if (actions.length === 2) {
// `press` without a wait is too slow and gets interpretted as a `longPress`
if (_.first(actions) === 'press' && _.last(actions) === 'release') {
if (_.head(actions) === 'press' && _.last(actions) === 'release') {
actions[0] = 'tap';
gestures[0].action = 'tap';
}

// the `longPress` and `tap` methods release on their own
if ((_.first(actions) === 'tap' || _.first(actions) === 'longPress') && _.last(actions) === 'release') {
if ((_.head(actions) === 'tap' || _.head(actions) === 'longPress') && _.last(actions) === 'release') {
gestures.pop();
actions.pop();
}
Expand Down Expand Up @@ -201,7 +201,7 @@ helpers.parseTouch = async function (gestures, multi) {

let touchStateObjects = await asyncmap(gestures, async (gesture) => {
let options = gesture.options || {};
if (_.contains(['press', 'moveTo', 'tap', 'longPress'], gesture.action)) {
if (_.includes(['press', 'moveTo', 'tap', 'longPress'], gesture.action)) {
options.offset = false;
let elementId = gesture.options.element;
if (elementId) {
Expand Down
4 changes: 2 additions & 2 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AndroidDriver extends BaseDriver {
this.bootstrapPort = opts.bootstrapPort || DEVICE_PORT;
this.unlocker = helpers.unlocker;

for (let [cmd, fn] of _.pairs(commands)) {
for (let [cmd, fn] of _.toPairs(commands)) {
AndroidDriver.prototype[cmd] = fn;
}
}
Expand Down Expand Up @@ -374,7 +374,7 @@ class AndroidDriver extends BaseDriver {
"org.chromium.chrome",
"org.chromium.webview_shell"];

if (!_.contains(knownPackages, this.opts.appPackage)) {
if (!_.includes(knownPackages, this.opts.appPackage)) {
opts.chromeAndroidActivity = this.opts.appActivity;
}
this.chromedriver = await setupNewChromedriver(opts, this.adb.curDeviceId,
Expand Down
2 changes: 1 addition & 1 deletion lib/webview-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ helpers.getWebviews = async function (adb, deviceSocket) {
helpers.decorateChromeOptions = function (caps, opts, deviceId) {
// add options from appium session caps
if (opts.chromeOptions) {
for (let [opt, val] of _.pairs(opts.chromeOptions)) {
for (let [opt, val] of _.toPairs(opts.chromeOptions)) {
if (_.isUndefined(caps.chromeOptions[opt])) {
caps.chromeOptions[opt] = val;
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"bluebird": "^3.4.7",
"io.appium.settings": "^2.4.0",
"jimp": "^0.2.24",
"lodash": "^3.10.0",
"lodash": "^4.17.4",
"portfinder": "^1.0.6",
"shared-preferences-builder": "^0.0.4",
"source-map-support": "^0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion test/functional/commands/keyboard/keyboard-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('keyboard', () => {

// sometimes the default ime is not what we are using
let engines = await driver.availableIMEEngines();
let selectedEngine = _.first(engines);
let selectedEngine = _.head(engines);
for (let engine of engines) {
// it seems that the latin ime has `android.inputmethod` in its package name
if (engine.indexOf('android.inputmethod') !== -1) {
Expand Down

0 comments on commit 26eca8d

Please sign in to comment.