kubricate
Version:
A TypeScript framework for building reusable, type-safe Kubernetes infrastructure — without the YAML mess.
35 lines (34 loc) • 1.75 kB
JavaScript
;
var _vitest = /*#__PURE__*/require("vitest");
var _utils = /*#__PURE__*/require("./utils.js");
// adjust the import path if needed
(0, _vitest.describe)('validateString', () => {
(0, _vitest.it)('should not throw for string values', () => {
(0, _vitest.expect)(() => (0, _utils.validateString)('hello')).not.toThrow();
});
(0, _vitest.it)('should throw TypeError for non-string values', () => {
const invalidValues = [42, true, null, undefined, {}, [], () => {}];
for (const value of invalidValues) {
(0, _vitest.expect)(() => (0, _utils.validateString)(value)).toThrowError(TypeError);
(0, _vitest.expect)(() => (0, _utils.validateString)(value)).toThrowError(/Expected a string, but received:/);
}
});
});
(0, _vitest.describe)('getClassName', () => {
(0, _vitest.it)('should return constructor name for object instances', () => {
class MyClass {}
const instance = new MyClass();
(0, _vitest.expect)((0, _utils.getClassName)(instance)).toBe('MyClass');
(0, _vitest.expect)((0, _utils.getClassName)([])).toBe('Array');
(0, _vitest.expect)((0, _utils.getClassName)({})).toBe('Object');
(0, _vitest.expect)((0, _utils.getClassName)(new Date())).toBe('Date');
});
(0, _vitest.it)('should return "Unknown" for primitives and null/undefined', () => {
(0, _vitest.expect)((0, _utils.getClassName)(null)).toBe('Unknown');
(0, _vitest.expect)((0, _utils.getClassName)(undefined)).toBe('Unknown');
(0, _vitest.expect)((0, _utils.getClassName)('string')).toBe('Unknown');
(0, _vitest.expect)((0, _utils.getClassName)(123)).toBe('Unknown');
(0, _vitest.expect)((0, _utils.getClassName)(true)).toBe('Unknown');
});
});
//# sourceMappingURL=utils.test.js.map