-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API errors expects new error format #93
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fa4a6fa
API errors expects new error format
3dd3659
throwApiError usage, utils use isSpecifiedError, cleanup unused lang …
9338a88
Update apiError tests
5ea3e61
Sandbox tests, type updates
843a10c
Specified hubspot auth error update
dd70251
Revert specified hubspot auth
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding these! It's a huge help 🙏 |
||
createSandbox as __createSandbox, | ||
getSandboxUsageLimits as __getSandboxUsageLimits, | ||
} from '../../api/sandboxHubs'; | ||
import { fetchTypes as __fetchTypes } from '../../api/sandboxSync'; | ||
import { Sandbox, Usage } from '../../types/Sandbox'; | ||
import { | ||
createSandbox as createSandboxAction, | ||
deleteSandbox as deleteSandboxAction, | ||
getSandboxUsageLimits as getSandboxUsageLimitsAction, | ||
fetchTypes as fetchTypesAction, | ||
} from '../sandboxes'; | ||
|
||
jest.mock('../../api/sandboxHubs'); | ||
jest.mock('../../api/sandboxSync'); | ||
|
||
const createSandbox = __createSandbox as jest.MockedFunction< | ||
typeof __createSandbox | ||
>; | ||
const getSandboxUsageLimits = __getSandboxUsageLimits as jest.MockedFunction< | ||
typeof __getSandboxUsageLimits | ||
>; | ||
const fetchTypes = __fetchTypes as jest.MockedFunction<typeof __fetchTypes>; | ||
|
||
const sandboxName = 'Mock Standard Sandbox'; | ||
const sandboxHubId = 987654; | ||
const accountId = 123456; | ||
|
||
const MOCK_SANDBOX_ACCOUNT: Sandbox = { | ||
sandboxHubId: sandboxHubId, | ||
parentHubId: accountId, | ||
createdAt: '2023-01-27T22:24:27.279Z', | ||
updatedAt: '2023-02-09T19:36:25.123Z', | ||
archivedAt: null, | ||
type: 'developer', | ||
archived: false, | ||
name: sandboxName, | ||
domain: 'mockStandardSandbox.com', | ||
createdByUser: { | ||
userId: 111, | ||
firstName: 'Test', | ||
lastName: 'User', | ||
}, | ||
}; | ||
|
||
const MOCK_USAGE_DATA: Usage = { | ||
STANDARD: { | ||
used: 0, | ||
available: 1, | ||
limit: 1, | ||
}, | ||
DEVELOPER: { | ||
used: 0, | ||
available: 1, | ||
limit: 1, | ||
}, | ||
}; | ||
|
||
const MOCK_TYPES = [ | ||
{ | ||
name: 'object-schemas', | ||
dependsOn: [], | ||
pushToProductionEnabled: true, | ||
isBeta: false, | ||
diffEnabled: true, | ||
groupType: 'object-schemas', | ||
syncMandatory: true, | ||
}, | ||
]; | ||
|
||
describe('lib/sandboxes', () => { | ||
it('createSandbox()', async () => { | ||
const personalAccessKey = 'pak-test-123'; | ||
createSandbox.mockResolvedValue({ | ||
sandbox: MOCK_SANDBOX_ACCOUNT, | ||
personalAccessKey, | ||
}); | ||
|
||
const response = await createSandboxAction(accountId, sandboxName, 1); | ||
expect(response.personalAccessKey).toEqual(personalAccessKey); | ||
expect(response.name).toEqual(sandboxName); | ||
expect(response.sandbox).toBeTruthy(); | ||
}); | ||
|
||
it('deleteSandbox()', async () => { | ||
const response = await deleteSandboxAction(accountId, sandboxHubId); | ||
expect(response.parentAccountId).toEqual(accountId); | ||
expect(response.sandboxAccountId).toEqual(sandboxHubId); | ||
}); | ||
|
||
it('getSandboxUsageLimits()', async () => { | ||
getSandboxUsageLimits.mockResolvedValue({ | ||
usage: MOCK_USAGE_DATA, | ||
}); | ||
|
||
const response = await getSandboxUsageLimitsAction(accountId); | ||
expect(response).toMatchObject(MOCK_USAGE_DATA); | ||
}); | ||
|
||
it('fetchTypes()', async () => { | ||
fetchTypes.mockResolvedValue({ | ||
results: MOCK_TYPES, | ||
}); | ||
|
||
const response = await fetchTypesAction(accountId, sandboxHubId); | ||
expect(response).toMatchObject(MOCK_TYPES); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the AxiosError type definition does include a status property, but I wasn't able to log any statuses directly from error when testing with actual API calls... I had to go one level deeper into the response (AxiosResponse type) to pull status, hence the changes to the tests here