Skip to content

Commit

Permalink
chore(tests): Fix test running setup
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Sep 13, 2022
1 parent 6dd1311 commit 21d6aaa
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"update-dependencies": "ncu -u && lerna exec -- ncu -u -x node-fetch -x chalk",
"clean": "find . -name node_modules -exec rm -rf '{}' + && find . -name package-lock.json -exec rm -rf '{}' +",
"test:deno": "deno test --config deno/tsconfig.json deno/test.ts",
"test": "npm run lint && npm run compile && c8 lerna run test --ignore @feathersjs/tests --ignore @feathersjs/adapter-commons"
"test": "npm run lint && npm run compile && c8 lerna run test"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.37.0",
Expand Down
48 changes: 27 additions & 21 deletions packages/schema/test/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ export const userSchema = schema({
}
} as const)

export const userResultSchema = schema({
$id: 'UserResult',
type: 'object',
additionalProperties: false,
required: ['id', ...userSchema.required],
properties: {
...userSchema.properties,
id: { type: 'number' }
}
} as const, fixtureAjv)
export const userResultSchema = schema(
{
$id: 'UserResult',
type: 'object',
additionalProperties: false,
required: ['id', ...userSchema.required],
properties: {
...userSchema.properties,
id: { type: 'number' }
}
} as const,
fixtureAjv
)

export type User = Infer<typeof userSchema>
export type UserResult = Infer<typeof userResultSchema> & { name: string }
Expand Down Expand Up @@ -92,17 +95,20 @@ export const messageSchema = schema({
}
} as const)

export const messageResultSchema = schema({
$id: 'MessageResult',
type: 'object',
additionalProperties: false,
required: ['id', ...messageSchema.required],
properties: {
...messageSchema.properties,
id: { type: 'number' },
user: { $ref: 'UserResult' }
}
} as const, fixtureAjv)
export const messageResultSchema = schema(
{
$id: 'MessageResult',
type: 'object',
additionalProperties: false,
required: ['id', ...messageSchema.required],
properties: {
...messageSchema.properties,
id: { type: 'number' },
user: { $ref: 'UserResult' }
}
} as const,
fixtureAjv
)

export type Message = Infer<typeof messageSchema>
export type MessageResult = Combine<
Expand Down
52 changes: 29 additions & 23 deletions packages/schema/test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,30 +186,36 @@ describe('@feathersjs/schema/schema', () => {
})

it('with references', async () => {
const userSchema = schema({
$id: 'ref-user',
type: 'object',
required: ['email'],
additionalProperties: false,
properties: {
email: { type: 'string' },
age: { type: 'number' }
}
} as const, customAjv)
const messageSchema = schema({
$id: 'ref-message',
type: 'object',
required: ['text', 'user'],
additionalProperties: false,
properties: {
text: {
type: 'string'
},
user: {
$ref: 'ref-user'
const userSchema = schema(
{
$id: 'ref-user',
type: 'object',
required: ['email'],
additionalProperties: false,
properties: {
email: { type: 'string' },
age: { type: 'number' }
}
}
} as const, customAjv)
} as const,
customAjv
)
const messageSchema = schema(
{
$id: 'ref-message',
type: 'object',
required: ['text', 'user'],
additionalProperties: false,
properties: {
text: {
type: 'string'
},
user: {
$ref: 'ref-user'
}
}
} as const,
customAjv
)

type User = Infer<typeof userSchema>
type Message = Infer<typeof messageSchema> & {
Expand Down
2 changes: 2 additions & 0 deletions packages/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
},
"scripts": {
"prepublish": "npm run compile",
"pack": "echo \"not necessary\"",
"test": "echo \"not necessary\"",
"compile": "shx rm -rf lib/ && tsc"
},
"directories": {
Expand Down

0 comments on commit 21d6aaa

Please sign in to comment.