|
1 | 1 | import { describe, test, expect } from 'vitest' |
2 | | -import { examples, schema, Expression } from '../lib' |
| 2 | +import { examples, Schema, Expression } from '../lib' |
3 | 3 |
|
4 | 4 | describe('schema.json', () => { |
5 | 5 | for (const [name, example] of Object.entries(examples)) { |
@@ -36,38 +36,39 @@ describe('schema.json', () => { |
36 | 36 |
|
37 | 37 | describe('resolve', () => { |
38 | 38 | test('returns a schema', () => { |
39 | | - const ref = schema.resolve('#/definitions/constant') |
| 39 | + const ref = Schema.resolve('#/definitions/constant') |
40 | 40 | expect(ref.title).toEqual('Constant') |
41 | 41 | expect(ref.validate(true)).toEqual({ valid: true, errors: null }) |
42 | 42 | }) |
43 | 43 |
|
44 | 44 | test('resolves refs', () => { |
45 | | - expect(schema.resolve('#/definitions/function/properties/Any').title).toEqual('Any') |
46 | | - expect(schema.definitions.function.properties.Any.title).toEqual('Any') |
| 45 | + expect(Schema.resolve('#/definitions/function/properties/Any').title).toEqual('Any') |
| 46 | + expect(Schema.resolve('#').definitions.function.properties.Any.title).toEqual('Any') |
47 | 47 | }) |
48 | 48 | }) |
49 | 49 |
|
50 | 50 | describe('resolveAnyOf', () => { |
51 | 51 | test('returns nested anyOf', () => { |
52 | | - expect(schema.resolveAnyOf()).toHaveLength(4) |
| 52 | + const ref = Schema.resolve('#') |
| 53 | + expect(ref.resolveAnyOf()).toHaveLength(4) |
53 | 54 | }) |
54 | 55 |
|
55 | 56 | test('returns array of schemas', () => { |
56 | | - const ref = schema.resolve('#/definitions/constant') |
| 57 | + const ref = Schema.resolve('#/definitions/constant') |
57 | 58 | expect(ref.resolveAnyOf()).toHaveLength(3) |
58 | 59 | expect(ref.resolveAnyOf()).toEqual(ref.anyOf) |
59 | 60 | }) |
60 | 61 | }) |
61 | 62 |
|
62 | 63 | describe('arrayItem', () => { |
63 | 64 | test('returns schema for repeated array item', () => { |
64 | | - const any = schema.resolve("Any.schema.json") |
| 65 | + const any = Schema.resolve('Any.schema.json') |
65 | 66 | expect(any.arrayItem(0).title).toEqual('Expression') |
66 | 67 | expect(any.arrayItem(99).title).toEqual('Expression') |
67 | 68 | }) |
68 | 69 |
|
69 | 70 | test('returns schema for tuple', () => { |
70 | | - const duration = schema.resolve("Duration.schema.json") |
| 71 | + const duration = Schema.resolve('Duration.schema.json') |
71 | 72 | expect(duration.arrayItem(0).title).toEqual('Number') |
72 | 73 | expect(duration.arrayItem(1).title).toEqual('Unit') |
73 | 74 | expect(duration.arrayItem(2)).toBe(undefined) |
|
0 commit comments