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
if ('serviceWorker' in navigator) { | |
window.addEventListener('load', function() { | |
navigator.serviceWorker.getRegistrations().then(registrations => { | |
for(let registration of registrations) { | |
registration.unregister().then(bool => {console.log('unregister: ', bool);}); | |
} | |
window.location.reload(); | |
}); | |
}); | |
} |
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
import { SUPERHEROES } from '../Constants'; | |
describe("Constants", () => { | |
it("SUPERHEROES should match snapshot", () => expect(SUPERHEROES).toMatchSnapshot()); | |
}); |
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
export const SUPERHEROES = [ | |
‘Batman’, | |
‘Superman’, | |
‘Deadpool’, | |
‘Wolverine’ | |
]; |
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
import Header from '../Header'; | |
const DATA = { | |
title: ‘Avengers’, | |
subtitle: ‘Infinity War’ | |
}; | |
const wrapper = shallow(<Header data={DATA} />); | |
//we omit the unit tests for props |
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
import React, { Component } from 'react'; | |
import { object } from 'prop-types'; | |
import './header.css'; | |
export default class Header extends Component { | |
static propTypes = { | |
data: object | |
}; | |
static defaultProps = { |
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
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import MyFirstComponent from '../MyFirstComponent'; | |
const wrapper = shallow(<MyFirstComponent />); | |
let container, containerProp; | |
describe("MyFirstComponent - No props", () => { | |
it("should have state set properly", () => { | |
expect(wrapper.state().buttonEnable).toEqual(true); |
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
import React, { Component } from 'react'; | |
import { string } from 'prop-types'; | |
import './my-first-component.css'; | |
export default class MyFirstComponent extends Component { | |
static propTypes = { | |
title: string | |
}; | |
static defaultProps = { |
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
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import ChildComponent from '../ChildComponent'; | |
const onSubmitSpy = jest.fn(); | |
const onSubmit = onSubmitSpy; | |
const wrapper = shallow(<ChildComponent onSubmit={onSubmitSpy} />); | |
let container, containerButton; |
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
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import MainComponent from '../MainComponent'; | |
jest.mock('../ChildComponent'); //ChildComponent is now a mock constructor | |
const wrapper = shallow(<MainComponent />); | |
let container, containerProp, childContainer, childContainerProps; | |
describe("MainComponent", () => { |
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
import React, { Component } from 'react'; | |
import { string, func } from 'prop-types'; | |
import './child-component.css'; | |
export default class ChildComponent extends Component { | |
static propTypes = { | |
label: string, | |
onSubmit: func.isRequired | |
}; |
NewerOlder