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 Service from 'path/to/service'; | |
import 'jasmine-ajax' | |
describe('Service', () => { | |
let request, promise; | |
let instance = Service; | |
let payload = {foo:'bar'}; | |
let path = '/path'; | |
let callback = jasmine.createSpy('callback'); |
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
describe('saveResource', () => { | |
let resource = { id: 5, name: 'foo' }; | |
describe('when the response is a 200', () => { | |
let dispatch = jasmine.createSpy('dispatch'); | |
beforeEach(() => { | |
spyOn(Service, 'post').and.callFake(function(url, payload, callback) { | |
callback(200, {foo: 'bar'}) | |
}) | |
}); |
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 Constants from '../path/to/constants'; | |
import Service from '../path/to/service'; | |
const Actions = { | |
toggleSomething: (id) => ({ | |
type: Constants.TOGGLE_SOMETHING, | |
id | |
}), | |
resourceSuccessfullySaved: (data) => ({ | |
type: Constants.RESOURCE_SUCCESSFULLY_SAVED, |
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
const mapDispatchToProps = (dispatch, ownProps) => ({ | |
saveResource: (resource, event) => { | |
Actions.saveResource(resource)(dispatch); | |
}, | |
toggleSomething: (id, event) => { | |
dispatch(Actions.toggleSomething(id)); | |
} | |
}); |
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 axios from 'axios'; | |
class Service { | |
constructor() { | |
let service = axios.create({ | |
headers: {csrf: 'token'} | |
}); | |
service.interceptors.response.use(this.handleSuccess, this.handleError); | |
this.service = service; | |
} |
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
yum install -y libpng | |
yum install -y libjpeg | |
yum install -y openssl | |
yum install -y icu | |
yum install -y libX11 | |
yum install -y libXext | |
yum install -y libXrender | |
yum install -y xorg-x11-fonts-Type1 | |
yum install -y xorg-x11-fonts-75dpi |
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 TestUtils from 'react/lib/ReactTestUtils'; | |
import actions from '../actions' | |
import ConnectedAddTodo from './AddTodo.js' | |
import { Provider } from 'react-redux'; | |
import configureMockStore from 'redux-mock-store'; | |
const store = configureMockStore()({}); | |
describe('AddTodo', () => { | |
let instance, container; |
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 { connect } from 'react-redux'; | |
import AddTodoForm from '../components/AddTodoForm' | |
import actions from '../actions'; | |
// mapDispatchToProps receives the dispatch() method and returns | |
// callback props that can be used to inject into the presentational component | |
// This means addTodo can be set as a prop when testing AddTodoForm which makes | |
// it easy to spy and check the correct actions are triggered | |
export const mapDispatchToProps = (dispatch) => ({ | |
addTodo: (value) => dispatch(actions.addTodo(value)) |
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 TestUtils from 'react/lib/ReactTestUtils'; | |
import Todo from './Todo'; | |
describe('Todo', () => { | |
let instance, li; | |
let Wrapper = React.createClass({ | |
render: function() { | |
return this.props.children; | |
} |
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, { PropTypes } from 'react' | |
const Todo = ({ onClick, completed, text }) => ( | |
<li | |
onClick={onClick} | |
style={{ | |
textDecoration: completed ? 'line-through' : 'none' | |
}} | |
> | |
{text} |
NewerOlder