Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
actual: 'not-name',
artifact: { expected: `'name'`, actual: `'not-name'` },
}, {
description: 'list',
expected: [{ name: 'Bob' }, { name: 'Alice' }],
actual: [{ name: 'Alice' }],
artifact: { expected: `[\n { name: 'Bob' },\n { name: 'Alice' }\n]`, actual: `[\n { name: 'Alice' }\n]` },
}, {
description: 'promise',
expected: Promise.resolve(true),
actual: Promise.resolve(false),
artifact: { expected: `true`, actual: `false` },
}, {
description: 'question',
expected: Question.about('some value', actor => true),
actual: Question.about('some value', actor => false),
artifact: { expected: 'true', actual: 'false' },
}]).
/** @test {Ensure.that} */
it('emits an artifact describing the actual and expected values', ({ actual, expected, artifact }) => {
const recorder = new EventRecorder();
theStage.assign(recorder);
return expect(Enrique.attemptsTo(
Ensure.that(actual, equals(expected)), // we don't care about the expectation itself in this test
)).to.be.rejected.then(() =>
PickEvent.from(recorder.events)
.next(ActivityRelatedArtifactGenerated, e => e.artifact.map(value => {
expect(value.expected).to.equal(artifact.expected);
expect(value.actual).to.equal(artifact.actual);
})),
);
export const ResultOfCalculation = () => Question.about>(`the result of the calculation`, (actor: Actor) => {
const ability = InteractDirectly.as(actor);
return Promise.resolve(ability.submit(new GetCalculationResult(ability.currentCalculationId())));
});
it('provides a sensible description of the interaction being performed when invoked with arguments', () => {
const arg3 = Question.about('arg number 3', actor => void 0);
expect(ExecuteScript.async(`arguments[arguments.length - 1]();`)
.withArguments(Promise.resolve('arg1'), 'arg2', arg3).toString(),
).to.equal(`#actor executes an asynchronous script with arguments: [ a Promise, 'arg2', arg number 3 ]`);
});
const numbers = () => Question.about('list of numbers', actor => [ 0, 1, 2 ]);
static result(): Question {
return Question.about(`last script execution result`, actor =>
BrowseTheWeb.as(actor).getLastScriptExecutionResult());
}
}
static headers() {
return Question.about<{ [header: string ]: string }>(`the headers or the last response`, actor => {
return CallAnApi.as(actor).mapLastResponse(response => response.headers);
});
}
}
constructor(
private readonly pathToArtifact: Path,
private readonly args: Question = Question.about(`no arguments`, actor => []),
private readonly props: Question = Question.about(`no properties`, actor => []),
) {
super();
}
const numbers = () => Question.about('list of numbers', actor => [ 0, 1, 2 ]);
const IsSynchronisationEnabled = () => Question.about('angular synchronisation',
actor => promiseOf(protractor.browser.waitForAngularEnabled()),
);
function q(value: T): Question {
return Question.about(`the animals`, actor => value);
}
});