From 3849ed1360ecae5d62238abc8275d6e106c8afe6 Mon Sep 17 00:00:00 2001 From: Dane Pilcher Date: Fri, 4 Oct 2024 10:26:06 -0600 Subject: [PATCH] test: add additional assertions --- .../visitors/appsync-swift-visitor.test.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts b/packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts index ebddff3f..8ed5de56 100644 --- a/packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts +++ b/packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts @@ -3195,7 +3195,10 @@ describe('AppSyncSwiftVisitor', () => { context: String } `; - expect(getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate()).toMatchSnapshot(); + const result = getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate(); + expect(result).toContain('myCustomTypes = try values.decode([MyCustomType?].self, forKey: .myCustomTypes)'); + expect(result).toContain('scalarArray = try values.decode([String?].self, forKey: .scalarArray)'); + expect(result).toMatchSnapshot(); }); test('decode optional list with required elements', () => { const schema = /* GraphQL */ ` @@ -3219,7 +3222,10 @@ describe('AppSyncSwiftVisitor', () => { context: String } `; - expect(getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate()).toMatchSnapshot(); + const result = getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate(); + expect(result).toContain('myCustomTypes = try? values.decode([MyCustomType].self, forKey: .myCustomTypes)'); + expect(result).toContain('scalarArray = try? values.decode([String].self, forKey: .scalarArray)'); + expect(result).toMatchSnapshot(); }); test('decode required list with required elements', () => { const schema = /* GraphQL */ ` @@ -3243,7 +3249,10 @@ describe('AppSyncSwiftVisitor', () => { context: String } `; - expect(getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate()).toMatchSnapshot(); + const result = getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate(); + expect(result).toContain('myCustomTypes = try values.decode([MyCustomType].self, forKey: .myCustomTypes)'); + expect(result).toContain('scalarArray = try values.decode([String].self, forKey: .scalarArray)'); + expect(result).toMatchSnapshot(); }); test('decode optional list with nullable elements', () => { @@ -3268,7 +3277,10 @@ describe('AppSyncSwiftVisitor', () => { context: String } `; - expect(getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate()).toMatchSnapshot(); + const result = getVisitorPipelinedTransformer(schema, 'MyModel', CodeGenGenerateEnum.code, {}).generate(); + expect(result).toContain('myCustomTypes = try? values.decode([MyCustomType?].self, forKey: .myCustomTypes)'); + expect(result).toContain('scalarArray = try? values.decode([String?].self, forKey: .scalarArray)'); + expect(result).toMatchSnapshot(); }); }); });