Skip to content

Commit 4e22921

Browse files
committed
fix: use match
1 parent e5e96e9 commit 4e22921

1 file changed

Lines changed: 21 additions & 31 deletions

File tree

packages/stream-model-instance-handler/src/__tests__/schema-utils.test.ts

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,54 +102,44 @@ describe('SchemaValidation', () => {
102102
})
103103

104104
it('validates content that conforms to schema', async () => {
105-
await expect(() => {
106-
schemaValidator.validateSchema(CONTENT_VALID, MODEL_DEFINITION.schema, SCHEMA_COMMIT_ID)
107-
}).resolves
105+
await expect(schemaValidator.validateSchema(CONTENT_VALID, MODEL_DEFINITION.schema, SCHEMA_COMMIT_ID)).resolves
108106
})
109107

110108
it('throws when required properties are missing', async () => {
111-
await expect(() => {
112-
schemaValidator.validateSchema(
113-
CONTENT_NO_REQ_PROPS,
114-
MODEL_DEFINITION.schema,
115-
SCHEMA_COMMIT_ID
116-
)
117-
}).rejects.toThrow(
109+
await expect(schemaValidator.validateSchema(
110+
CONTENT_NO_REQ_PROPS,
111+
MODEL_DEFINITION.schema,
112+
SCHEMA_COMMIT_ID
113+
)).rejects.toMatch(
118114
/data must have required property 'arrayProperty', data must have required property 'stringArrayProperty', data must have required property 'stringProperty', data must have required property 'intProperty', data must have required property 'floatProperty'/
119115
)
120116
})
121117

122118
it('throws when min values requirements are not respected', async () => {
123-
await expect(() => {
124-
schemaValidator.validateSchema(
125-
CONTENT_MINS_NOT_RESPECTED,
126-
MODEL_DEFINITION.schema,
127-
SCHEMA_COMMIT_ID
128-
)
129-
}).rejects.toThrow(
119+
await expect(schemaValidator.validateSchema(
120+
CONTENT_MINS_NOT_RESPECTED,
121+
MODEL_DEFINITION.schema,
122+
SCHEMA_COMMIT_ID
123+
)).rejects.toMatch(
130124
/data\/arrayProperty must NOT have fewer than 2 items, data\/stringArrayProperty\/0 must NOT have fewer than 2 characters, data\/stringProperty must NOT have fewer than 3 characters, data\/intProperty must be >= 2, data\/floatProperty must be >= 3/
131125
)
132126
})
133127

134128
it('throws when max values requirements are not respected', async () => {
135-
await expect(() => {
136-
schemaValidator.validateSchema(
137-
CONTENT_MAXS_NOT_RESPECTED,
138-
MODEL_DEFINITION.schema,
139-
SCHEMA_COMMIT_ID
140-
)
141-
}).rejects.toThrow(
129+
await expect(schemaValidator.validateSchema(
130+
CONTENT_MAXS_NOT_RESPECTED,
131+
MODEL_DEFINITION.schema,
132+
SCHEMA_COMMIT_ID
133+
)).rejects.toMatch(
142134
/data\/arrayProperty must NOT have more than 4 items, data\/stringArrayProperty\/0 must NOT have more than 6 characters, data\/stringProperty must NOT have more than 8 characters, data\/intProperty must be <= 100, data\/floatProperty must be <= 110/
143135
)
144136
})
145137

146138
it('throws when additional values are given', async () => {
147-
await expect(() => {
148-
schemaValidator.validateSchema(
149-
CONTENT_WITH_ADDITIONAL_PROPERTY,
150-
MODEL_DEFINITION.schema,
151-
SCHEMA_COMMIT_ID
152-
)
153-
}).rejects.toThrow(/data must NOT have additional properties/)
139+
await expect(schemaValidator.validateSchema(
140+
CONTENT_WITH_ADDITIONAL_PROPERTY,
141+
MODEL_DEFINITION.schema,
142+
SCHEMA_COMMIT_ID
143+
)).rejects.toMatch(/data must NOT have additional properties/)
154144
})
155145
})

0 commit comments

Comments
 (0)