Created
September 13, 2016 21:33
-
-
Save marr/7909958f39dc5b504cafa7be2a348e19 to your computer and use it in GitHub Desktop.
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 'isomorphic-fetch' | |
import { test } from 'tap' | |
import nock from 'nock' | |
nock('http://localhost') | |
.get(/item\/(.*)/) | |
.times(2) | |
.reply(200, function(url, requestBody) { | |
const user = url.substr(url.lastIndexOf('/') + 1) | |
return `You found user ${user}` | |
}) | |
test('maintain a list of promises', assert => { | |
const items = [{ id: 1 }, { id: 2 }] | |
items.forEach(async ({ id }) => { | |
const text = await fetch(`http://localhost/item/${id}`).then(res => { | |
return res.text() | |
}) | |
assert.equal(text, `You found user ${id}`) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment