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
export default class Events extends React.Component { | |
constructor() { | |
/* no change */ | |
} | |
handle(e) { | |
const evt = e | |
this.setState({ count: this.state.count + 1 }) | |
console.log(`Event: `, evt) | |
} |
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
/* ... */ | |
handle(e) { | |
const evt = e.nativeEvent.inputEvent | |
this.setState({ count: this.state.count + 1 }) | |
console.log(`Event: `, evt) | |
} | |
/* ... */ |
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
handle(e) { | |
const evt = e.nativeEvent.inputEvent | |
if (evt.type === 'KeyboardInputEvent') { | |
this.setState({ count: this.state.count + 1 }) | |
console.log(`Key pressed. \nkeyCode: ${evt.keyCode}.\nkey: ${evt.key}\neventType: ${evt.eventType}`) | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script> | |
</head> | |
<body> | |
<div id="app"> |
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
describe('adder', () => { | |
it('adds two numbers', () => { | |
const result = adder(1, 2) | |
expect(result).toBe(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
const describe = (desc, fn) => { | |
console.log(desc) | |
fn() | |
} |
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
describe('Outer', () => { | |
describe('inner', () => { | |
}) | |
}) | |
// Outer | |
// inner |
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 it = (msg, fn) => describe(' ' + msg, fn) |
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 expect = (value) => { return /* object with toBe property */ } |
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 matchers = (exp) => ({ | |
toBe: (assertion) => { | |
if (exp === assertion) { | |
console.log('pass') | |
return true | |
} else { | |
console.log('fail') | |
return false | |
} | |
} |