-
Notifications
You must be signed in to change notification settings - Fork 355
/
numberInput.spec.ts
68 lines (61 loc) · 2.17 KB
/
numberInput.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
describe('NumberInput Demo Test', () => {
it('Navigate to numberInput section', () => {
cy.visit('http://localhost:3000/numberInput-demo-nav-link');
});
it('has initial value of 0 & shows min threshold', () => {
cy.get('#input1').should('have.value', 0);
cy.get('#minus-button').should('be.disabled');
cy.get('#plus-button').should('not.be.disabled');
});
it('can be incremented with the plus button & shows max threshold', () => {
cy.get('#plus-button').click();
cy.get('#minus-button').should('not.be.disabled');
cy.get('#input1').should('have.value', 1);
cy.get('#plus-button').click();
cy.get('#plus-button').click();
cy.get('#input1').should('have.value', 3);
cy.get('#plus-button').should('be.disabled');
});
it('can be decremented with the minus button', () => {
cy.get('#minus-button').click();
cy.get('#input1').should('have.value', 2);
cy.get('#minus-button').should('not.be.disabled');
cy.get('#plus-button').should('not.be.disabled');
});
it('can be manually set with input', () => {
cy.get('#input1')
.type('{selectall}')
.type('1');
cy.get('#input1').should('have.value', 1);
cy.get('#minus-button').should('not.be.disabled');
cy.get('#plus-button').should('not.be.disabled');
});
it('is properly disabled', () => {
cy.get('#input2').should('be.disabled');
cy.get('#minus-button2').should('be.disabled');
cy.get('#plus-button2').should('be.disabled');
});
it('can have different unit positions', () => {
cy.get('#numberInput1')
.children()
.first()
.should('have.class', 'pf-c-input-group');
cy.get('#numberInput1')
.children()
.last()
.should('have.class', 'pf-c-number-input__unit');
cy.get('#numberInput2')
.children()
.first()
.should('have.class', 'pf-c-number-input__unit');
cy.get('#numberInput2')
.children()
.last()
.should('have.class', 'pf-c-input-group');
});
it('initial null value can be increment with the plus button', () => {
cy.get('#input3').should('have.value', 0);
cy.get('#plus-button3').click();
cy.get('#input3').should('have.value', 1);
});
});