Created
July 31, 2017 02:58
-
-
Save jbaxleyiii/b06c0ad194c53796703c9d6d96bc2c67 to your computer and use it in GitHub Desktop.
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
import { HERO_QUERY, withCharacter, Character, App } from '../App'; | |
import { | |
empty, | |
hero_no_friends, | |
empty_array_friends, | |
friend_without_appearsIn, | |
} from './__mocks__/data'; | |
// const mock = (hoc, props) => { | |
// return new Observable(observer => { | |
// const TestComponent extends Component { | |
// componentWillMount(){ | |
// observer.next("componentWillMount", shape(this.props)) | |
// } | |
// componentWillRecieveProps(next){ | |
// observer.next(shape(next, this.props)) | |
// } | |
// componentDidMount(){ | |
// observer.next(shapes(this.props)); | |
// } | |
// componentWillUnmount(){ | |
// observer.next("componentWillUnmount", shape(this.props)) | |
// observer.complete(); | |
// } | |
// } | |
// }) | |
// } | |
interface MockedGraphQLHOC { | |
// internal call capturing | |
options: (props: any) => any, | |
props: (result, props, error) => any, | |
skip: (props: any) => any, | |
// render component to observe lifecycle events | |
render: (props: any) => Observable<MockedResult>, | |
// actions | |
setProps: (props: any) => void, | |
setData: (data: any) => void, | |
setError: (error: Error) => void, | |
} | |
describe('withCharacter', () => { | |
it('shapes the props into variables', () => { | |
const mockedCharacter = mock(withCharacter); | |
const props = { episode: "NEWHOPE" }; | |
const { variables } = mockedCharacter.options(props); | |
expect(variables).toEqual(props); | |
}); | |
it('reshapes the data into the passed props'); | |
it('has a loading state'); | |
it('has a potential error state'); | |
it('returns the expected data shapes'); | |
}); | |
describe('Character', () => { | |
it('handles a loading state'); | |
it('handles an error state'); | |
it('returns markup for null response'); | |
it('returns markup for a hero with no friends'); | |
it('returns markup for empty array of friends'); | |
it('returns markup for a friend without an appearsIn'); | |
}); | |
describe('App', () => { | |
it('renders the data from NEWHOPE'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment