Skip to content

Commit

Permalink
Test forEach.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgraham committed May 29, 2015
1 parent 42ba790 commit 2f442ce
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ suite('Headers', function() {
headers.set({field: 'value'}, 'application/json');
}, TypeError)
})
test('is iterable with forEach', function() {
var headers = new Headers()
headers.append('Accept', 'application/json')
headers.append('Accept', 'text/plain')
headers.append('Content-Type', 'text/html')

var results = []
headers.forEach(function(value, key, object) {
results.push({value: value, key: key, object: object})
})

assert.equal(results.length, 3)
assert.deepEqual({key: 'accept', value: 'application/json', object: headers}, results[0])
assert.deepEqual({key: 'accept', value: 'text/plain', object: headers}, results[1])
assert.deepEqual({key: 'content-type', value: 'text/html', object: headers}, results[2])
})
})

// https://fetch.spec.whatwg.org/#request-class
Expand Down

0 comments on commit 2f442ce

Please sign in to comment.