Skip to content

Commit 2c3a0a6

Browse files
committed
Add many to many tests to visitors
1 parent f6bda5b commit 2c3a0a6

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-java-visitor.test.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`AppSyncModelVisitor Many To Many V2 Tests Should generate the intermediate model successfully 1`] = `
4+
"package com.amplifyframework.datastore.generated.model;
5+
6+
7+
import java.util.List;
8+
import java.util.UUID;
9+
import java.util.Objects;
10+
11+
import androidx.core.util.ObjectsCompat;
12+
13+
import com.amplifyframework.core.model.Model;
14+
import com.amplifyframework.core.model.annotations.Index;
15+
import com.amplifyframework.core.model.annotations.ModelConfig;
16+
import com.amplifyframework.core.model.annotations.ModelField;
17+
import com.amplifyframework.core.model.query.predicate.QueryField;
18+
19+
import static com.amplifyframework.core.model.query.predicate.QueryField.field;
20+
"
21+
`;
22+
323
exports[`AppSyncModelVisitor Model with Auth should generate class with custom claims 1`] = `
424
"package com.amplifyframework.datastore.generated.model;
525

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-swift-visitor.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`AppSyncSwiftVisitor Many To Many V2 Tests Should generate the intermediate model successfully 1`] = `
4+
"// swiftlint:disable all
5+
import Amplify
6+
import Foundation
7+
"
8+
`;
9+
310
exports[`AppSyncSwiftVisitor Should handle nullability of lists appropriately 1`] = `
411
"// swiftlint:disable all
512
import Amplify

packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-java-visitor.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,4 +582,25 @@ describe('AppSyncModelVisitor', () => {
582582
expect(generatedCode).toMatchSnapshot();
583583
});
584584
});
585+
586+
describe('Many To Many V2 Tests', () => {
587+
it('Should generate the intermediate model successfully', () => {
588+
const schema = /* GraphQL */ `
589+
type Post @model {
590+
id: ID!
591+
title: String!
592+
content: String
593+
tags: [Tag] @manyToMany(relationName: "PostTags")
594+
}
595+
596+
type Tag @model {
597+
id: ID!
598+
label: String!
599+
posts: [Post] @manyToMany(relationName: "PostTags")
600+
}
601+
`;
602+
const generatedCode = getVisitorPipelinedTransformer(schema, CodeGenGenerateEnum.code).generate();
603+
expect(generatedCode).toMatchSnapshot();
604+
});
605+
});
585606
});

packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-swift-visitor.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,4 +2259,25 @@ describe('AppSyncSwiftVisitor', () => {
22592259
`);
22602260
});
22612261
});
2262+
2263+
describe('Many To Many V2 Tests', () => {
2264+
it('Should generate the intermediate model successfully', () => {
2265+
const schema = /* GraphQL */ `
2266+
type Post @model {
2267+
id: ID!
2268+
title: String!
2269+
content: String
2270+
tags: [Tag] @manyToMany(relationName: "PostTags")
2271+
}
2272+
2273+
type Tag @model {
2274+
id: ID!
2275+
label: String!
2276+
posts: [Post] @manyToMany(relationName: "PostTags")
2277+
}
2278+
`;
2279+
const generatedCode = getVisitorPipelinedTransformer(schema, CodeGenGenerateEnum.code).generate();
2280+
expect(generatedCode).toMatchSnapshot();
2281+
});
2282+
});
22622283
});

0 commit comments

Comments
 (0)