Skip to content

Commit d610049

Browse files
committed
test(models): fix asserted error messages
1 parent a473c11 commit d610049

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

packages/models/src/lib/implementation/schemas.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export function metaSchema(options?: {
146146
export const filePathSchema = z
147147
.string()
148148
.trim()
149-
.min(1, { message: 'The path is invalid' })
149+
.min(1)
150150
.meta({ title: 'FilePath' });
151151

152152
/**
@@ -156,16 +156,11 @@ export const filePathSchema = z
156156
*/
157157
const globRegex = /^!?[^<>"|]+$/;
158158

159-
export const globPathSchema = z
160-
.string()
161-
.trim()
162-
.min(1, { message: 'The glob pattern is invalid' })
163-
.regex(globRegex)
164-
.meta({
165-
title: 'GlobPath',
166-
description:
167-
'Schema for a glob pattern (supports wildcards like *, **, {}, !, etc.)',
168-
});
159+
export const globPathSchema = z.string().trim().min(1).regex(globRegex).meta({
160+
title: 'GlobPath',
161+
description:
162+
'Schema for a glob pattern (supports wildcards like *, **, {}, !, etc.)',
163+
});
169164

170165
/** Schema for a fileNameSchema */
171166
export const fileNameSchema = z

packages/models/src/lib/implementation/schemas.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('globPathSchema', () => {
8282
'should throw for invalid path with forbidden character: %s',
8383
pattern => {
8484
expect(() => globPathSchema.parse(pattern)).toThrow(
85-
'valid file path or glob pattern',
85+
'Invalid string: must match pattern',
8686
);
8787
},
8888
);

packages/models/src/lib/persist-config.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ describe('persistConfigSchema', () => {
2323
it('should throw for an empty file name', () => {
2424
expect(() =>
2525
persistConfigSchema.parse({ filename: ' ' } as PersistConfig),
26-
).toThrow('file name is invalid');
26+
).toThrow('Invalid string: must match pattern');
2727
});
2828

2929
it('should throw for an empty output directory', () => {
3030
expect(() =>
3131
persistConfigSchema.parse({ outputDir: ' ' } as PersistConfig),
32-
).toThrow('path is invalid');
32+
).toThrow('Too small: expected string to have >=1 characters');
3333
});
3434

3535
it('should throw for an invalid format', () => {

packages/models/src/lib/runner-config.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('runnerConfigSchema', () => {
4343
command: 'node',
4444
outputFile: '',
4545
}),
46-
).toThrow('path is invalid');
46+
).toThrow('Too small: expected string to have >=1 characters');
4747
});
4848
});
4949

0 commit comments

Comments
 (0)