-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix countdown status, add stop functionality * Refactorings, doc updates * Add overtime prop, doc updates * Add cypress for e2e testing (#102) * Update travis cfg * Update test cfgs * Update travis cfg * Update e2e refs * Update dist and clean cmds
- Loading branch information
Showing
23 changed files
with
5,967 additions
and
2,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
dist/ | ||
node_modules/ | ||
coverage/ | ||
.cache/ | ||
*.DS_Store | ||
*.log | ||
*.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"baseUrl": "http://localhost:1234", | ||
"screenshotOnRunFailure": false, | ||
"video": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
describe('<Countdown />', () => { | ||
const ALIAS = 'countdown'; | ||
|
||
const cyGetAs = (selector: string) => cy.get(selector).as(ALIAS); | ||
const cyGet = (alias = ALIAS) => cy.get(`@${alias}`); | ||
|
||
beforeEach(() => { | ||
cy.clock(); | ||
cy.visit('/'); | ||
}); | ||
|
||
describe('Basic Usage', () => { | ||
it('should render final state', () => { | ||
cyGetAs('#basic-usage'); | ||
|
||
for (let i = 5; i > 0; i--) { | ||
cyGet().contains(`00:00:00:0${i}`); | ||
if (i > 0) cy.tick(1000); | ||
} | ||
|
||
cyGet().contains('00:00:00:00'); | ||
}); | ||
|
||
it('should render final state when already in the past', () => { | ||
cyGetAs('#basic-usage-past'); | ||
cyGet().contains('00:00:00:00'); | ||
|
||
cy.tick(1000); | ||
cyGet().contains('00:00:00:00'); | ||
}); | ||
}); | ||
|
||
describe('Custom & Conditional Rendering', () => { | ||
it('should render completed state', () => { | ||
cyGetAs('#children-completionist'); | ||
|
||
for (let i = 5; i > 0; i--) { | ||
cyGet().contains(`00:00:00:0${i}`); | ||
if (i > 0) cy.tick(1000); | ||
} | ||
|
||
cyGet().contains('You are good to go!'); | ||
}); | ||
}); | ||
|
||
describe('Countdown (overtime)', () => { | ||
it('should render infinity', () => { | ||
cyGetAs('#overtime'); | ||
|
||
for (let i = 5; i > -5; i--) { | ||
cyGet().contains(`${i < 0 ? '-' : ''}00:00:00:0${Math.abs(i)}`); | ||
cy.tick(1000); | ||
} | ||
|
||
cy.tick(5000); | ||
cyGet().contains('-00:00:00:10'); | ||
}); | ||
}); | ||
|
||
describe('Countdown API', () => { | ||
beforeEach(() => { | ||
cyGetAs('#api'); | ||
cyGet().contains('00:00:10'); | ||
|
||
cyGet() | ||
.find('button') | ||
.contains('Start') | ||
.as('StartBtn') | ||
.click() | ||
.should('have.be.disabled'); | ||
}); | ||
|
||
it('should click the "Start" button and count down 5s', () => { | ||
cy.tick(5000); | ||
cyGet().contains('00:00:05'); | ||
}); | ||
|
||
it('should click the "Start" (10s) => "Pause" (5s) => "Start" (5s) => "Stop" (3s) buttons => 10s', () => { | ||
cy.tick(5000); | ||
cyGet().contains('00:00:05'); | ||
|
||
cyGet() | ||
.find('button') | ||
.contains('Pause') | ||
.as('PauseBtn') | ||
.click() | ||
.should('have.be.disabled'); | ||
|
||
cy.tick(2000); | ||
cyGet().contains('00:00:05'); | ||
|
||
cyGet('StartBtn').click(); | ||
|
||
cy.tick(2000); | ||
cyGet().contains('00:00:03'); | ||
|
||
cyGet() | ||
.find('button') | ||
.contains('Stop') | ||
.as('StopBtn') | ||
.click() | ||
.should('have.be.disabled'); | ||
|
||
cyGet().contains('00:00:10'); | ||
}); | ||
|
||
it('should reset the countdown at 4s => 10s and count down to 7s', () => { | ||
cy.tick(6000); | ||
cyGet().contains('00:00:04'); | ||
|
||
cyGet() | ||
.find('button') | ||
.contains('Reset') | ||
.as('ResetBtn') | ||
.click(); | ||
|
||
cy.tick(3000); | ||
cyGet().contains('00:00:07'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
Oops, something went wrong.