Created
February 5, 2020 17:23
-
-
Save gcmatheusj/775247d429ac3eeeaffc71ce73d950aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| it('should be able to update account', async () => { | |
| const queryAccountSettings = ` | |
| query ($subdomain: String!) { | |
| getAccountSettingsBySubDomain(subdomain: $subdomain) { | |
| id | |
| } | |
| } | |
| `; | |
| const variablesAccountSettings = { | |
| subdomain: 'learn49' | |
| }; | |
| const accountSettings = await request(app.getHttpServer()) | |
| .post('/graphql') | |
| .send({ | |
| query: queryAccountSettings, | |
| variables: variablesAccountSettings | |
| }); | |
| const accountSettingsParsed = JSON.parse(accountSettings.text); | |
| const accountId = | |
| accountSettingsParsed.data.getAccountSettingsBySubDomain.id; | |
| const queryAuth = ` | |
| mutation($accountId: String!, $UserInput: UserInput!) { | |
| auth(accountId: $accountId, userInput: $UserInput) { | |
| token | |
| } | |
| } | |
| `; | |
| const variablesAuth = { | |
| accountId, | |
| UserInput: { | |
| email: 'user@learn49.com', | |
| passwd: '12345678' | |
| } | |
| }; | |
| const auth = await request(app.getHttpServer()) | |
| .post('/graphql') | |
| .send({ | |
| query: queryAuth, | |
| variables: variablesAuth | |
| }); | |
| const authParsed = JSON.parse(auth.text); | |
| const token = authParsed.data.auth.token; | |
| const query = ` | |
| mutation ($accountId: String!, $UpdateAccountInput: UpdateAccountInput!) { | |
| updateAccount(accountId: $accountId, updateAccountInput: $UpdateAccountInput){ | |
| id | |
| } | |
| } | |
| `; | |
| const variables = { | |
| accountId, | |
| UpdateAccountInput: { | |
| domain: 'learn49.com', | |
| friendlyName: 'Learn49 LMS', | |
| description: 'The Best LMS In The World' | |
| } | |
| }; | |
| return request(app.getHttpServer()) | |
| .post('/graphql') | |
| .set('Authorization', `Bearer ${token}`) | |
| .send({ query, variables }) | |
| .expect(200, { | |
| data: { | |
| updateAccount: { | |
| id: accountId | |
| } | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment