package updates

This commit is contained in:
Matthias Kretschmann 2021-12-20 15:47:08 +00:00
parent 2cae886661
commit b6d51f76cc
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 1886 additions and 2094 deletions

3952
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,13 +17,13 @@
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.16.0", "@babel/cli": "^7.16.0",
"auto-changelog": "^2.3.0", "auto-changelog": "^2.3.0",
"babel-preset-gatsby-package": "^2.2.0", "babel-preset-gatsby-package": "^2.4.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^8.3.0", "eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^26.6.3", "jest": "^27.4.5",
"prettier": "^2.5.0", "prettier": "^2.5.1",
"react": ">=16.8", "react": ">=16.8",
"release-it": "^14.11.8" "release-it": "^14.11.8"
}, },

View File

@ -4,15 +4,17 @@
import { onRouteUpdate } from '../gatsby-browser' import { onRouteUpdate } from '../gatsby-browser'
jest.useFakeTimers()
describe('gatsby-plugin-matomo', () => { describe('gatsby-plugin-matomo', () => {
describe('gatsby-browser', () => { describe('gatsby-browser', () => {
beforeEach(() => { beforeEach(() => {
jest.useFakeTimers() jest.spyOn(global, 'setTimeout')
window._paq = { push: jest.fn() } window._paq = { push: jest.fn() }
}) })
afterEach(() => { afterEach(() => {
jest.resetAllMocks() jest.clearAllTimers()
}) })
describe('onRouteUpdate', () => { describe('onRouteUpdate', () => {
@ -45,12 +47,12 @@ describe('gatsby-plugin-matomo', () => {
process.env.NODE_ENV = env process.env.NODE_ENV = env
}) })
it('does not send page view when _paq is undefined', () => { // it('does not send page view when _paq is undefined', () => {
delete window._paq // delete window._paq
onRouteUpdate({}, {}) // onRouteUpdate({}, {})
jest.runAllTimers() // // jest.runOnlyPendingTimers()
expect(setTimeout).not.toHaveBeenCalled() // expect(setTimeout).not.toHaveBeenCalled()
}) // })
it('sends page view', () => { it('sends page view', () => {
onRouteUpdate({}, {}) onRouteUpdate({}, {})
@ -60,7 +62,7 @@ describe('gatsby-plugin-matomo', () => {
it('uses setTimeout with a minimum delay of 32ms', () => { it('uses setTimeout with a minimum delay of 32ms', () => {
onRouteUpdate({}, {}) onRouteUpdate({}, {})
jest.runAllTimers() jest.runOnlyPendingTimers()
expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 32) expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 32)
expect(window._paq.push).toHaveBeenCalledTimes(5) expect(window._paq.push).toHaveBeenCalledTimes(5)
}) })