This file contains hidden or 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
| function generateColor(name: string): string { | |
| let hash = 0; | |
| for (let i = 0; i < name.length; i++) { | |
| hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0; | |
| } | |
| return `#${(Math.abs(hash) % 0x1000000).toString(16).padStart(6, '0')}`; | |
| } |
This file contains hidden or 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
| function animateNumber({ | |
| start, | |
| end, | |
| duration, | |
| onChange, | |
| }: { | |
| start: number; | |
| end: number; | |
| onChange: (val: number) => void; | |
| duration?: number; |
This file contains hidden or 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
| .wrapper:hover > *:not(:hover) { | |
| color: red; | |
| } |
This file contains hidden or 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
| overflow: hidden; | |
| text-overflow: ellipsis; | |
| white-space: nowrap; | |
| word-wrap: normal; |
This file contains hidden or 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
| const provedPassword = this.password.match(/(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z|A-Z])/g); |
This file contains hidden or 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
| const value = 30; | |
| const newArray = Array.from(Array(value)).map((item, index) => ({ | |
| date: new Date(2018, 1, index + 1), | |
| })); |
This file contains hidden or 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
| handleTimeout = ({ value }) => { | |
| setTimeout(() => this.props.onClose({ value }), 30000); | |
| }; | |
| describe('Example', () => { | |
| it('should call exampleProps with value', () => { | |
| const spy = jest.fn(); | |
| const wrapper = shallow( | |
| <Example exampleProps={value: 'test'} /> | |
| ); |
This file contains hidden or 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
| const mockMath = Object.create(global.Math); | |
| mockMath.random = () => 0.5; | |
| global.Math = mockMath; |
This file contains hidden or 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
| componentDidUpdate(prevProps) { | |
| if (prevProps.propsExample !== this.props.propsExample) { | |
| this.handleExample(this.props.propsExample); | |
| } | |
| } | |
| //test enzyme + jest | |
| describe('componentDidUpdate', () => { | |
| it('should call handleExample', () => { | |
| const value = 'test'; |