Skip to content

Commit

Permalink
test: add additional assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Oct 4, 2024
1 parent 6ecafeb commit 3849ed1
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ `
Expand All @@ -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 */ `
Expand All @@ -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', () => {
Expand All @@ -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();
});
});
});

0 comments on commit 3849ed1

Please sign in to comment.