Skip to content

Commit

Permalink
removed new datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham4443 committed Jan 29, 2021
1 parent 852a941 commit 4941b7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 140 deletions.
26 changes: 1 addition & 25 deletions src/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dotprop from "dot-prop-immutable";

const lorem = new LoremIpsum();

const primitiveTypes = ["ID", "String", "Float", "Integer", "Boolean", "Date", "Time", "DateTime", "JSON", "SmallInteger", "BigInteger", "Decimal", "Char", "Varchar", "DateTimeWithZone"]
const primitiveTypes = ["ID", "String", "Float", "Integer", "Boolean", "Date", "Time", "DateTime", "JSON"]
const getDefType = (type, isArray, required) => {
isArray = isArray ? true : type.kind === "ListType";
required = required ? true : type.kind === "NonNullType";
Expand Down Expand Up @@ -183,18 +183,6 @@ const generateRandomValue = (type) => {
return "2017-11-13T03:15:45.108Z"
case "JSON":
return { foo: "bar" }
case "SmallInteger":
return 12
case "BigInteger":
return 4323
case "Decimal":
return 23.84
case "Char":
return "F919mV2W1ifQy9wlNyYnoOoqUM1"
case "Varchar":
return "7mr8VjGnCCerZUyzC9YDCn8Oxku"
case "DateTimeWithZone":
return "2021-11-22T03:15:45.108"
default:
return type
}
Expand All @@ -218,18 +206,6 @@ const generateRandomValue = (type) => {
return new Date().toISOString()
case "JSON":
return { foo: "bar" }
case "SmallInteger":
return Math.ceil(Math.random() * 100)
case "BigInteger":
return Math.ceil(Math.random() * 10000)
case "Decimal":
return Number((Math.random() * 100).toFixed(2))
case "Char":
return generateId(6)
case "Varchar":
return generateId(6)
case "DateTimeWithZone":
return new Date().toISOString()
default:
return type
}
Expand Down
116 changes: 1 addition & 115 deletions src/graphql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ describe("generateSchemaAST method", () => {
f19: String @link(table: mytype4, from: id, to: somefield, field: goodfield)
f20: mytype5 @link(table: mytype5, from: id, to: nicefield)
f21: [mytype6]! @link(table: mytype6, from: id, to: goodfield)
f22: SmallInteger
f23: BigInteger
f24: Decimal
f25: Char
f26: Varchar
f27: DateTimeWithZone
}
`
const expectedSchemaAST = {
Expand Down Expand Up @@ -330,84 +324,6 @@ describe("generateSchemaAST method", () => {
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: true
},
{
name: "f22",
type: "SmallInteger",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
},
{
name: "f23",
type: "BigInteger",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
},
{
name: "f24",
type: "Decimal",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
},
{
name: "f25",
type: "Char",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
},
{
name: "f26",
type: "Varchar",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
},
{
name: "f27",
type: "DateTimeWithZone",
isRequired: false,
isPrimary: false,
hasUniqueConstraint: false,
hasForeignConstraint: false,
isLink: false,
isArray: false,
hasCreatedAtDirective: false,
hasUpdatedAtDirective: false,
hasNestedFields: false
}
]
}
Expand Down Expand Up @@ -549,30 +465,6 @@ describe("generateRandomFieldValues method", () => {
{
name: "k9",
type: "JSON"
},
{
name: "k10",
type: "SmallInteger"
},
{
name: "k11",
type: "BigInteger"
},
{
name: "k12",
type: "Decimal"
},
{
name: "k13",
type: "Char"
},
{
name: "k14",
type: "Varchar"
},
{
name: "k15",
type: "DateTimeWithZone"
}
]
const result = {
Expand All @@ -586,13 +478,7 @@ describe("generateRandomFieldValues method", () => {
k8: "2017-11-13T03:15:45.108Z",
k9: {
foo: "bar"
},
k10: 12,
k11: 4323,
k12: 23.84,
k13: "F919mV2W1ifQy9wlNyYnoOoqUM1",
k14: "7mr8VjGnCCerZUyzC9YDCn8Oxku",
k15: "2021-11-22T03:15:45.108"
}
}
expect(generateRandomFieldValues(fields)).toEqual(result)
})
Expand Down

0 comments on commit 4941b7b

Please sign in to comment.