Skip to content

Commit

Permalink
Update swift tests improved pluralization
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvberg committed Sep 28, 2022
1 parent 65a1457 commit 95bf566
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,19 +967,143 @@ exports[`AppSyncSwiftVisitor Use Improved Pluralization Should work with potenti
"// swiftlint:disable all
import Amplify
import Foundation
"
public struct Wish: Model {
public let id: String
public var date: Temporal.DateTime
public var idUser: String
public var ev: String
public var deprecated: Bool
public var owner: String?
public var createdAt: Temporal.DateTime?
public var updatedAt: Temporal.DateTime?
public init(id: String = UUID().uuidString,
date: Temporal.DateTime,
idUser: String,
ev: String,
deprecated: Bool,
owner: String? = nil) {
self.init(id: id,
date: date,
idUser: idUser,
ev: ev,
deprecated: deprecated,
owner: owner,
createdAt: nil,
updatedAt: nil)
}
internal init(id: String = UUID().uuidString,
date: Temporal.DateTime,
idUser: String,
ev: String,
deprecated: Bool,
owner: String? = nil,
createdAt: Temporal.DateTime? = nil,
updatedAt: Temporal.DateTime? = nil) {
self.id = id
self.date = date
self.idUser = idUser
self.ev = ev
self.deprecated = deprecated
self.owner = owner
self.createdAt = createdAt
self.updatedAt = updatedAt
}
}"
`;
exports[`AppSyncSwiftVisitor Use Improved Pluralization Should work with potentially pluralized collision 2`] = `
"// swiftlint:disable all
import Amplify
import Foundation
"
extension Wish {
// MARK: - CodingKeys
public enum CodingKeys: String, ModelKey {
case id
case date
case idUser
case ev
case deprecated
case owner
case createdAt
case updatedAt
}
public static let keys = CodingKeys.self
// MARK: - ModelSchema
public static let schema = defineSchema { model in
let wish = Wish.keys
model.listPluralName = \\"Wishes\\"
model.syncPluralName = \\"Wishes\\"
model.attributes(
.index(fields: [\\"idUser\\"], name: \\"byUsers\\")
)
model.fields(
.id(),
.field(wish.date, is: .required, ofType: .dateTime),
.field(wish.idUser, is: .required, ofType: .string),
.field(wish.ev, is: .required, ofType: .string),
.field(wish.deprecated, is: .required, ofType: .bool),
.field(wish.owner, is: .optional, ofType: .string),
.field(wish.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime),
.field(wish.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime)
)
}
}"
`;
exports[`AppSyncSwiftVisitor Use Improved Pluralization Should work with potentially pluralized collision 3`] = `
"// swiftlint:disable all
import Amplify
import Foundation
"
public struct Wishes: Model {
public let id: String
public var date: Temporal.DateTime
public var idUser: String
public var ev: String
public var deprecated: Bool
public var owner: String?
public var createdAt: Temporal.DateTime?
public var updatedAt: Temporal.DateTime?
public init(id: String = UUID().uuidString,
date: Temporal.DateTime,
idUser: String,
ev: String,
deprecated: Bool,
owner: String? = nil) {
self.init(id: id,
date: date,
idUser: idUser,
ev: ev,
deprecated: deprecated,
owner: owner,
createdAt: nil,
updatedAt: nil)
}
internal init(id: String = UUID().uuidString,
date: Temporal.DateTime,
idUser: String,
ev: String,
deprecated: Bool,
owner: String? = nil,
createdAt: Temporal.DateTime? = nil,
updatedAt: Temporal.DateTime? = nil) {
self.id = id
self.date = date
self.idUser = idUser
self.ev = ev
self.deprecated = deprecated
self.owner = owner
self.createdAt = createdAt
self.updatedAt = updatedAt
}
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ describe('AppSyncSwiftVisitor', () => {
it('Should work with potentially pluralized collision', () => {
const visitor = getVisitor(
wishSchema,
'ListContainer',
'Wish',
CodeGenGenerateEnum.code,
{
improvePluralization: true,
Expand All @@ -2332,7 +2332,7 @@ describe('AppSyncSwiftVisitor', () => {

const metadataVisitor = getVisitor(
wishSchema,
'ListContainer',
'Wish',
CodeGenGenerateEnum.metadata,
{
improvePluralization: true,
Expand All @@ -2343,7 +2343,7 @@ describe('AppSyncSwiftVisitor', () => {

const customTypeVisitor = getVisitor(
wishSchema,
'CustomType',
'Wishes',
CodeGenGenerateEnum.code,
{
improvePluralization: true,
Expand Down

0 comments on commit 95bf566

Please sign in to comment.