-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix for
undefined
in Nuxt provider data (#3185)
* Fix undefined in provider data * Update unit test * Add unit test
- Loading branch information
Showing
4 changed files
with
45 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
frontend/test/unit/specs/data/media-provider-service.spec.js
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,28 @@ | ||
import { initProviderServices } from "~/data/media-provider-service" | ||
import { warn } from "~/utils/console" | ||
|
||
jest.mock("~/utils/console", () => ({ warn: jest.fn(), log: jest.fn() })) | ||
let mockReturn = {} | ||
jest.mock("~/data/api-service", () => ({ | ||
createApiService: function () { | ||
return { | ||
get: async () => { | ||
return mockReturn | ||
}, | ||
} | ||
}, | ||
})) | ||
|
||
describe("Media Provider Service", () => { | ||
afterEach(() => { | ||
warn.mockClear() | ||
}) | ||
it("No data in response", async () => { | ||
const result = await initProviderServices.image().getProviderStats() | ||
expect(result).toEqual([]) | ||
expect(warn).toHaveBeenCalledTimes(1) | ||
expect(warn).toHaveBeenCalledWith( | ||
"Invalid response from provider stats endpoint: {}" | ||
) | ||
}) | ||
}) |
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