2. REACT INTRODUCTION
• Declarative
React will efficiently update and render just the right components when your data
changes
• Component Based
Build encapsulated components that manage their own state, then compose them
to make complex UIs
• Learn Once, Write Anywhere ( Debug Everywhere ~ Pardi )
React can also render on the server using Node and power mobile apps using
React Native.
6. TESTING (FULL DOM RENDERING)
import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';
import MyComponent from './MyComponent';
import Foo from './Foo';
describe('<Foo />', () => {
it('allows us to set props', () => {
const wrapper = mount(<Foo bar="baz" />);
expect(wrapper.props().bar).to.equal('baz');
wrapper.setProps({ bar: 'foo' });
expect(wrapper.props().bar).to.equal('foo');
});
it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = mount(
<Foo onButtonClick={onButtonClick} />
);
wrapper.find('button').simulate('click');
expect(onButtonClick).to.have.property('callCount',
1);
});
it('calls componentDidMount', () => {
sinon.spy(Foo.prototype, 'componentDidMount');
const wrapper = mount(<Foo />);
expect(Foo.prototype.componentDidMount).to.ha
ve.property('callCount', 1);
Foo.prototype.componentDidMount.restore();
});
});
7. GRAPHQL INTRODUCTION
GraphQL is a query language for APIs and a runtime for fulfilling those
queries with your existing data. GraphQL provides a complete and
understandable description of the data in your API, gives clients the power
to ask for exactly what they need and nothing more, makes it easier to
evolve APIs over time, and enables powerful developer tools
Ask what you need, give what you need
{
hero {
name
height
}
}
{
"hero": {
"name": "Luke Skywalker",
"height": 1.72,
}
}
Will Return
8. GRAPHQL TESTING
We use :
• Mocha – JS Test Framework (describe, it)
• Chai - JS BDD / TDD assertion library (expect)
• graphql-tools - Graphql Schema Builder (mockServer, MockList)
• casual-browserify – Fake data generator (casual)