@fastly/performance-observer-polyfill
Advanced tools
Comparing version 1.1.1 to 2.0.0-pre-1
@@ -1,8 +0,9 @@ | ||
/*! | ||
/** | ||
* Performance Observer Polyfill | ||
* Version: 1.1.1 | ||
* Version: 2.0.0-pre-1 | ||
* Generated: 2021-02-10 | ||
* https://github.com/fastly/performance-observer-polyfill | ||
* | ||
* Copyright (c) 2020, Fastly, Inc. All rights reserved. | ||
* | ||
* | ||
* Copyright (c) 2021, Fastly, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
@@ -14,6 +15,6 @@ * of this software and associated documentation files (the "Software"), to deal | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
@@ -26,4 +27,4 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* SOFTWARE. | ||
* | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PerformanceOberserverPolyfill=t():e.PerformanceOberserverPolyfill=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function c(e,t,r){return(c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&a(o,r.prototype),o}).apply(null,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}r.r(t);var l=function(e){function t(e){var r,i,s,c,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?u(e):t}(this,(r=f(t)).call.apply(r,[this].concat(o(e)))),s=u(i),a=void 0,(c="_entries")in s?Object.defineProperty(s,c,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[c]=a,i._entries=e,i}var r,s,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(t,e),r=t,(s=[{key:"getEntries",value:function(){return this._entries}},{key:"getEntriesByType",value:function(e){return this._entries.filter((function(t){return t.entryType===e}))}},{key:"getEntriesByName",value:function(e,t){return this._entries.filter((function(t){return t.name===e})).filter((function(e){return!t||e.entryType===t}))}}])&&i(r.prototype,s),c&&i(r,c),t}(s(Array));function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var d=["mark","measure","navigation","resource"],h="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present.",m="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present, not both.",g="Aborting 'observe' on 'PerformanceObserver': no valid entry types present in either 'entryTypes' or 'type' member.",O="Invalid or unsupported entry types provided to 'observe' on 'PerformanceObserver'.",w=function(e){return d.some((function(t){return e===t}))},k=new(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.registeredObservers,n=void 0===r?new Set:r,o=t.processedEntries,i=void 0===o?new Set:o,u=t.interval,s=void 0===u?100:u,c=t.context,a=void 0===c?self:c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),p(this,"registeredObservers",void 0),p(this,"processedEntries",void 0),p(this,"interval",void 0),p(this,"intervalId",void 0),p(this,"context",void 0),this.registeredObservers=n,this.processedEntries=i,this.interval=s,this.context=a,this.intervalId=null}var t,r,n;return t=e,(r=[{key:"getNewEntries",value:function(){var e=this;return this.context.performance.getEntries().filter((function(t){return!e.processedEntries.has(t)}))}},{key:"getObserversForType",value:function(e,t){return Array.from(e).filter((function(e){return e.entryTypes.some((function(e){return e===t}))}))}},{key:"processBuffer",value:function(e){var t=Array.from(e.buffer),r=new l(t);e.buffer.clear(),t.length&&e.callback&&e.callback.call(void 0,r,e)}},{key:"processEntries",value:function(){var e=this;this.getNewEntries().forEach((function(t){var r=t.entryType;e.getObserversForType(e.registeredObservers,r).forEach((function(e){e.buffer.add(t)})),e.processedEntries.add(t)}));var t=function(){return e.registeredObservers.forEach(e.processBuffer)};"requestAnimationFrame"in this.context?this.context.requestAnimationFrame(t):this.context.setTimeout(t,0)}},{key:"add",value:function(e){this.registeredObservers.add(e),1===this.registeredObservers.size&&this.observe()}},{key:"remove",value:function(e){this.registeredObservers.delete(e),this.registeredObservers.size||this.disconnect()}},{key:"observe",value:function(){this.intervalId=this.context.setInterval(this.processEntries.bind(this),this.interval)}},{key:"disconnect",value:function(){this.intervalId=this.context.clearInterval(this.intervalId)}}])&&y(t.prototype,r),n&&y(t,n),e}()),E=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),b(this,"callback",void 0),b(this,"buffer",void 0),b(this,"entryTypes",[]),b(this,"taskQueue",void 0),this.callback=t,this.buffer=new Set,this.taskQueue=r}var t,r,n;return t=e,(r=[{key:"observe",value:function(e){if(!e)throw new Error(h);if(e.entryTypes&&e.type)throw new Error(m);var t;if(e.entryTypes)t=e.entryTypes;else{if(!e.type)throw new Error(h);t=[e.type]}var r=t.filter(w);r.length>0&&r.length!==t.length&&console.warn(O),r.length?(this.entryTypes=r,this.taskQueue.add(this)):console.warn(g)}},{key:"disconnect",value:function(){this.taskQueue.remove(this)}},{key:"takeRecords",value:function(){var e=Array.from(this.buffer);return new l(e)}}])&&v(t.prototype,r),n&&v(t,n),e}();b(E,"supportedEntryTypes",d);var P=E,j="PerformanceObserver"in self&&"function"==typeof PerformanceObserver;t.default=j?PerformanceObserver:P}])})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).FASTLY=t()}(this,(function(){"use strict";var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};var t=function(t){function r(e){var r=t.apply(this,e)||this;return r._entries=e,r}return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r.prototype.getEntries=function(){return this._entries},r.prototype.getEntriesByType=function(e){return this._entries.filter((function(t){return t.entryType===e}))},r.prototype.getEntriesByName=function(e,t){return this._entries.filter((function(t){return t.name===e})).filter((function(e){return!t||e.entryType===t}))},r}(Array),r=function(){function e(e){var t=void 0===e?{}:e,r=t.registeredObservers,n=void 0===r?new Set:r,o=t.processedEntries,s=void 0===o?new Set:o,i=t.interval,c=void 0===i?100:i,f=t.context,u=void 0===f?self:f;this.registeredObservers=n,this.processedEntries=s,this.interval=c,this.context=u,this.intervalId=null}return e.prototype.getNewEntries=function(){var e=this;return this.context.performance.getEntries().filter((function(t){return!e.processedEntries.has(t)}))},e.prototype.getObserversForType=function(e,t){return Array.from(e).filter((function(e){return e.entryTypes.some((function(e){return e===t}))}))},e.prototype.processBuffer=function(e){var r=Array.from(e.buffer),n=new t(r);e.buffer.clear(),r.length&&e.callback&&e.callback.call(void 0,n,e)},e.prototype.processEntries=function(){var e=this;this.getNewEntries().forEach((function(t){var r=t.entryType;e.getObserversForType(e.registeredObservers,r).forEach((function(e){e.buffer.add(t)})),e.processedEntries.add(t)}));var t=function(){return e.registeredObservers.forEach(e.processBuffer)};"requestAnimationFrame"in this.context?this.context.requestAnimationFrame(t):this.context.setTimeout(t,0)},e.prototype.add=function(e){this.registeredObservers.add(e),1===this.registeredObservers.size&&this.observe()},e.prototype.remove=function(e){this.registeredObservers.delete(e),this.registeredObservers.size||this.disconnect()},e.prototype.observe=function(){this.intervalId=this.context.setInterval(this.processEntries.bind(this),this.interval)},e.prototype.disconnect=function(){this.intervalId=this.context.clearInterval(this.intervalId)},e}(),n=["mark","measure","navigation","resource"],o="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present.",s="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present, not both.",i="Aborting 'observe' on 'PerformanceObserver': no valid entry types present in either 'entryTypes' or 'type' member.",c="Invalid or unsupported entry types provided to 'observe' on 'PerformanceObserver'.",f=function(e){return n.some((function(t){return e===t}))},u=new r,p=function(){function e(e,t){void 0===t&&(t=u),this.entryTypes=[],this.callback=e,this.buffer=new Set,this.taskQueue=t}return e.prototype.observe=function(e){if(!e)throw new Error(o);if(e.entryTypes&&e.type)throw new Error(s);var t;if(e.entryTypes)t=e.entryTypes;else{if(!e.type)throw new Error(o);t=[e.type]}var r=t.filter(f);r.length>0&&r.length!==t.length&&console.warn(c),r.length?(this.entryTypes=r,this.taskQueue.add(this)):console.warn(i)},e.prototype.disconnect=function(){this.taskQueue.remove(this)},e.prototype.takeRecords=function(){var e=Array.from(this.buffer);return new t(e)},e.supportedEntryTypes=n,e}();return"PerformanceObserver"in self&&"function"==typeof PerformanceObserver?PerformanceObserver:p})); |
{ | ||
"name": "@fastly/performance-observer-polyfill", | ||
"version": "1.1.1", | ||
"version": "2.0.0-pre-1", | ||
"main": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/esm/types/index.d.ts", | ||
"files": [ | ||
@@ -23,3 +25,2 @@ "src", | ||
], | ||
"types": "src/@types/index.d.ts", | ||
"scripts": { | ||
@@ -29,5 +30,5 @@ "test": "npm run test:once && npm run lint", | ||
"test:watch": "jest --watch", | ||
"start": "webpack-dev-server --progress --open --config webpack.dev.js", | ||
"build": "webpack --config webpack.prod.js", | ||
"build:dev": "webpack --config webpack.dev.js", | ||
"start": "rollup -c --environment ENV:dev", | ||
"build": "rollup -c --environment ENV:prod", | ||
"build:dev": "npm run start", | ||
"lint": "tsc --noEmit && eslint '*/**/*.ts' --fix", | ||
@@ -38,15 +39,9 @@ "release": "npx np", | ||
"devDependencies": { | ||
"@babel/cli": "^7.7.0", | ||
"@babel/core": "^7.7.2", | ||
"@babel/plugin-proposal-class-properties": "^7.7.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/preset-env": "^7.7.1", | ||
"@babel/preset-typescript": "^7.7.2", | ||
"@babel/types": "^7.7.2", | ||
"@rollup/plugin-html": "^0.2.0", | ||
"@rollup/plugin-node-resolve": "^11.0.0", | ||
"@rollup/plugin-typescript": "^6.1.0", | ||
"@types/jest": "^24.0.22", | ||
"@types/node": "^14.14.10", | ||
"@typescript-eslint/eslint-plugin": "^1.13.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"babel-jest": "^24.9.0", | ||
"babel-loader": "^8.0.6", | ||
"clean-webpack-plugin": "^2.0.2", | ||
"core-js": "^3.4.0", | ||
@@ -57,15 +52,17 @@ "eslint": "^5.16.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"html-webpack-plugin": "^3.2.0", | ||
"husky": "^2.7.0", | ||
"jest": "^24.9.0", | ||
"jest": "^26.6.3", | ||
"jest-mock-random": "^1.0.2", | ||
"prettier": "^1.17.1", | ||
"typescript": "^3.7.2", | ||
"webpack": "^4.41.2", | ||
"webpack-bundle-analyzer": "^3.6.0", | ||
"webpack-cli": "^3.3.10", | ||
"webpack-dev-server": "^3.9.0", | ||
"webpack-merge": "^4.2.2" | ||
"rollup": "^2.30.0", | ||
"rollup-plugin-license": "^2.2.0", | ||
"rollup-plugin-serve": "^1.1.0", | ||
"rollup-plugin-sizes": "^1.0.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^3.9.7" | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"tslib": "^2.0.3" | ||
}, | ||
"husky": { | ||
@@ -72,0 +69,0 @@ "hooks": { |
@@ -64,3 +64,3 @@ <h1 align="center" style="border-bottom: none;">🔎 PerformanceObserver Polyfill</h1> | ||
### Requirements | ||
- Node.js >= 10a | ||
- Node.js >= 10 | ||
@@ -67,0 +67,0 @@ ### Install |
@@ -16,4 +16,4 @@ declare namespace PollingPerformanceObserver { | ||
declare const PollingPerformanceObserver: typeof PerformanceObserver; | ||
/* declare const PollingPerformanceObserver: typeof PerformanceObserver; */ | ||
export default PollingPerformanceObserver; |
@@ -0,20 +1,17 @@ | ||
import { mocked } from "ts-jest/utils"; | ||
import PerformanceObserver from "./observer"; | ||
import PerformanceObserverTaskQueue from "./task-queue"; | ||
const mockTaskQueueAdd = jest.fn(); | ||
const mockTaskQueueRemove = jest.fn(); | ||
jest.mock( | ||
"./task-queue", | ||
(): jest.Mock => { | ||
return jest.fn().mockImplementation((): any => { | ||
(): jest.Mock => | ||
jest.fn().mockImplementation((): any => { | ||
return { | ||
add: mockTaskQueueAdd, | ||
remove: mockTaskQueueRemove | ||
add: jest.fn(), | ||
remove: jest.fn() | ||
}; | ||
}); | ||
} | ||
}) | ||
); | ||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars | ||
const callbackFixture = (entires: PerformanceObserverEntryList): void => {}; | ||
const callbackFixture = jest.fn(); | ||
@@ -53,11 +50,11 @@ describe("PerformanceObserver", (): void => { | ||
const originalWarn = console.warn; | ||
let consoleOutput: string[] = []; | ||
const mockedWarn = (output: string): number => consoleOutput.push(output); | ||
beforeEach((): void => { | ||
mockTaskQueueAdd.mockClear(); | ||
consoleOutput = []; | ||
console.warn = mockedWarn; | ||
const mockedConsoleWarn = jest.fn(); | ||
const mockTaskQueue = mocked(new PerformanceObserverTaskQueue(), true); | ||
beforeAll((): void => { | ||
console.warn = mockedConsoleWarn; | ||
}); | ||
afterEach((): void => { | ||
jest.resetAllMocks(); | ||
}); | ||
afterAll((): void => { | ||
console.warn = originalWarn; | ||
@@ -67,6 +64,3 @@ }); | ||
it("should throw if no entryTypes or type are supplied", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
expect(observer.observe).toThrow(); | ||
@@ -77,6 +71,3 @@ expect((): void => observer.observe({ buffered: false })).toThrow(); | ||
it("should throw if both entryTypes and type are supplied", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
expect((): void => | ||
@@ -88,6 +79,3 @@ observer.observe({ entryTypes: ["resource"], type: "resource" }) | ||
it("should validate entryTypes and ignore any invalid types", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.observe({ entryTypes: ["resource", "mark", "bad"] }); | ||
@@ -99,19 +87,12 @@ expect(observer.entryTypes).toHaveLength(2); | ||
it("should warn if invalid entryTypes are supplied", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.observe({ entryTypes: ["resource", "mark", "bad"] }); | ||
expect(consoleOutput).toHaveLength(1); | ||
expect(mockedConsoleWarn).toHaveBeenCalledTimes(1); | ||
}); | ||
it("should abort if no valid entryTypes are supplied", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.observe({ entryTypes: ["invalid"] }); | ||
expect(consoleOutput).toHaveLength(1); | ||
expect(mockTaskQueueAdd).toHaveBeenCalledTimes(0); | ||
expect(mockedConsoleWarn).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueue.add).toHaveBeenCalledTimes(0); | ||
}); | ||
@@ -121,9 +102,6 @@ | ||
const fixture = { entryTypes: ["resource"] }; | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.observe(fixture); | ||
expect(mockTaskQueueAdd).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueueAdd).toHaveBeenCalledWith(observer); | ||
expect(mockTaskQueue.add).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueue.add).toHaveBeenCalledWith(observer); | ||
}); | ||
@@ -133,9 +111,6 @@ | ||
const fixture = { type: "resource" }; | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.observe(fixture); | ||
expect(mockTaskQueueAdd).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueueAdd).toHaveBeenCalledWith(observer); | ||
expect(mockTaskQueue.add).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueue.add).toHaveBeenCalledWith(observer); | ||
}); | ||
@@ -145,12 +120,12 @@ }); | ||
describe("#disconnect", (): void => { | ||
beforeEach((): void => mockTaskQueueRemove.mockClear()); | ||
const mockTaskQueue = mocked(new PerformanceObserverTaskQueue(), true); | ||
afterEach((): void => { | ||
jest.resetAllMocks(); | ||
}); | ||
it("should remove observer from the task queue", (): void => { | ||
const observer = new PerformanceObserver( | ||
callbackFixture, | ||
new PerformanceObserverTaskQueue() | ||
); | ||
const observer = new PerformanceObserver(callbackFixture, mockTaskQueue); | ||
observer.disconnect(); | ||
expect(mockTaskQueueRemove).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueueRemove).toHaveBeenCalledWith(observer); | ||
expect(mockTaskQueue.remove).toHaveBeenCalledTimes(1); | ||
expect(mockTaskQueue.remove).toHaveBeenCalledWith(observer); | ||
}); | ||
@@ -157,0 +132,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23
1392
63628
1
15
2
+ Addedtslib@^2.0.3
+ Addedtslib@2.8.1(transitive)