-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from codex-team/feat/update-add-tool-response
feat: updated add user tool response
- Loading branch information
Showing
10 changed files
with
133 additions
and
20 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
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
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
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
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 |
---|---|---|
|
@@ -40,4 +40,56 @@ describe('User API', () => { | |
expect(body.message).toBe('You must be authenticated to access this resource'); | ||
}); | ||
}); | ||
}); | ||
describe('POST /user/editor-tools', () => { | ||
test('Returns added tool with status code 200 if tool added to user extensions', async () => { | ||
await global.db.truncateTables(); | ||
|
||
/** | ||
* Create user and get accessToken | ||
*/ | ||
const createdUser = await global.db.insertUser({ | ||
email: '[email protected]', | ||
name: 'Test', | ||
}); | ||
const accessToken = global.auth(createdUser.id); | ||
|
||
const addedToolId = await global.db.insertEditorTool({ | ||
name: 'code', | ||
title: 'Code Tool', | ||
exportName: 'Code', | ||
isDefault: false, | ||
source: { | ||
cdn: 'https://cdn.jsdelivr.net/npm/@editorjs/code@latest', | ||
}, | ||
}); | ||
|
||
const response = await global.api?.fakeRequest({ | ||
method: 'POST', | ||
headers: { | ||
authorization: `Bearer ${accessToken}`, | ||
}, | ||
url: '/user/editor-tools', | ||
body: { | ||
'toolId': addedToolId, | ||
}, | ||
}); | ||
|
||
expect(response?.statusCode).toBe(200); | ||
|
||
const body = response?.json(); | ||
|
||
expect(body).toStrictEqual({ | ||
addedTool :{ | ||
id: addedToolId, | ||
name: 'code', | ||
title: 'Code Tool', | ||
exportName: 'Code', | ||
isDefault: false, | ||
source: { | ||
cdn: 'https://cdn.jsdelivr.net/npm/@editorjs/code@latest', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
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
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
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
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
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