Skip to content

Commit

Permalink
chore: restore unrelated refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
williazz committed Aug 24, 2023
1 parent 94baa98 commit c901d91
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/plugins/event-plugins/__tests__/FetchPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
} from '../../utils/http-utils';
import { advanceTo } from 'jest-date-mock';
import {
DEFAULT_CONFIG,
record,
recordPageView,
xRayOffContext,
xRayOnContext,
mockFetch,
Expand Down
33 changes: 18 additions & 15 deletions src/plugins/event-plugins/__tests__/ResourcePlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ import {
import { ResourcePlugin } from '../ResourcePlugin';
import { mockRandom } from 'jest-mock-random';
import {
context as mockContext,
context,
DEFAULT_CONFIG,
record
getSession,
record,
recordPageView
} from '../../../test-utils/test-utils';
import { PERFORMANCE_RESOURCE_EVENT_TYPE } from '../../utils/constant';
import { ResourceEvent } from '../../../events/resource-event';
import { PluginContext } from '../../types';
import { PartialPerformancePluginConfig } from 'plugins/utils/performance-utils';

const buildResourcePlugin = (config?: PartialPerformancePluginConfig) => {
Expand All @@ -45,7 +48,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -67,13 +70,13 @@ describe('ResourcePlugin tests', () => {
test('when recordResourceUrl is false then the resource name is not recorded', async () => {
// Setup
mockRandom(0); // Retain order in shuffle
const context = Object.assign({}, mockContext, {
const mockContext = Object.assign({}, context, {
config: { ...DEFAULT_CONFIG, recordResourceUrl: false }
});
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(context);
plugin.load(mockContext);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -94,7 +97,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -110,7 +113,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -126,7 +129,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -139,7 +142,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
plugin.disable();
plugin.enable();
window.dispatchEvent(new Event('load'));
Expand All @@ -154,7 +157,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(mockContext);
plugin.load(context);
plugin.disable();
window.dispatchEvent(new Event('load'));
plugin.disable();
Expand All @@ -171,7 +174,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin({ eventLimit: 1 });

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -188,7 +191,7 @@ describe('ResourcePlugin tests', () => {
// Run
const plugin: ResourcePlugin = buildResourcePlugin({ eventLimit: 1 });

plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));

plugin.disable();
Expand All @@ -212,7 +215,7 @@ describe('ResourcePlugin tests', () => {
const plugin: ResourcePlugin = buildResourcePlugin({ eventLimit: 3 });

// Run
plugin.load(mockContext);
plugin.load(context);

mockRandom(0.99); // Retain order in shuffle
window.dispatchEvent(new Event('load'));
Expand Down Expand Up @@ -253,7 +256,7 @@ describe('ResourcePlugin tests', () => {
});

// Run
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand All @@ -265,7 +268,7 @@ describe('ResourcePlugin tests', () => {
mockPerformanceObserver();

const plugin = buildResourcePlugin();
plugin.load(mockContext);
plugin.load(context);
window.dispatchEvent(new Event('load'));
plugin.disable();

Expand Down
1 change: 1 addition & 0 deletions src/plugins/event-plugins/__tests__/XhrPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
xRayOffContext,
xRayOnContext,
record,
recordPageView,
mockNow
} from '../../../test-utils/test-utils';
import mock from 'xhr-mock';
Expand Down

0 comments on commit c901d91

Please sign in to comment.