Skip to content

Commit

Permalink
test: fix gene-tools tests (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
kopach authored Jan 2, 2025
1 parent 29603d7 commit c813c01
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions packages/gene-tools/src/generators/service-generator/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,13 @@ describe('Service generator', () => {
.read('libs/question/services/question-service/src/index.ts')
?.toString();

expect(indexFile).toContain(
"export { useQuestions, queryQuestions, getQuestionsQueryKey } from './lib/useQuestions';"
);
expect(indexFile).toContain(
"export { useQuestion, queryQuestion, getQuestionQueryKey } from './lib/useQuestion';"
);
expect(indexFile).toContain(
"export { useCreateQuestion } from './lib/useCreateQuestion';"
);
expect(indexFile).toContain(
"export { useDeleteQuestion } from './lib/useDeleteQuestion';"
);
expect(indexFile).toContain(
"export { useUpdateQuestion } from './lib/useUpdateQuestion';"
);
expect(indexFile).toMatchInlineSnapshot(`
"export { useQuestion, queryQuestion, getQuestionQueryKey } from './lib/useQuestion';
export { useQuestions, queryQuestions, getQuestionsQueryKey } from './lib/useQuestions';
export { useCreateQuestion } from './lib/useCreateQuestion';
export { useUpdateQuestion } from './lib/useUpdateQuestion';
export { useDeleteQuestion } from './lib/useDeleteQuestion';"
`);
});

it('should generate react-query service with only selected crud operations', async () => {
Expand Down Expand Up @@ -213,21 +205,10 @@ describe('Service generator', () => {
.read('libs/question/services/question-service/src/index.ts')
?.toString();

expect(indexFile).toContain(
"export { useQuestions, queryQuestions, getQuestionsQueryKey } from './lib/useQuestions';"
);
expect(indexFile).not.toContain(
"export { useQuestion, queryQuestion, getQuestionQueryKey } from './lib/useQuestion';"
);
expect(indexFile).not.toContain(
"export { useCreateQuestion } from './lib/useCreateQuestion';"
);
expect(indexFile).not.toContain(
"export { useDeleteQuestion } from './lib/useDeleteQuestion';"
);
expect(indexFile).toContain(
"export { useUpdateQuestion } from './lib/useUpdateQuestion';"
);
expect(indexFile).toMatchInlineSnapshot(`
"export { useQuestions, queryQuestions, getQuestionsQueryKey } from './lib/useQuestions';
export { useUpdateQuestion } from './lib/useUpdateQuestion';"
`);
});

it('should camelize query name if service name includes "-"', async () => {
Expand Down

0 comments on commit c813c01

Please sign in to comment.