Fix image url test

This commit is contained in:
rhyse302 2024-02-23 21:01:12 -06:00 committed by Bill Thornton
parent d705dc993b
commit d74d149944
3 changed files with 21 additions and 4 deletions

View File

@ -3,7 +3,7 @@
"licenser.license": "Custom",
"licenser.useSingleLineStyle": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
},
"eslint.format.enable": true,
"editor.formatOnSave": false

View File

@ -9,9 +9,18 @@ import { vi, describe, expect, it, afterEach } from 'vitest';
import { Api, AUTHORIZATION_HEADER } from '..';
import { SERVER_URL, TEST_CLIENT, TEST_DEVICE } from '../__helpers__/common';
import { ImageType } from '../generated-client/models';
import { getAuthorizationHeader } from '../utils';
vi.mock('axios');
vi.mock('axios', async () => {
const actual = await vi.importActual('axios');
return {
default: {
getUri: actual.getUri,
request: vi.fn()
}
}
})
const TEST_ACCESS_TOKEN = 'TEST-ACCESS-TOKEN';
/**
@ -48,8 +57,8 @@ describe('Api', () => {
});
it('should logout and update state', async () => {
const api = new Api(SERVER_URL, TEST_CLIENT, TEST_DEVICE, TEST_ACCESS_TOKEN);
const requestSpy = vi.spyOn(axios, 'request');
const api = new Api(SERVER_URL, TEST_CLIENT, TEST_DEVICE, TEST_ACCESS_TOKEN);
expect(api.accessToken).toBe(TEST_ACCESS_TOKEN);
@ -71,4 +80,12 @@ describe('Api', () => {
const api = new Api(SERVER_URL, TEST_CLIENT, TEST_DEVICE);
expect(api.basePath).toBe(SERVER_URL);
});
it('should return an item image url', () => {
vi.restoreAllMocks();
const api = new Api(SERVER_URL, TEST_CLIENT, TEST_DEVICE);
expect(api.getItemImageUrl('TEST')).toBe('https://example.com/Items/TEST/Images/Primary');
expect(api.getItemImageUrl('TEST', ImageType.Backdrop, { fillWidth: 100, fillHeight: 100 }))
.toBe('https://example.com/Items/TEST/Images/Backdrop?fillWidth=100&fillHeight=100');
});
});

View File

@ -102,7 +102,7 @@ describe('RecommendedServerDiscovery', () => {
const requestSpy = vi.spyOn(axios, 'request');
requestSpy.mockImplementationOnce(() => {
vi.setSystemTime(now + 3001)
vi.setSystemTime(now + 3001);
return Promise.resolve({ data: systemInfo });
});
const info = await serverDiscovery.fetchRecommendedServerInfo(ADDRESS);