UNPKG

suitest-js-api

Version:

Suitest is a test automation and device manipulation tool for living room devices and web browsers.

30 lines (23 loc) 899 B
const {makeModifierComposer} = require('../utils/makeComposer'); const composers = require('../constants/composer'); const {validate, validators} = require('../validation'); const SuitestError = require('../utils/SuitestError'); const texts = require('../texts'); /** * Until composer populates chain with .until() method, * which accepts another chain and stores it under 'until' property */ const untilComposer = makeModifierComposer(composers.UNTIL, ['until'], (classInstance, data, chain) => { if (!chain || (typeof chain.toJSON !== 'function')) { throw new SuitestError(texts.chainExpected(), SuitestError.INVALID_INPUT); } classInstance.unusedExpressionWatchers.unregisterLeaf(chain); const json = chain.toJSON(); // Validate chain validate(validators.UNTIL_CONDITION_CHAIN, json); return { ...data, until: json.request.condition, }; }); module.exports = untilComposer;