Skip to content

Commit

Permalink
chore: verify that @default(value) works on mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
p5quared committed Oct 1, 2024
1 parent 8f6f81b commit d4ee97e
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ export const testGraphQLAPI = (
engine: ImportedRDSType,
): void => {
describe(`${testBlockDescription} - ${engine}`, () => {
const defaultTodoDescription = 'Lorem Ipsum yadda yadda';
const amplifyGraphqlSchema = `
type Todo @model @refersTo(name: "${getRDSTableNamePrefix()}todos") {
id: ID! @primaryKey
description: String!
description: String! @default("${defaultTodoDescription}")
}
type Student @model @refersTo(name: "${getRDSTableNamePrefix()}students") {
studentId: Int! @primaryKey(sortKeyFields: ["classId"])
Expand Down Expand Up @@ -72,6 +73,32 @@ export const testGraphQLAPI = (
deleteProjectDir(projRoot);
});

test(`check default value on todo table - ${engine}`, async () => {
// Create Todo Mutation
const createTodo1 = await toDoTableCRUDLHelper.create({});

expect(createTodo1).toBeDefined();
expect(createTodo1.id).toBeDefined();
expect(createTodo1.description).toEqual(defaultTodoDescription);

// Get Todo Query
const getTodo1 = await toDoTableCRUDLHelper.getById(createTodo1.id);
expect(getTodo1.id).toEqual(createTodo1.id);
expect(getTodo1.description).toEqual(createTodo1.description);

// Update Todo Mutation
const updateTodo1 = await toDoTableCRUDLHelper.update({ id: createTodo1.id, description: 'Updated Todo #1' });

expect(updateTodo1.id).toEqual(createTodo1.id);
expect(updateTodo1.description).toEqual('Updated Todo #1');

// Get Todo Query after update
const getUpdatedTodo1 = await toDoTableCRUDLHelper.getById(createTodo1.id);

expect(getUpdatedTodo1.id).toEqual(createTodo1.id);
expect(getUpdatedTodo1.description).toEqual('Updated Todo #1');
});

test(`check CRUDL on todo table with default primary key - ${engine}`, async () => {
// Create Todo Mutation
const createTodo1 = await toDoTableCRUDLHelper.create({ description: 'Todo #1' });
Expand Down

0 comments on commit d4ee97e

Please sign in to comment.