Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should init with collectStatistics(true)", () => {
// Given
const mockGa = ImportMock.mockFunction(ga, "sendEvent");
// When
flickingInfo = createFlicking(horizontal.full, { collectStatistics: true });
mockGa.restore();
// Then
expect(mockGa.callCount).to.be.equals(1);
});
});
before(() => {
// Stub out pact-node
const manager = ImportMock.mockClass(serviceFactory, "createServer") as any
manager.mock("createServer", () => {})
})
it('should redirect user to login portal', async function() {
req.headers['proxy-authorization'] = 'zglfzeljfzelmkj';
req.query.rd = 'https://login.example.com/';
const mock = ImportMock.mockOther(GetBasicAuth, "default", () => Promise.reject(new NotAuthenticatedError('No!')));
await Get(vars)(req, res as any);
Assert(res.redirect.calledWith('https://login.example.com/?rd=https://secret.example.com/'));
mock.restore();
});
});
it('should allow access to user', async function() {
const mock = ImportMock.mockOther(GetSessionCookie, "default", () => Promise.resolve());
await Get(vars)(req, res as any);
Assert(res.send.calledWithExactly());
Assert(res.status.calledWithExactly(204))
mock.restore();
});
});
it('should fail when authorizations are not sufficient', function() {
req.headers['proxy-authorization'] = 'Basic aGVsbG8xOndvcmxkCg==';
const mock = ImportMock.mockOther(CheckAuthorizations, 'default', () => { throw new Error('Not enough permissions.')});
mocks.usersDatabase.checkUserPasswordStub.resolves({
email: 'john@example.com',
groups: ['group1', 'group2'],
});
AssertRejects(async () => await GetBasicAuthModule(req, res as any, vars));
mock.restore();
});
import { fireEvent, render } from '@testing-library/react';
import fetchMock from 'fetch-mock';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { ImportMock } from 'ts-mock-imports';
import { DashboardVideoPaneTranscriptOption } from '.';
import * as useTimedTextTrackModule from '../../data/stores/useTimedTextTrack';
import { timedTextMode, uploadState } from '../../types/tracks';
import { Deferred } from '../../utils/tests/Deferred';
import { wrapInIntlProvider } from '../../utils/tests/intl';
const useTimedTextTrackStub = ImportMock.mockFunction(
useTimedTextTrackModule,
'useTimedTextTrack',
);
jest.mock('../../data/appData', () => ({
appData: {},
}));
describe('', () => {
afterEach(jest.resetAllMocks);
afterAll(useTimedTextTrackStub.restore);
const video = {
description: 'Some description',
has_transcript: false,
id: '443',
import { wrapInIntlProvider } from '../../utils/tests/intl';
jest.mock('react-router-dom', () => ({
Redirect: ({ push, to }: { push: boolean; to: string }) =>
`Redirect push to ${to}.`,
}));
jest.mock('../../data/appData', () => ({
appData: {
jwt: 'some token',
},
}));
const mockAddThumbnail = jest.fn();
const useThumbnailStub = ImportMock.mockFunction(
useThumbnailModule,
'useThumbnail',
);
describe('', () => {
afterEach(jest.resetAllMocks);
afterAll(useThumbnailStub.restore);
const video = {
description: '',
has_transcript: false,
id: '43',
is_ready_to_show: true,
show_download: true,
thumbnail: {
jest.mock('jwt-decode', () => jest.fn());
jest.mock('../../utils/isAbrSupported', () => ({
isHlsSupported: jest.fn(),
isMSESupported: jest.fn(),
}));
const mockIsMSESupported = isMSESupported as jestMockOf;
const mockIsHlsSupported = isHlsSupported as jestMockOf;
jest.mock('../../Player/createPlayer', () => ({
createPlayer: jest.fn(),
}));
const mockCreatePlayer = createPlayer as jestMockOf;
const useTimedTextTrackStub = ImportMock.mockFunction(
useTimedTextTrackModule,
'useTimedTextTrack',
);
jest.mock('../../data/appData', () => ({
appData: {
video: {
description: 'Some description',
id: 'video-id',
is_ready_to_show: true,
show_download: false,
thumbnail: null,
timed_text_tracks: [],
title: 'Some title',
upload_state: 'ready',
urls: {