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
# With in Expression inside guard clause | |
case result do | |
result when result in [:ok, true, 1] -> :ok | |
_ -> :error | |
end | |
# Without in Expression | |
case result do | |
:ok -> :ok | |
true -> :ok |
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
class ComponentToBeTested extends Component { | |
// 생략 | |
multiply(data) { | |
return data * 10; | |
} | |
square(data) { | |
return Math.pow(data, 3); // 의도된 실수 | |
} |
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
it('should render <ChildComponent />', () => { | |
const wrapper = shallow(<ComponentToBeTested />); | |
expect(wrapper.find('ChildComponent').length).toEqual(1); | |
}); | |
it('should pass a number multiplied by 10 as data prop', () => { | |
const wrapper = shallow(<ComponentToBeTested data={2}/>); | |
expect(wrapper.find('ChildComponent').prop('data')).toEqual(20); | |
}); |
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
class ComponentToBeTested extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isActive: false | |
}; | |
this.handleButtonClick = this.handleButtonClick.bind(this); | |
} | |
handleButtonClick() { |
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
class ComponentToBeTested extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isActive: false, | |
}; | |
this.handleButtonClick = this.handleButtonClick.bind(this); | |
} | |
handleButtonClick() { |
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
it('should render button.test-button', () => { | |
const wrapper = shallow(<ComponentToBeTested />); | |
expect(wrapper.find('button.test-button').length).toEqual(1); | |
}); | |
it('should render text \'FOO\' inside button.test-button', () => { | |
const wrapper = shallow(<ComponentToBeTested />); | |
expect(wrapper.find('button.test-button').text()).toEqual('FOO'); | |
}); |
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
class ComponentToBeTested extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isActive: false, | |
}; | |
} | |
// 생략 | |
} |
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
it('should have isActive state\(default: false\)', () => { | |
const wrapper = shallow(<ComponentToBeTested />); | |
expect(wrapper.state('isActive')).toEqual(false); | |
}); |
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
import React, { Component } from 'react'; | |
class ComponentToBeTested extends Component { | |
render() { | |
return ( | |
<div className="ComponentToBeTested" /> | |
); | |
} | |
} |
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
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import ComponentToBeTested from './ComponentToBeTested'; | |
it('renders without crashing', () => { | |
shallow(<ComponentToBeTested />); | |
}); |
NewerOlder