Skip to content

Commit

Permalink
update test models due to api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Jan 30, 2021
1 parent 0ebcbb3 commit 6615700
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/models/Board.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/models/BoardMember.ts
Expand Up @@ -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;
},
},
Expand All @@ -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;
}
Expand Down
22 changes: 14 additions & 8 deletions test/models/Profile.ts
Expand Up @@ -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: (<string>input.username).toLowerCase(),
password: crypto
.createHash('sha256')
.update(<string>input.password, 'utf8')
.digest('hex'),
};
},
}),
],
Expand Down

0 comments on commit 6615700

Please sign in to comment.