forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
textarea.spec.ts
130 lines (116 loc) · 4.58 KB
/
textarea.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
describe('Text Area Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/text-area-nav-link');
});
it('Verify Text area exist', () => {
cy.get('#textarea1').should('exist');
});
it('Verify Required Text area exist', () => {
cy.get('#textarea2').should('exist');
});
it('Verify Horizontally resizable Text area exist', () => {
cy.get('#textarea3').should('exist');
});
it('Verify Vertically resizable Text area exist', () => {
cy.get('#textarea4').should('exist');
});
it('Verify Text Area can be updated and that invalid is applied', () => {
cy.get('#textarea1').should('have.value', '');
cy.get('#textarea1').type('testing');
cy.get('#textarea1').should('have.value', 'testing');
// Clear text area and verify it is invalid
cy.get('#textarea1')
.clear()
.then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('true');
});
});
it('Verify Required Text Area can be updated and that invalid is applied', () => {
// Verify it is required
cy.get('#textarea2').should('have.attr', 'required');
cy.get('#textarea2').should('have.value', '');
cy.get('#textarea2').type('testing');
cy.get('#textarea2').should('have.value', 'testing');
// Clear text area and verify it is invalid
cy.get('#textarea2')
.clear()
.then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('true');
});
});
it('Verify Text Area can has horizontally resizable attribute', () => {
cy.get('#textarea3.pf-m-resize-horizontal').should('exist');
cy.get('#textarea3').should('have.value', '');
cy.get('#textarea3').type('testing');
cy.get('#textarea3').should('have.value', 'testing');
// Clear text area and verify it is invalid
cy.get('#textarea3')
.clear()
.then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('true');
});
});
it('Verify Text Area can has vertically resizable attribute', () => {
cy.get('#textarea4.pf-m-resize-vertical').should('exist');
cy.get('#textarea4').should('have.value', '');
cy.get('#textarea4').type('testing');
cy.get('#textarea4').should('have.value', 'testing');
// Clear text area and verify it is invalid
cy.get('#textarea4')
.clear()
.then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('true');
});
});
it('Verify Text Area can be validated using validated prop', () => {
cy.get('#textarea5.pf-m-success').should('not.exist');
cy.get('#textarea5').then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('false');
});
cy.get('#textarea5').should('have.value', '');
// Type string value less than 5 characters so it is invalid
cy.get('#textarea5').type('test');
cy.get('#textarea5').should('have.value', 'test');
cy.get('#textarea5').then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('true');
});
// Clear text area and type string longer than 5 Characters so it is valid
cy.get('#textarea5')
.clear()
.type('testing')
.should('have.value', 'testing');
cy.get('#textarea5.pf-m-success').should('exist');
cy.get('#textarea5').then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('false');
});
// Clear text area and verify it is warning
cy.get('#textarea5')
.clear()
.then(textarea => {
expect(textarea.attr('aria-invalid')).to.be.equal('false');
});
cy.get('#textarea5.pf-m-warning').should('exist');
});
it('Verify Text Area can not be changed when disabled', () => {
cy.get('#textarea6-a').should('be.disabled');
cy.get('#textarea6-a').type('testing', { force: true });
cy.get('#textarea6-a').should('have.value', 'disabled text area');
cy.get('#textarea6-b').should('be.disabled');
cy.get('#textarea6-a').type('testing', { force: true });
cy.get('#textarea6-b').should('have.value', 'isDisabled text area');
cy.get('#textarea7-a').type('testing', { force: true });
cy.get('#textarea7-a').should('have.value', 'readOnly text area');
cy.get('#textarea7-b').type('testing', { force: true });
cy.get('#textarea7-b').should('have.value', 'isReadOnly text area');
});
it('Verify text area autoresizes', () => {
cy.get('#autoResize')
.invoke('outerHeight')
.then(startingHeight => {
cy.get('#autoResize').type('0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0');
cy.get('#autoResize')
.invoke('outerHeight')
.should('be.gt', startingHeight);
});
});
});