@takeshape/json-schema 11.73.0 → 11.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,143 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { isAllOfSchema, isAnyOfSchema, isArraySchema, isEnumSchema, isListSchema, isObjectSchema, isOneOfSchema, isPropertySchema, isRefSchema, isSchema, isTupleSchema, isUnionSchema } from "../type-utils.js";
3
- describe('isSchema', () => {
4
- it('should return true for valid JSONSchema7', () => {
5
- const schema = { type: 'object' };
6
- expect(isSchema(schema)).toBe(true);
7
- });
8
- it('should return false for boolean schema', () => {
9
- const schema = false;
10
- expect(isSchema(schema)).toBe(false);
11
- });
12
- });
13
- describe('isOneOfSchema', () => {
14
- it('should return true for oneOf schema', () => {
15
- const schema = { oneOf: [{ type: 'string' }] };
16
- expect(isOneOfSchema(schema)).toBe(true);
17
- });
18
- it('should return false for non-oneOf schema', () => {
19
- const schema = { type: 'string' };
20
- expect(isOneOfSchema(schema)).toBe(false);
21
- });
22
- });
23
- describe('isAnyOfSchema', () => {
24
- it('should return true for anyOf schema', () => {
25
- const schema = { anyOf: [{ type: 'string' }] };
26
- expect(isAnyOfSchema(schema)).toBe(true);
27
- });
28
- it('should return false for non-anyOf schema', () => {
29
- const schema = { type: 'string' };
30
- expect(isAnyOfSchema(schema)).toBe(false);
31
- });
32
- });
33
- describe('isAllOfSchema', () => {
34
- it('should return true for allOf schema', () => {
35
- const schema = { allOf: [{ type: 'string' }] };
36
- expect(isAllOfSchema(schema)).toBe(true);
37
- });
38
- it('should return false for non-allOf schema', () => {
39
- const schema = { type: 'string' };
40
- expect(isAllOfSchema(schema)).toBe(false);
41
- });
42
- });
43
- describe('isUnionSchema', () => {
44
- it('should return true for allOf/anyOf/oneOf schema', () => {
45
- expect(isUnionSchema({ allOf: [{ type: 'string' }] })).toBe(true);
46
- expect(isUnionSchema({ anyOf: [{ type: 'string' }] })).toBe(true);
47
- expect(isUnionSchema({ oneOf: [{ type: 'string' }] })).toBe(true);
48
- });
49
- it('should return false for non-allOf/anyOf/oneOf schema', () => {
50
- const schema = { type: 'string' };
51
- expect(isUnionSchema(schema)).toBe(false);
52
- });
53
- });
54
- describe('isObjectSchema', () => {
55
- it('should return true for object schema', () => {
56
- const schema = { type: 'object' };
57
- expect(isObjectSchema(schema)).toBe(true);
58
- });
59
- it('should return false for non-object schema', () => {
60
- const schema = { type: 'string' };
61
- expect(isObjectSchema(schema)).toBe(false);
62
- });
63
- });
64
- describe('isPropertySchema', () => {
65
- it('should return true for an object schema with properties', () => {
66
- const schema = { type: 'object', properties: {} };
67
- expect(isPropertySchema(schema)).toBe(true);
68
- });
69
- it('should return false for non-property schema', () => {
70
- const schema = { type: 'object' };
71
- expect(isPropertySchema(schema)).toBe(false);
72
- });
73
- });
74
- describe('isRefSchema', () => {
75
- it('should return true for a schema with $ref', () => {
76
- const schema = { $ref: '#/definitions/definition' };
77
- expect(isRefSchema(schema)).toBe(true);
78
- });
79
- it('should return false for non-$ref schema', () => {
80
- const schema = { type: 'string' };
81
- expect(isRefSchema(schema)).toBe(false);
82
- });
83
- });
84
- describe('isEnumSchema', () => {
85
- it('should return true for a schema with enums', () => {
86
- const schema = { enum: ['value1', 'value2'] };
87
- expect(isEnumSchema(schema)).toBe(true);
88
- });
89
- it('should return false for non-enum schema', () => {
90
- const schema = { type: 'string' };
91
- expect(isEnumSchema(schema)).toBe(false);
92
- });
93
- });
94
- describe('isArraySchema', () => {
95
- it('should return true for an array schema', () => {
96
- const schema = { type: 'array' };
97
- expect(isArraySchema(schema)).toBe(true);
98
- });
99
- it('should return false for non-array schema', () => {
100
- const schema = { type: 'string' };
101
- expect(isArraySchema(schema)).toBe(false);
102
- });
103
- });
104
- describe('isListSchema', () => {
105
- it('should return true for an array list schema', () => {
106
- const schema = {
107
- type: 'array',
108
- items: { type: 'string' }
109
- };
110
- expect(isListSchema(schema)).toBe(true);
111
- });
112
- it('should return false for partial list schema', () => {
113
- const schema = { type: 'array' };
114
- expect(isListSchema(schema)).toBe(false);
115
- });
116
- it('should return false for a tuple schema', () => {
117
- const schema = {
118
- type: 'array',
119
- items: [{ type: 'string' }]
120
- };
121
- expect(isListSchema(schema)).toBe(false);
122
- });
123
- });
124
- describe('isTupleSchema', () => {
125
- it('should return true for tuple schema', () => {
126
- const schema = {
127
- type: 'array',
128
- items: [{ type: 'string' }]
129
- };
130
- expect(isTupleSchema(schema)).toBe(true);
131
- });
132
- it('should return false for partial array schema', () => {
133
- const schema = { type: 'array' };
134
- expect(isTupleSchema(schema)).toBe(false);
135
- });
136
- it('should return false for an array list schema', () => {
137
- const schema = {
138
- type: 'array',
139
- items: { type: 'string' }
140
- };
141
- expect(isTupleSchema(schema)).toBe(false);
142
- });
143
- });