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
javascript:var%20%24jscomp%3D%24jscomp%7C%7C%7B%7D%3B%24jscomp.scope%3D%7B%7D%3B%24jscomp.createTemplateTagFirstArg%3Dfunction(a)%7Breturn%20a.raw%3Da%7D%3B%24jscomp.createTemplateTagFirstArgWithRaw%3Dfunction(a%2Cb)%7Ba.raw%3Db%3Breturn%20a%7D%3Bvar%20getDeckListFromDom%3Dfunction(a)%7Ba%3Dvoid%200%3D%3D%3Da%3F%22D%22%3Aa%3Bvar%20b%3D%22%22%3Bdocument.querySelectorAll(%22.card-controller-inner%22).forEach(function(c)%7Bvar%20d%3Dc.firstChild.title.split(%22%3A%22)%5B1%5D.trim()%3Bc%3Dc.lastChild.innerText%3Bd%3Dd.concat(%22%20%5B%22%2Ba%2B%22%20Format%5D%22)%3Bb%3Db.concat(%22%5Cn%22%2Cc%2B%22%20%22%2Bd)%7D)%3Breturn%20b%7D%2Clist%3DgetDeckListFromDom()%3Bprompt(%22Please%20copy%20your%20decklist%20and%20import%20it%20to%20Cardmarket%22%2Clist)%3Bvoid+0 |
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
/** | |
* Calculates the angle based on the user's mouse position and a given point | |
* @param {*} x1 - Mouse X pos | |
* @param {*} y1 - Mouse Y pos | |
*/ | |
const getAngle = (x1, y1, x2, y2) => { | |
var distY = Math.abs(y2 - y1); | |
var distX = Math.abs(x2 - x1); | |
// Calculate the hypotenuse | |
var dist = Math.sqrt((distY * distY) + (distX * distX)); |
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
it("should increase counter when the button is clicked", () => { | |
wrapper.find("button").simulate("click") | |
expect(wrapper.find("h1").text()).toContain("1") | |
}) |
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 App from './App'; | |
import { shallow } from 'enzyme' | |
// 1. Test suite | |
describe("[UNIT] Testing the App component", () => { | |
let wrapper | |
// 2. A Jest setup helper function | |
beforeEach(() => { |
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
class App extends Component { | |
state = { | |
counter: 0 | |
} | |
handleClick = () => { | |
this.setState(state => { | |
return { | |
counter: state.counter + 1 | |
} |
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
PASS src/App.spec.js | |
✓ renders without crashing (2ms) | |
Test Suites: 1 passed, 1 total | |
Tests: 1 passed, 1 total | |
Snapshots: 0 total | |
Time: 0.097s, estimated 1s | |
Ran all test suites. |
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
// App.spec.js | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import App from './App'; | |
it('renders without crashing', () => { | |
const div = document.createElement('div'); | |
ReactDOM.render(<App />, div); | |
ReactDOM.unmountComponentAtNode(div); | |
}); |
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
// /src/setupTests.js | |
import { configure } from 'enzyme'; | |
import Adapter from 'enzyme-adapter-react-16'; | |
configure({ adapter: new Adapter() }); |
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
function add(x, y) { | |
// Check if the parameters are numbers | |
// If not, throw an error | |
if (isNaN(x) || isNaN(y)) { | |
throw new Error("Parameter is not a number !") | |
} | |
return x + y | |
} | |
describe("add method", () => { |
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
it("should return -2", () => { | |
expect(add(0, -2)).toBe(-2) | |
}) |
NewerOlder