From c813c01a9747705d961c7e96986525672a9f5b93 Mon Sep 17 00:00:00 2001 From: Ihor Date: Thu, 2 Jan 2025 12:50:10 +0100 Subject: [PATCH] test: fix gene-tools tests (#46) --- .../service-generator/index.spec.ts | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/packages/gene-tools/src/generators/service-generator/index.spec.ts b/packages/gene-tools/src/generators/service-generator/index.spec.ts index 9725222..5ed1822 100644 --- a/packages/gene-tools/src/generators/service-generator/index.spec.ts +++ b/packages/gene-tools/src/generators/service-generator/index.spec.ts @@ -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 () => { @@ -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 () => {