From eee179f7c1d4bd0d36fb35f3a51b5463deef5fa6 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:58:51 -0700 Subject: [PATCH] minor js fixes --- app/controller.js | 2 +- test/functional/prefs/prefs.js | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/controller.js b/app/controller.js index 80bb4f684..8f63438d8 100644 --- a/app/controller.js +++ b/app/controller.js @@ -75,7 +75,7 @@ var respondError = function(req, res, statusObj, value) { } if (typeof newValue === "object") { - if (_.has(value, "message")) { + if (newValue !== null && _.has(value, "message")) { // make sure this doesn't get obliterated value.origValue = value.message; message += " (Original error: " + value.message + ")"; diff --git a/test/functional/prefs/prefs.js b/test/functional/prefs/prefs.js index 13e7a64d9..ea59faa1c 100644 --- a/test/functional/prefs/prefs.js +++ b/test/functional/prefs/prefs.js @@ -22,26 +22,27 @@ describe('preferences app', function() { // have modified the plist of your preferences.app to run iphone // instead of ipad by default (this test is for iphone) it('should turn off autocomplete', function(done) { - h.driver.elementsByTagName('tableCell', function(err, els) { - els[1].click(function(err) { - h.driver.elementsByTagName('tableCell', function(err, els) { - els[1].click(function(err) { - h.driver.elementByXPath('//switch[@name="Auto-Correction"]', function(err, switchEl) { - switchEl.getValue(function(err, checked) { - if (checked === 1) { - // was checked, click it off - switchEl.click(function(err) { - done(); - }); - } else { - // was unchecked, do nothing + var p = {strategy: "tag name", selector: "tableCell", index: 1}; + h.driver.execute("mobile: findAndAct", [p], function(err) { + should.not.exist(err); + setTimeout(function() { + h.driver.execute("mobile: findAndAct", [p], function(err) { + should.not.exist(err); + h.driver.elementByXPath('//switch[@name="Auto-Correction"]', function(err, switchEl) { + switchEl.getValue(function(err, checked) { + if (checked === 1) { + // was checked, click it off + switchEl.click(function(err) { done(); - } - }); + }); + } else { + // was unchecked, do nothing + done(); + } }); }); }); - }); + }, 1000); }); }); });