16:31:53] Starting'copy-html'... [16:31:53] Finished'copy-html' after 15 ms [16:31:53] Starting'default'... [16:31:54] 2690 bytes written (0.09 seconds) [16:31:54] Finished'default' after 1.12 s
test('Link changes the class when hovered', () => { const component = renderer.create( <Linkpage="http://www.facebook.com">Facebook</Link> ); let tree = component.toJSON(); expect(tree).toMatchSnapshot();
// manually trigger the callback tree.props.onMouseEnter(); // re-rendering tree = component.toJSON(); expect(tree).toMatchSnapshot();
// manually trigger the callback tree.props.onMouseLeave(); // re-rendering tree = component.toJSON(); expect(tree).toMatchSnapshot();
test('CheckboxWithLabel changes the text after click', () => { // Render a checkbox with label in the document const checkbox = shallow( <CheckboxWithLabellabelOn="On"labelOff="Off" /> );
module.exports = classImageJpgextendsImage { constructor(path) { if (!path.match(/\.jpe?g$/)) { thrownewError(`${path} is not a JPEG image`); } super(path); } };
imagePng.js
1 2 3 4 5 6 7 8 9 10 11 12
"use strict";
constImage = require('./image');
module.exports = classImagePngextendsImage { constructor(path) { if (!path.match(/\.png$/)) { thrownewError(`${path} is not a PNG image`); } super(path); } };
imageGif.js
1 2 3 4 5 6 7 8 9 10 11 12
"use strict";
constImage = require('./image');
module.exports = classImageGifextendsImage { constructor(path) { if (!path.match(/\.gif/)) { thrownewError(`${path} is not a GIF image`); } super(path); } };
functioncreatePerson(name) { const privateProperties = {}; const person = { setName: name => { if (!name) thrownewError('A person must have a name'); privateProperties.name = name; }, getName: () => privateProperties.name };
person.setName(name); return person; }
const person = createPerson('Tomas Lin'); console.log(person.getName(), person);
module.exports = function (label) { if (process.env.NODE_ENV === 'development') { returnnewProfiler(label); //[1] } elseif (process.env.NODE_ENV === 'production') { return { //[2] start: function () { }, end: function () { } } } else { thrownewError('Must set NODE_ENV'); } }
profilerTest.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14
const profiler = require('./profile');
functiongetRandomArray(len) { const p = profiler(`Generating a ${len} items long array`); p.start(); const arr = []; for (let i = 0; i < len; i++) { arr.push(Math.random()); } p.end(); }