-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathtest_form.spec.js
60 lines (45 loc) · 2.09 KB
/
test_form.spec.js
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
/// <reference types="Cypress" />
context('Form', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/')
})
it('should change input values', () => {
const nameText = 'John Deer';
const descText = 'This is a desc test';
const recurrenceIntervalText = 10;
const dateText = '2001-03-15';
cy.get('[id="#/properties/name-input"]').clear().type(nameText);
cy.get('[id="#/properties/description-input"]').clear().type(descText);
cy.get('[id="#/properties/done-input"]').uncheck();
cy.get('[id="#/properties/recurrence"] > div').click();
cy.get('[data-value="Monthly"]').click();
cy.get('[id="#/properties/recurrence_interval-input"]').clear().type(recurrenceIntervalText);
cy.get('[id="#/properties/due_date-input"]').clear().type(dateText);
cy.get('[id="#/properties/rating"] span:last').click();
cy.get('[id="boundData"]').invoke('text').then((content => {
const data = JSON.parse(content);
expect(data.name).to.equal(nameText);
cy.get('[id="#/properties/name"] p').should('be.empty')
cy.get('[id="#/properties/recurrence_interval"]').should('exist')
expect(data.description).to.equal(descText);
expect(data.done).to.equal(false);
expect(data.recurrence).to.equal('Monthly');
expect(data.recurrence_interval).to.equal(recurrenceIntervalText);
expect(data.due_date).to.equal(dateText);
expect(data.rating).to.equal(5);
}));
});
it('should show errors', () => {
cy.get('[id="#/properties/name-input"]').clear();
cy.get('[id="#/properties/name"] p:first-child').should('not.be.empty');
cy.get('[id="#/properties/due_date-input"]').clear().type('351');
cy.get('[id="#/properties/due_date"] p:first-child').should('not.be.empty');
cy.get('[id="#/properties/recurrence"] > div').click();
cy.get('[data-value="Never"]').click();
cy.get('[id="#/properties/recurrence_interval"]').should('not.exist')
cy.get('[id="boundData"]').invoke('text').then((content => {
const data = JSON.parse(content);
expect(data.due_date).to.equal('Invalid date');
}));
});
})