2023-05-16 05:34:22 +00:00
|
|
|
/// <reference types="@types/jest" />
|
|
|
|
|
|
|
|
|
|
import { loadSchema } from '@zenstackhq/testtools';
|
|
|
|
|
|
|
|
|
|
describe('Tanstack Query Plugin Tests', () => {
|
|
|
|
|
let origDir: string;
|
|
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
|
origDir = process.cwd();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
process.chdir(origDir);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const sharedModel = `
|
|
|
|
|
model User {
|
|
|
|
|
id String @id
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
email String @unique
|
2023-08-23 08:16:24 +00:00
|
|
|
role role @default(USER)
|
|
|
|
|
posts post_Item[]
|
2023-05-16 05:34:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-08-23 08:16:24 +00:00
|
|
|
enum role {
|
|
|
|
|
USER
|
|
|
|
|
ADMIN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model post_Item {
|
2023-05-16 05:34:22 +00:00
|
|
|
id String @id
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
title String
|
|
|
|
|
author User? @relation(fields: [authorId], references: [id])
|
|
|
|
|
authorId String?
|
|
|
|
|
published Boolean @default(false)
|
|
|
|
|
viewCount Int @default(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Foo {
|
|
|
|
|
id String @id
|
|
|
|
|
@@ignore
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2023-07-17 10:29:22 +00:00
|
|
|
it('react-query run plugin', async () => {
|
2023-05-16 05:34:22 +00:00
|
|
|
await loadSchema(
|
|
|
|
|
`
|
|
|
|
|
plugin tanstack {
|
|
|
|
|
provider = '${process.cwd()}/dist'
|
|
|
|
|
output = '$projectRoot/hooks'
|
|
|
|
|
target = 'react'
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 08:05:39 +00:00
|
|
|
${sharedModel}
|
|
|
|
|
`,
|
2023-07-19 04:59:44 +00:00
|
|
|
{
|
2023-08-23 08:16:24 +00:00
|
|
|
provider: 'postgresql',
|
2023-07-19 04:59:44 +00:00
|
|
|
pushDb: false,
|
|
|
|
|
extraDependencies: [
|
|
|
|
|
`${origDir}/dist`,
|
|
|
|
|
'react@18.2.0',
|
|
|
|
|
'@types/react@18.2.0',
|
|
|
|
|
'@tanstack/react-query@4.29.7',
|
|
|
|
|
],
|
|
|
|
|
compile: true,
|
|
|
|
|
}
|
2023-05-18 08:05:39 +00:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-13 23:55:42 +00:00
|
|
|
it('vue-query run plugin', async () => {
|
|
|
|
|
await loadSchema(
|
|
|
|
|
`
|
|
|
|
|
plugin tanstack {
|
|
|
|
|
provider = '${process.cwd()}/dist'
|
|
|
|
|
output = '$projectRoot/hooks'
|
|
|
|
|
target = 'vue'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
${sharedModel}
|
|
|
|
|
`,
|
|
|
|
|
{
|
|
|
|
|
provider: 'postgresql',
|
|
|
|
|
pushDb: false,
|
|
|
|
|
extraDependencies: [`${origDir}/dist`, 'vue@^3.3.4', '@tanstack/vue-query@4.37.0'],
|
|
|
|
|
compile: true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2023-07-17 10:29:22 +00:00
|
|
|
it('svelte-query run plugin', async () => {
|
2023-05-16 05:34:22 +00:00
|
|
|
await loadSchema(
|
|
|
|
|
`
|
|
|
|
|
plugin tanstack {
|
|
|
|
|
provider = '${process.cwd()}/dist'
|
|
|
|
|
output = '$projectRoot/hooks'
|
|
|
|
|
target = 'svelte'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
${sharedModel}
|
|
|
|
|
`,
|
2023-07-19 04:59:44 +00:00
|
|
|
{
|
2023-08-23 08:16:24 +00:00
|
|
|
provider: 'postgresql',
|
2023-07-19 04:59:44 +00:00
|
|
|
pushDb: false,
|
|
|
|
|
extraDependencies: [`${origDir}/dist`, 'svelte@^3.0.0', '@tanstack/svelte-query@4.29.7'],
|
|
|
|
|
compile: true,
|
|
|
|
|
}
|
2023-05-16 05:34:22 +00:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|