Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Switch): convert Switch to TypeScript
- Loading branch information
Titani
committed
Jun 20, 2019
1 parent
a5dc8bb
commit 3c4b8c9
Showing
10 changed files
with
102 additions
and
50 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
packages/patternfly-4/react-core/src/components/Switch/Switch.d.ts
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
packages/patternfly-4/react-core/src/components/Switch/index.d.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/patternfly-4/react-core/src/components/Switch/index.js
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/patternfly-4/react-core/src/components/Switch/index.ts
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 @@ | ||
export * from './Switch'; |
29 changes: 29 additions & 0 deletions
29
packages/patternfly-4/react-integration/cypress/integration/switch.spec.ts
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,29 @@ | ||
describe('Switch Demo Test', () => { | ||
it('Navigate to demo section', () => { | ||
cy.visit('http://localhost:3000/'); | ||
cy.get('#switch-demo-nav-item-link').click(); | ||
cy.url().should('eq', 'http://localhost:3000/switch-demo-nav-link') | ||
}); | ||
|
||
it('Verify Switches exist and initial state', () => { | ||
cy.get('#simple-switch').should('exist'); | ||
cy.get('#simple-switch').should('be.checked'); | ||
cy.get('#disabled-switch-off').should('exist'); | ||
cy.get('#disabled-switch-off').should('not.be.checked'); | ||
}); | ||
|
||
it('Verify switch can be toggled', () => { | ||
cy.get('#simple-switch').click({ force: true }); | ||
cy.get('#simple-switch').should('not.be.checked'); | ||
cy.get('#simple-switch').click({ force: true }); | ||
cy.get('#simple-switch').should('be.checked'); | ||
}); | ||
|
||
|
||
it('Verify disabled switch can not be toggled', () => { | ||
cy.get('#disabled-switch-off').should('be.disabled'); | ||
cy.get('#disabled-switch-off').should('not.be.checked'); | ||
cy.get('#disabled-switch-off').click({ force: true }); | ||
cy.get('#disabled-switch-off').should('not.be.checked'); | ||
}); | ||
}); |
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
33 changes: 33 additions & 0 deletions
33
...patternfly-4/react-integration/demo-app-ts/src/components/demos/SwitchDemo/SwitchDemo.tsx
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,33 @@ | ||
import React from 'react'; | ||
import { Switch } from '@patternfly/react-core'; | ||
|
||
interface SwitchState { | ||
isChecked: boolean | ||
}; | ||
export class SwitchDemo extends React.Component<{}, SwitchState> { | ||
state = { | ||
isChecked: true | ||
}; | ||
|
||
handleChange = isChecked => { | ||
this.setState({ isChecked }); | ||
}; | ||
|
||
|
||
render() { | ||
const { isChecked } = this.state; | ||
return ( | ||
<React.Fragment> | ||
<Switch | ||
id="simple-switch" | ||
label={isChecked ? 'Message when on' : 'Message when off'} | ||
onChange={this.handleChange} | ||
aria-label="Switch" | ||
isChecked={isChecked} | ||
/> | ||
<br /> | ||
<Switch id="disabled-switch-off" aria-label="disabled switch" label="Message when on" isChecked={false} isDisabled /> | ||
</React.Fragment> | ||
); | ||
} | ||
} |
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