-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): Add getCurrentUser mock and update tests
Added `getCurrentUser` mock to support testing and adjusted test cases accordingly. Cleanup and reorganization of mock data and improved structure for consistency. Minor import adjustments for better readability.
- Loading branch information
Showing
2 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { | ||
ChallengeDocument, | ||
GetCurrentUserDocument, | ||
SignUpDocument, | ||
VerifyDocument, | ||
} from '~/generated/graphql'; | ||
|
@@ -8,6 +9,7 @@ export const queries = { | |
challenge: ChallengeDocument, | ||
verify: VerifyDocument, | ||
signup: SignUpDocument, | ||
getCurrentUser: GetCurrentUserDocument, | ||
}; | ||
|
||
export const email = '[email protected]'; | ||
|
@@ -22,6 +24,7 @@ export const variables = { | |
}, | ||
verify: { loginToken: token }, | ||
signup: {}, | ||
getCurrentUser: {}, | ||
}; | ||
|
||
export const results = { | ||
|
@@ -32,7 +35,14 @@ export const results = { | |
}, | ||
}, | ||
verify: { | ||
user: { | ||
tokens: { | ||
accessToken: { token, expiresAt: 'expiresAt' }, | ||
refreshToken: { token, expiresAt: 'expiresAt' }, | ||
}, | ||
}, | ||
signUp: { loginToken: { token, expiresAt: 'expiresAt' } }, | ||
getCurrentUser: { | ||
currentUser: { | ||
id: 'id', | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
|
@@ -65,13 +75,7 @@ export const results = { | |
}, | ||
}, | ||
}, | ||
tokens: { | ||
accessToken: { token, expiresAt: 'expiresAt' }, | ||
refreshToken: { token, expiresAt: 'expiresAt' }, | ||
}, | ||
signup: {}, | ||
}, | ||
signUp: { loginToken: { token, expiresAt: 'expiresAt' } }, | ||
}; | ||
|
||
export const mocks = [ | ||
|
@@ -108,4 +112,13 @@ export const mocks = [ | |
}, | ||
})), | ||
}, | ||
{ | ||
request: { | ||
query: queries.getCurrentUser, | ||
variables: variables.getCurrentUser, | ||
}, | ||
result: jest.fn(() => ({ | ||
data: results.getCurrentUser, | ||
})), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters