feat: fork drizzle-typebox as @alkdev/drizzlebox
- Rebrand package from drizzle-typebox to @alkdev/drizzlebox - Replace @sinclair/typebox with @alkdev/typebox in all source and test files - Replace @sinclair/typebox with @alkdev/typebox in rollup externals - Convert tsconfig.json from monorepo extends to standalone config - Fix build script monorepo remnant (dist.new -> dist) - Add missing devDependencies (recast, tsx, typescript, resolve-tspaths) - Replace monorepo link dependency for drizzle-orm with ^0.38.4 - Add .gitignore, LICENSE (Apache-2.0 with attribution), and README - Initialize git repo with remote at git.alk.dev:alkdev/drizzlebox
This commit is contained in:
34
tests/utils.ts
Normal file
34
tests/utils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type * as t from '@alkdev/typebox';
|
||||
import { expect, type TaskContext } from 'vitest';
|
||||
|
||||
function removeKeysFromObject(obj: Record<string, any>, keys: string[]) {
|
||||
for (const key of keys) {
|
||||
delete obj[key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function expectSchemaShape<T extends t.TObject>(t: TaskContext, expected: T) {
|
||||
return {
|
||||
from(actual: T) {
|
||||
expect(Object.keys(actual.properties)).toStrictEqual(Object.keys(expected.properties));
|
||||
const keys = ['$id', '$schema', 'title', 'description', 'default', 'examples', 'readOnly', 'writeOnly'];
|
||||
|
||||
for (const key of Object.keys(actual.properties)) {
|
||||
expect(removeKeysFromObject(actual.properties[key]!, keys)).toStrictEqual(
|
||||
removeKeysFromObject(expected.properties[key]!, keys),
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function expectEnumValues<T extends t.TEnum<any>>(t: TaskContext, expected: T) {
|
||||
return {
|
||||
from(actual: T) {
|
||||
expect(actual.anyOf).toStrictEqual(expected.anyOf);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function Expect<_ extends true>() {}
|
||||
Reference in New Issue
Block a user