OpenVeo test API

API Docs for: 8.0.0
Show:

File: lib/e2e/fields/FakeField.js

'use strict';

/**
 * @module e2e
 */

var util = require('util');
var Field = process.requireTest('lib/e2e/fields/Field.js');

/**
 * Defines a form fake field.
 *
 * FakeField is not really a field, it is just a simple text with a label.
 * Use Field.get method to get an instance of FakeField.
 *
 * @example
 *
 *     var Field = require('@openveo/test').e2e.fields.Field;
 *
 *     var myFakeField = Field.get({
 *       type: 'fake',
 *       name: 'My field',
 *       baseElement: element(by.css('form'))
 *     });
 *
 * @class FakeField
 * @extends Field
 * @constructor
 * @param {Object} conf A field configuration object
 */
function FakeField(conf) {
  FakeField.super_.call(this, conf);
}

module.exports = FakeField;
util.inherits(FakeField, Field);

/**
 * Gets fake field text.
 *
 * @example
 *
 *     myField.getValue().then(function(value) {
 *       console.log('Got text: ' + value);
 *     });
 *
 * @method getValue
 * @return {Promise} Promise resolving with field text
 */
FakeField.prototype.getValue = function() {
  return this.getText();
};

/**
 * Sets field value.
 *
 * Does not do anything as this is not a real field.
 *
 * @method setValue
 * @param {String} [value=''] Field's value
 * @return {Promise} Promise resolving immediately
 */
FakeField.prototype.setValue = function(value) {
  return protractor.promise.fulfilled();
};

/**
 * Clears field value.
 *
 * Does not do anything as this is not a real field.
 *
 * @method clear
 * @return {Promise} Promise resolving immediately
 */
FakeField.prototype.clear = function() {
  return protractor.promise.fulfilled();
};

/**
 * Tests if a field is considered as on error.
 *
 * Does not do anything as this is not a real field.
 *
 * @method isOnError
 * @return {Promise} Promise resolving with false as it is not a real field, it couldn't be in error
 */
FakeField.prototype.isOnError = function() {
  return protractor.promise.fulfilled(false);
};