/*global it:true */
"use strict";

var describeWd = require('../../helpers/driverblock.js').describeForApp('TestApp')
  , should = require("should")
  , assert = require('assert');

describeWd('clear', function(h) {
  return it('should clear the text field', function(done) {
    var someText = "some-value";
    h.driver.elementByTagName('textField', function(err, elem) {
      elem.sendKeys(someText, function() {
        elem.text(function(err, text) {
          assert.equal(text, someText);
          elem.clear(function(err) {
            elem.text(function(err, text) {
              assert.equal(text, '');
              done();
            });
          });
        });
      });
    });
  });
});

describeWd('keyboard', function(h) {
  it('should be hideable', function(done) {
    h.driver.elementByTagName('textField', function(err, elem) {
      should.not.exist(err);
      elem.sendKeys("1", function(err) {
        should.not.exist(err);
        h.driver.elementByTagName('slider', function(err, slider) {
          slider.displayed(function(err, isDisplayed) {
            isDisplayed.should.equal(false);
            h.driver.execute("mobile: hideKeyboard", [{keyName: "Done"}], function(err) {
              should.not.exist(err);
              slider.displayed(function(err, isDisplayed) {
                isDisplayed.should.equal(true);
                done();
              });
            });
          });
        });
      });
    });
  });
});

@@ -1030,33 +1030,29 @@
      slider.
-displayed
+click
 (function(er
@@ -1048,37 +1048,24 @@
 function(err
-, isDisplayed
 ) %7B%0A        
@@ -1072,38 +1072,24 @@
     
-isDisplayed.should.equal(false
+should.exist(err
 );%0A 
@@ -1232,25 +1232,44 @@
     
-slider.displayed(
+h.driver.elementByTagName('slider', 
 func
@@ -1278,27 +1278,22 @@
 on(err, 
-isDisplayed
+slider
 ) %7B%0A    
@@ -1308,40 +1308,80 @@
     
-isDisplayed.should.equal(true
+slider.click(function(err) %7B%0A                  should.not.exist(err
 );%0A
+  
     
@@ -1392,32 +1392,52 @@
         done();%0A
+                %7D);%0A
               %7D)

fix text with correct displayed behavior