UNPKG

ember-cli-page-object

Version:

This ember-cli addon eases the construction of page objects on your acceptance and integration tests

51 lines (50 loc) 1.1 kB
/** * @public * * Allow to perform operations on intermediate results within the chain. * * Useful for grouping what's being tested. * * @example * page.users(1).as(user => { * assert.equal(user.name, 'John'); * assert.equal(user.lastName, 'Doe'); * assert.equal(user.email, 'john@doe'); * }); * * page.users(2).as(user => { * assert.equal(user.name, 'John'); * assert.equal(user.lastName, 'Doe'); * assert.equal(user.email, 'john@doe'); * }); * * page.users(3).as(user => { * assert.equal(user.name, 'John'); * assert.equal(user.lastName, 'Doe'); * assert.equal(user.email, 'john@doe'); * }); * * @example * // Lorem <span>ipsum <strong>dolor</strong></span> * * let page = create({ * scope: 'span', * foo: { * bar: { * scope: 'strong' * } * } * }); * * page.foo.bar.as(element => { * assert.equal(element.text, 'dolor'); * }); * * @param {function} callback - Function to be called with the current object as the parameter * @return {object} this * */ export function as(callback) { callback(this); return this; }