UNPKG

piumino

Version:

Piumino, meaning duvet in Italian, is like a duvet over the bed called Angular TestBed. It provides test helpers to test trivial things like inputs and outputs with a single line.

32 lines (31 loc) 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ToCallWithMatcher = void 0; const es6_1 = __importDefault(require("fast-deep-equal/es6")); const matcher_1 = require("./matcher"); class ToCallWithMatcher extends matcher_1.Matcher { /** * Expect the called function to be called with the provided values. * The last of the provided values is dispatched as $event in case of an output. * * [input]="func(value)"\ * (output)="func($event)"\ * (output)="func(value, $event)" * * @param values - The values to compare with the values that the function was called with. */ with(value, ...rest) { const values = [value, ...rest]; const toCallMatcher = this.state.matcher; this.appendDescription(`with '${values.join("','")}'`); this.setMatcher(() => { const [hasBeenCalled, received] = toCallMatcher(values[values.length - 1]); return [hasBeenCalled && (0, es6_1.default)(received, values), received, values]; }); return this; } } exports.ToCallWithMatcher = ToCallWithMatcher;