add is.formData

This commit is contained in:
kaysonwu 2021-09-11 17:26:20 +08:00
parent b007935b4b
commit c6eac3ebd4
2 changed files with 25 additions and 0 deletions

View file

@ -1621,6 +1621,27 @@ test('is.all', t => {
});
});
test('is.formData', t => {
const data = new window.FormData();
t.true(is.formData(data));
t.false(is.formData({}));
t.false(is.formData(undefined));
t.false(is.formData(null));
t.notThrows(() => {
assert.formData(data);
});
t.throws(() => {
assert.formData({});
});
t.throws(() => {
assert.formData(undefined);
});
t.throws(() => {
assert.formData(null);
});
});
test('assert', t => {
// Contrived test showing that TypeScript acknowledges the type assertion in `assert.number()`.
// Real--world usage includes asserting user input, but here we use a random number/string generator.