annotate core/tests/Drupal/Nightwatch/Commands/drupalLogout.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@17 1 import { execSync } from 'child_process';
Chris@17 2 import { URL } from 'url';
Chris@17 3
Chris@17 4 /**
Chris@17 5 * Logs out from a Drupal site.
Chris@17 6 *
Chris@17 7 * @param {object} [settings={}]
Chris@17 8 * The settings object.
Chris@17 9 * @param {boolean} [settings.silent=false]
Chris@17 10 * If the command should be run silently.
Chris@17 11 * @param {function} callback
Chris@17 12 * A callback which will be called, when the logout is finished.
Chris@17 13 * @return {object}
Chris@17 14 * The drupalLogout command.
Chris@17 15 */
Chris@17 16 exports.command = function drupalLogout({ silent = false } = {}, callback) {
Chris@17 17 const self = this;
Chris@17 18
Chris@17 19 this.drupalRelativeURL('/user/logout');
Chris@17 20
Chris@17 21 this.drupalUserIsLoggedIn(sessionExists => {
Chris@17 22 if (silent) {
Chris@17 23 if (sessionExists) {
Chris@17 24 throw new Error('Logging out failed.');
Chris@17 25 }
Chris@17 26 } else {
Chris@17 27 this.assert.equal(sessionExists, false, 'The user was logged out.');
Chris@17 28 }
Chris@17 29 });
Chris@17 30
Chris@17 31 if (typeof callback === 'function') {
Chris@17 32 callback.call(self);
Chris@17 33 }
Chris@17 34
Chris@17 35 return this;
Chris@17 36 };