mirror of
https://github.com/jellyfin/jellyfin-sdk-typescript.git
synced 2024-11-22 21:49:48 +00:00
Fix image url test
This commit is contained in:
parent
d705dc993b
commit
d74d149944
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -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
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user