axios-axios/test/specs/helpers/validator.spec.js
Jay fa337332b9
Update unit testing flows as part of migration to vitest (#7484)
* 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
2026-03-06 20:42:14 +02:00

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();
});
});