mirror of
https://github.com/axios/axios.git
synced 2026-04-14 03:11:58 +08:00
* fix/Avoid package.json import; (#4041) * Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`; Refactored `http.js` to use `env/data.js` instead of package.json; * Added `env/data.js`; Added `env/README.md`; * Feat/export package version constant (#4065) * Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`; Refactored `http.js` to use `env/data.js` instead of package.json; * Added `env/data.js`; Added `env/README.md`; * Export package version constant; * Fixed cancelToken leakage; Added AbortController support; (#3305) * Fixed cancelToken leakage; Added AbortController support; * Fixed typings; * Documented `signal` option; * Added processing of early cancellation using AbortController without sending a request; Co-authored-by: Jay <jasonsaayman@gmail.com> * Updating CI to run on release branches * Fixed default transitional config for custom Axios instance; (#4052) Refactored `/core/mergeConfig`; Co-authored-by: Jay <jasonsaayman@gmail.com> * Prepping v0.22.0 for release * Updated date Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
var validator = require('../../../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();
|
|
});
|
|
});
|