/
isEnabled.spec.ts
45 lines (37 loc) · 1.89 KB
/
isEnabled.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import 'mocha';
import { expect } from '@integration/testing-tools';
import { Ensure } from '@serenity-js/assertions';
import { actorCalled, AssertionError, Wait } from '@serenity-js/core';
import { By, isEnabled, Navigate, PageElement } from '@serenity-js/web';
describe('isEnabled', function () {
const Page = {
enabledButton: PageElement.located(By.id('enabled')).describedAs('the enabled button'),
disabledButton: PageElement.located(By.id('disabled')).describedAs('the disabled button'),
hiddenButton: PageElement.located(By.id('hidden')).describedAs('the hidden button'),
};
beforeEach(() =>
actorCalled('Wendy').attemptsTo(
Navigate.to('/expectations/is-enabled/buttons.html'),
));
/** @test {isEnabled} */
it('allows the actor flow to continue when the element is enabled', () =>
expect(actorCalled('Wendy').attemptsTo(
Wait.until(Page.enabledButton, isEnabled()),
Ensure.that(Page.enabledButton, isEnabled()),
)).to.be.fulfilled);
/** @test {isEnabled} */
it('breaks the actor flow when element is disabled', () =>
expect(actorCalled('Wendy').attemptsTo(
Ensure.that(Page.disabledButton, isEnabled()),
)).to.be.rejectedWith(AssertionError, `Expected the disabled button to become enabled`));
/** @test {isEnabled} */
it('contributes to a human-readable description of an assertion', () => {
expect(Ensure.that(Page.enabledButton, isEnabled()).toString())
.to.equal(`#actor ensures that the enabled button does become enabled`);
});
/** @test {isEnabled} */
it('contributes to a human-readable description of a wait', () => {
expect(Wait.until(Page.enabledButton, isEnabled()).toString())
.to.equal(`#actor waits up to 5s, polling every 500ms, until the enabled button does become enabled`);
});
});