mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import nock from 'nock';
|
|
|
|
import { PlexSDK } from '../../../src';
|
|
|
|
import { ActivitiesService } from '../../../src/services/activities/Activities';
|
|
|
|
describe('test ActivitiesService object', () => {
|
|
it('should be an object', () => {
|
|
expect(typeof ActivitiesService).toBe('function');
|
|
});
|
|
});
|
|
|
|
describe('test Activities', () => {
|
|
let sdk: any;
|
|
|
|
beforeEach(() => {
|
|
sdk = new PlexSDK({});
|
|
|
|
nock.cleanAll();
|
|
});
|
|
|
|
describe('test getServerActivities', () => {
|
|
test('test api call', () => {
|
|
const scope = nock('http://10.10.10.47:32400').get('/activities').reply(200, { data: {} });
|
|
return sdk.activities
|
|
.getServerActivities()
|
|
.then((r: any) => expect(r.data).toEqual({ data: {} }));
|
|
});
|
|
});
|
|
|
|
describe('test cancelServerActivities', () => {
|
|
test('test api call', () => {
|
|
const scope = nock('http://10.10.10.47:32400')
|
|
.delete('/activities/unde')
|
|
.reply(200, { data: {} });
|
|
return sdk.activities
|
|
.cancelServerActivities('unde')
|
|
.then((r: any) => expect(r.data).toEqual({ data: {} }));
|
|
});
|
|
|
|
test('test will throw error if required fields missing', () => {
|
|
const scope = nock('http://10.10.10.47:32400')
|
|
.delete('/activities/commodi')
|
|
.reply(200, { data: {} });
|
|
return expect(async () => await sdk.activities.cancelServerActivities()).rejects.toThrow();
|
|
});
|
|
|
|
test('test will throw error on a non-200 response', () => {
|
|
const scope = nock('http://10.10.10.47:32400')
|
|
.delete('/activities/alias')
|
|
.reply(404, { data: {} });
|
|
return expect(
|
|
async () => await sdk.activities.cancelServerActivities('alias'),
|
|
).rejects.toThrow();
|
|
});
|
|
});
|
|
});
|