From 6615700eb35b8419718d24e293deb07b65357a73 Mon Sep 17 00:00:00 2001 From: Chris Kalmar Date: Sat, 30 Jan 2021 15:42:26 +0100 Subject: [PATCH] update test models due to api changes --- test/models/Board.ts | 4 ++-- test/models/BoardMember.ts | 4 ++-- test/models/Profile.ts | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/models/Board.ts b/test/models/Board.ts index 74896b18..fc738033 100644 --- a/test/models/Board.ts +++ b/test/models/Board.ts @@ -60,7 +60,7 @@ export const Board = new Entity({ name: 'build', description: 'build a new board', type: MUTATION_TYPE_CREATE, - attributes: ['name', 'isPrivate', 'vip'], + attributes: ['name', 'isPrivate', 'vip', 'metaData', 'mods'], }), new Mutation({ name: 'update', @@ -89,7 +89,7 @@ export const Board = new Entity({ type: Profile, description: 'Owner of the board', required: true, - defaultValue(payload, mutation, entity, { userId }) { + defaultValue({ context: { userId } }) { return userId; }, }, diff --git a/test/models/BoardMember.ts b/test/models/BoardMember.ts index 97be5b2b..3c7f988b 100644 --- a/test/models/BoardMember.ts +++ b/test/models/BoardMember.ts @@ -129,7 +129,7 @@ export const BoardMember = new Entity({ type: Profile, description: 'The user that invites to a board', required: true, - defaultValue(payload, mutation, entity, { userId }) { + defaultValue({ context: { userId } }) { return userId; }, }, @@ -138,7 +138,7 @@ export const BoardMember = new Entity({ type: Profile, description: 'The user that participates in the board', required: true, - defaultValue(payload, mutation, entity, { userId }) { + defaultValue({ operation: mutation, context: { userId } }) { if (mutation.name === 'join') { return userId; } diff --git a/test/models/Profile.ts b/test/models/Profile.ts index e4f961b7..24915675 100644 --- a/test/models/Profile.ts +++ b/test/models/Profile.ts @@ -39,14 +39,20 @@ export const Profile = new Entity({ description: 'sign up a new user', type: MUTATION_TYPE_CREATE, attributes: ['username', 'password', 'firstname', 'lastname'], - preProcessor(entity, id, source, input) { - input.username = input.username.toLowerCase(); - // do not copy this very unsecure method of password hashing (only for testing purposes) - input.password = crypto - .createHash('sha256') - .update(input.password, 'utf8') - .digest('hex'); - return input; + preProcessor({ input }) { + /** + * ATTENTION! + * DO NOT COPY this very unsecure method of password hashing! + * This is ONLY for testing purposes! + */ + return { + ...input, + username: (input.username).toLowerCase(), + password: crypto + .createHash('sha256') + .update(input.password, 'utf8') + .digest('hex'), + }; }, }), ],