todos-contra-el-fuego-web/cucumber/features/steps_definitions/pages.js
2018-02-01 17:45:04 +01:00

43 lines
1.1 KiB
JavaScript

/* global module expect require process client */
const { goHome } = require('./helper.js');
// Does no works with arrow func
module.exports = function () {
let pages;
this.Given(/^a list of page ids and contents$/, (table, callback) => {
pages = table.raw();
callback();
});
function processPage(i) {
const id = `#${pages[i][0]}`;
const content = pages[i][1];
client.waitForVisible(id, 10000);
client.click(id);
client.waitForText('#react-root', content);
}
this.Given(/^a list of non visible pages ids and contents$/, (table, callback) => {
pages = table.raw();
callback();
});
this.Then(/^I check that all non visible pages works properly$/, (callback) => {
for (let i = 0; i < pages.length; i += 1) {
client.url(`${process.env.ROOT_URL}/${pages[i][0]}`);
const content = pages[i][1];
client.waitForText('#react-root', content);
}
callback();
});
this.Then(/^I check that all pages works properly$/, (callback) => {
goHome(client);
for (let i = 0; i < pages.length; i += 1) {
processPage(i);
}
callback();
});
};