add support for FormData

This commit is contained in:
Randall Schmidt
2020-11-28 11:43:50 -05:00
parent 3b5adecd7f
commit 9241b74dde
4 changed files with 106 additions and 0 deletions

View File

@ -1,4 +1,5 @@
const fs = require('fs');
const FormData = require('form-data');
const assert = require('assert');
const rimraf = require('rimraf');
const path = require('path');
@ -163,6 +164,34 @@ describe('Cache tests', function() {
res = await fetch(TWO_HUNDRED_URL, post(s1));
assert.strictEqual(res.fromCache, true);
});
it('Gives different form data different cache keys', async function() {
const data1 = new FormData();
data1.append('a', 'a');
const data2 = new FormData();
data2.append('b', 'b');
res = await fetch(TWO_HUNDRED_URL, post(data1));
assert.strictEqual(res.fromCache, false);
res = await fetch(TWO_HUNDRED_URL, post(data2));
assert.strictEqual(res.fromCache, false);
});
it('Gives same form data same cache keys', async function() {
const data1 = new FormData();
data1.append('a', 'a');
const data2 = new FormData();
data2.append('a', 'a');
res = await fetch(TWO_HUNDRED_URL, post(data1));
assert.strictEqual(res.fromCache, false);
res = await fetch(TWO_HUNDRED_URL, post(data2));
assert.strictEqual(res.fromCache, true);
});
}).timeout(10000);
describe('Data tests', function() {