diff --git a/src/components/LeaderBoard.cy.js b/src/components/LeaderBoard.cy.js
index 77600b8b1..54eaaf976 100644
--- a/src/components/LeaderBoard.cy.js
+++ b/src/components/LeaderBoard.cy.js
@@ -1,12 +1,10 @@
-import React from 'react';
-
import { mountWithTheme as mount } from '../models/test-utils';
import LeaderBoard from './LeaderBoard';
-
describe('LeaderBoard', () => {
it('renders', () => {
- mount();
+ cy.fixture('countries/leader').then(({ countries }) => {
+ mount();
+ });
});
});
-
diff --git a/src/components/common/Filter.cy.js b/src/components/common/Filter.cy.js
index 14d015493..5b931e299 100644
--- a/src/components/common/Filter.cy.js
+++ b/src/components/common/Filter.cy.js
@@ -1,5 +1,3 @@
-import React from 'react';
-
import { mountWithTheme as mount } from '../../models/test-utils';
import Filter from './Filter';
// import the expect function from Chai
@@ -10,85 +8,49 @@ describe('Filter', () => {
mount();
});
- it.only('Submit is success when startDate is less than endDate', () => {
+ it('Submit is success when startDate is less than endDate', () => {
const handleFilter = cy.stub();
mount();
cy.contains(/timeline/i);
- // cypress to find the date type of input, choose the first one, and input the date
- cy.get('input[type=text]').first().type('2020-01-01');
-
- // find the second date type of input, choose the second one, and input the date
- cy.get('input[type=text]').eq(1).type('2020-01-02');
-
- cy.get('input[type=text]')
- .invoke('val')
- .then((startDate) => {
- cy.get('input[type=text]')
- .eq(1)
- .invoke('val')
- .should((endDate) => {
- const convertStartDate = new Date(startDate);
- const convert_endDate = new Date(endDate);
+ cy.contains('label', 'Start Date')
+ .parent()
+ .find('input')
+ .type('01-01-2020');
- const StartDate_milliSeconds = convertStartDate.getTime();
- const endDate_milliSeconds = convert_endDate.getTime();
+ cy.contains('label', 'End Date').parent().find('input').type('01-02-2020');
- expect(StartDate_milliSeconds).to.be.lessThan(endDate_milliSeconds);
- });
- });
cy.contains(/submit/i)
.click()
.then(() => {
expect(handleFilter).to.be.calledWith({
startDate: '2020-01-01',
- endDate: '2020-01-02',
+ endDate: '2020-02-01',
});
});
});
- it.only('Submit is Failed when startDate is greater than endDate', () => {
+ it('Submit is Failed when startDate is greater than endDate', () => {
const handleFilter = cy.stub();
mount();
cy.contains(/timeline/i);
+ cy.contains('label', 'Start Date')
+ .parent()
+ .find('input')
+ .type('01-05-2020');
- // cypress to find the date type of input, choose the first one, and input the date
- cy.get('input[type=text]').first().type('2020-01-05');
-
- // find the second date type of input, choose the second one, and input the date
- cy.get('input[type=text]').eq(1).type('2020-01-02');
+ cy.contains('label', 'End Date').parent().find('input').type('01-02-2020');
- cy.get('input[type=text]')
- .invoke('val')
- .then((startDate) => {
- cy.get('input[type=text]')
- .eq(1)
- .invoke('val')
- .should((endDate) => {
- const convertStartDate = new Date(startDate);
- const convert_endDate = new Date(endDate);
-
- const StartDate_milliSeconds = convertStartDate.getTime();
- const endDate_milliSeconds = convert_endDate.getTime();
-
- expect(StartDate_milliSeconds).to.be.greaterThan(
- endDate_milliSeconds,
- );
- });
- });
cy.contains(/submit/i)
.click()
.then(() => {
- expect(handleFilter).to.been.not.calledWith({
- startDate: '2020-01-05',
- endDate: '2020-01-02',
- });
+ expect(handleFilter).to.have.callCount(0);
});
});
- it.only('Cancel Button hides the filters', () => {
+ it('Cancel Button hides the filters', () => {
mount();
cy.contains(/timeline/i);