Created
February 24, 2016 05:56
-
-
Save mcgrue/58068a80f1da4087cc10 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
| it.only('works', function (){ | |
| const resultFn = fetchPosts( 'hot-tacos' ); | |
| expect(typeof resultFn).toEqual('function'); | |
| const dispatchStack = []; | |
| const fakeDispatchFn = (dispatched) => { | |
| dispatchStack.push(dispatched); | |
| }; | |
| const fakeRes = { | |
| json : () => { return getFakeRedditResponse(); } | |
| }; | |
| expect(dispatchStack.length).toEqual(0); | |
| const fakePromises = resultFn(fakeDispatchFn); | |
| const callstack = fakePromises.callstack; | |
| expect(dispatchStack.length).toEqual(1); | |
| expect(callstack.length).toEqual(3); | |
| expect(callstack[0]).toEqual("http://www.reddit.com/r/hot-tacos.json"); | |
| const return1 = callstack[1](fakeRes); | |
| expect(return1).toEqual( getFakeRedditResponse() ); | |
| expect(dispatchStack.length).toEqual(1); | |
| const return2 = callstack[2]( getFakeRedditResponse() ); | |
| expect(dispatchStack.length).toEqual(2); | |
| console.log(dispatchStack); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment