-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix edit constructed inventory hanging loading state (#14343)
- Loading branch information
1 parent
8c7ab8f
commit 2a1dffd
Showing
8 changed files
with
177 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import ConstructedInventories from './ConstructedInventories'; | ||
|
||
describe('ConstructedInventoriesAPI', () => { | ||
const constructedInventoryId = 1; | ||
const constructedInventoryMethod = 'PUT'; | ||
let ConstructedInventoriesAPI; | ||
let mockHttp; | ||
|
||
beforeEach(() => { | ||
const optionsPromise = () => | ||
Promise.resolve({ | ||
data: { | ||
actions: { | ||
PUT: {}, | ||
}, | ||
}, | ||
}); | ||
mockHttp = { | ||
options: jest.fn(optionsPromise), | ||
}; | ||
ConstructedInventoriesAPI = new ConstructedInventories(mockHttp); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
test('readConstructedInventoryOptions calls options with the expected params', async () => { | ||
await ConstructedInventoriesAPI.readConstructedInventoryOptions( | ||
constructedInventoryId, | ||
constructedInventoryMethod | ||
); | ||
expect(mockHttp.options).toHaveBeenCalledTimes(1); | ||
expect(mockHttp.options).toHaveBeenCalledWith( | ||
`api/v2/constructed_inventories/${constructedInventoryId}/` | ||
); | ||
}); | ||
|
||
test('readConstructedInventory should throw an error if action method is missing', async () => { | ||
try { | ||
await ConstructedInventoriesAPI.readConstructedInventoryOptions( | ||
constructedInventoryId, | ||
'POST' | ||
); | ||
} catch (error) { | ||
expect(error.message).toContain( | ||
'You have insufficient access to this Constructed Inventory.' | ||
); | ||
} | ||
}); | ||
}); |
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
Oops, something went wrong.