mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
* chore: small fixes to tests * feat: transitional move to vitests * feat: moving unit tests in progress * feat: moving more unit tests over * feat: more tests moved * feat: updated more sections of the http test * chore: wip http tests * chore: wip http tests * chore: more http tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: remove un-needed docs * chore: update package lock * chore: update lock
57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
/* eslint-env mocha */
|
|
'use strict';
|
|
|
|
import validator from '../../../lib/helpers/validator';
|
|
|
|
describe('validator::assertOptions', function () {
|
|
it('should throw only if unknown an option was passed', function () {
|
|
expect(function () {
|
|
validator.assertOptions(
|
|
{
|
|
x: true,
|
|
},
|
|
{
|
|
y: validator.validators.boolean,
|
|
}
|
|
);
|
|
}).toThrow(new Error('Unknown option x'));
|
|
|
|
expect(function () {
|
|
validator.assertOptions(
|
|
{
|
|
x: true,
|
|
},
|
|
{
|
|
x: validator.validators.boolean,
|
|
y: validator.validators.boolean,
|
|
}
|
|
);
|
|
}).not.toThrow(new Error('Unknown option x'));
|
|
});
|
|
|
|
it("should throw TypeError only if option type doesn't match", function () {
|
|
expect(function () {
|
|
validator.assertOptions(
|
|
{
|
|
x: 123,
|
|
},
|
|
{
|
|
x: validator.validators.boolean,
|
|
}
|
|
);
|
|
}).toThrow(new TypeError('option x must be a boolean'));
|
|
|
|
expect(function () {
|
|
validator.assertOptions(
|
|
{
|
|
x: true,
|
|
},
|
|
{
|
|
x: validator.validators.boolean,
|
|
y: validator.validators.boolean,
|
|
}
|
|
);
|
|
}).not.toThrow();
|
|
});
|
|
});
|