Skip to content

Commit

Permalink
Merge pull request #22 from gladly-team/kevin/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
kmjennison authored Oct 9, 2021
2 parents 7178be3 + 06bb111 commit d1834ae
Show file tree
Hide file tree
Showing 14 changed files with 2,601 additions and 2,762 deletions.
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"bracketSpacing": true,
"jsxBracketSameLine": false,
"useTabs": false,
"semi": false,
"singleQuote": true,
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,29 @@
"dev:yalc-publish-push": "yalc publish --push"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.10.5",
"@babel/plugin-transform-runtime": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"babel-jest": "^26.1.0",
"babel-plugin-module-resolver": "^4.0.0",
"core-js": "^3.6.5",
"eslint": "^7.5.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.8",
"@babel/plugin-transform-runtime": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"babel-jest": "^27.2.5",
"babel-plugin-module-resolver": "^4.1.0",
"core-js": "^3.18.2",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.5.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"if-env": "^1.0.4",
"jest": "^26.1.0",
"mockdate": "^3.0.2",
"jest": "^27.2.5",
"mockdate": "^3.0.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"prop-types": "^15.7.2",
"regenerator-runtime": "^0.13.7"
"prettier": "^2.4.1",
"prop-types": "^15.7.2"
},
"dependencies": {}
}
4 changes: 1 addition & 3 deletions src/__mocks__/localStorageMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { isNil } from 'src/utils'
let mockStorage = {}

export default {
getItem: jest.fn((key) => {
return mockStorage[key]
}),
getItem: jest.fn((key) => mockStorage[key]),
setItem: jest.fn((key, val) => {
if (!isNil(val)) {
mockStorage[key] = String(val)
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mock = jest.genMockFromModule('src/utils')
const mock = jest.createMockFromModule('src/utils')

mock.getURL = jest.fn(() => 'https://example.com/foo/bar/')

Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/awaitCMPLoad.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: fix eslint rule. Ignoring for now.
/* eslint jest/no-conditional-expect: 0 */

import { logDebugging } from 'src/logger'
import { getMockTabCMPGlobal, runAsyncTimerLoops } from 'src/test-utils'
import awaitCMPLoad from 'src/awaitCMPLoad'
Expand Down
39 changes: 18 additions & 21 deletions src/__tests__/getClientLocation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ afterAll(() => {
describe('client-location: response data', () => {
it('returns the expected set of data', async () => {
expect.assertions(1)
mockGeoIP.country.mockImplementationOnce((successCallback) => {
mockGeoIP.country.mockImplementationOnce((successCallback) =>
// Mock that MaxMind says the location is Germany
return successCallback(getMockMaxMindResponse('DE', true))
})
successCallback(getMockMaxMindResponse('DE', true))
)
const getClientLocation = require('src/getClientLocation').default
const data = await getClientLocation()
expect(data).toEqual({
Expand All @@ -94,10 +94,10 @@ describe('client-location: response data', () => {

it('sets isInUS to true when the countryISOCode is US', async () => {
expect.assertions(1)
mockGeoIP.country.mockImplementationOnce((successCallback) => {
mockGeoIP.country.mockImplementationOnce((successCallback) =>
// Mock that MaxMind says the location is Germany
return successCallback(getMockMaxMindResponse('US', false))
})
successCallback(getMockMaxMindResponse('US', false))
)
const getClientLocation = require('src/getClientLocation').default
const { isInUS } = await getClientLocation()
expect(isInUS).toBe(true)
Expand All @@ -112,10 +112,10 @@ describe('client-location: response data', () => {

it('returns expected value for isInEuropeanUnion when it is true (via MaxMind)', async () => {
expect.assertions(1)
mockGeoIP.country.mockImplementationOnce((successCallback) => {
mockGeoIP.country.mockImplementationOnce((successCallback) =>
// Mock that MaxMind says the location is Germany
return successCallback(getMockMaxMindResponse('DE', true))
})
successCallback(getMockMaxMindResponse('DE', true))
)
const getClientLocation = require('src/getClientLocation').default
const { isInEuropeanUnion } = await getClientLocation()
expect(isInEuropeanUnion).toBe(true)
Expand Down Expand Up @@ -157,9 +157,8 @@ describe('client-location: response data', () => {

// Mock a MaxMind error
mockGeoIP.country.mockImplementationOnce(
(successCallback, failureCallback) => {
return failureCallback({ code: 'BAD_THING_HAPPENED' })
}
(successCallback, failureCallback) =>
failureCallback({ code: 'BAD_THING_HAPPENED' })
)

const getClientLocation = require('src/getClientLocation').default
Expand Down Expand Up @@ -260,10 +259,10 @@ describe('client-location: requests and storage', () => {

it('stores the location result in localStorage after calling MaxMind (EU country variant)', async () => {
expect.assertions(3)
mockGeoIP.country.mockImplementationOnce((successCallback) => {
mockGeoIP.country.mockImplementationOnce((successCallback) =>
// Mock that MaxMind says the location is Germany
return successCallback(getMockMaxMindResponse('DE', true))
})
successCallback(getMockMaxMindResponse('DE', true))
)
const getClientLocation = require('src/getClientLocation').default
await getClientLocation()

Expand Down Expand Up @@ -341,9 +340,8 @@ describe('client-location: isInEuropeanUnion', () => {

// Mock a MaxMind error
mockGeoIP.country.mockImplementationOnce(
(successCallback, failureCallback) => {
return failureCallback({ code: 'HTTP_TIMEOUT' })
}
(successCallback, failureCallback) =>
failureCallback({ code: 'HTTP_TIMEOUT' })
)

const getClientLocation = require('src/getClientLocation').default
Expand All @@ -364,9 +362,8 @@ describe('client-location: isInEuropeanUnion', () => {

// Mock a MaxMind error
mockGeoIP.country.mockImplementationOnce(
(successCallback, failureCallback) => {
return failureCallback({ code: 'OUT_OF_QUERIES' })
}
(successCallback, failureCallback) =>
failureCallback({ code: 'OUT_OF_QUERIES' })
)

const getClientLocation = require('src/getClientLocation').default
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ describe('index.js: initializeCMP', () => {
expect.assertions(1)
const index = require('src/index')
await index.initializeCMP()
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
expect(updateStoredPrivacyData).toHaveBeenCalled()
})

Expand Down
72 changes: 36 additions & 36 deletions src/__tests__/updateStoredPrivacyData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ describe('updateStoredPrivacyData: CMP failure', () => {
it('does not throw if awaitCMPLoad rejects', async () => {
expect.assertions(1)
awaitCMPLoad.mockRejectedValue(new Error('Timed out.'))
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await expect(updateStoredPrivacyData()).resolves.not.toThrow()
})

it('does not call __tcfapi or __uspapi if awaitCMPLoad rejects', async () => {
expect.assertions(2)
awaitCMPLoad.mockRejectedValue(new Error('Timed out.'))
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(window.__tcfapi).not.toHaveBeenCalled()
expect(window.__uspapi).not.toHaveBeenCalled()
Expand All @@ -47,8 +47,8 @@ describe('updateStoredPrivacyData: CMP failure', () => {
it('calls logDebugging if awaitCMPLoad rejects', async () => {
expect.assertions(1)
awaitCMPLoad.mockRejectedValue(new Error('Timed out.'))
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
`Could not update stored privacy data.`
Expand All @@ -60,16 +60,16 @@ describe('updateStoredPrivacyData: TCF', () => {
it('does not throw if window.__tcfapi is undefined', async () => {
expect.assertions(1)
delete window.__tcfapi
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await expect(updateStoredPrivacyData()).resolves.not.toThrow()
})

it('logs an error if window.__tcfapi is undefined', async () => {
expect.assertions(1)
delete window.__tcfapi
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logError).toHaveBeenCalledWith(
new Error(
Expand All @@ -90,8 +90,8 @@ describe('updateStoredPrivacyData: TCF', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(localStorageMgr.setItem).toHaveBeenCalledWith(
'tabCMP.tcfv2.data',
Expand All @@ -111,8 +111,8 @@ describe('updateStoredPrivacyData: TCF', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(localStorageMgr.setItem).toHaveBeenCalledWith(
'tabCMP.tcfv2.data',
Expand All @@ -132,8 +132,8 @@ describe('updateStoredPrivacyData: TCF', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
`Successfully updated TCF local storage data. Value:`,
Expand All @@ -153,8 +153,8 @@ describe('updateStoredPrivacyData: TCF', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
'Could not update TCF local storage data. The CMP errored and provided these data:',
Expand All @@ -167,16 +167,16 @@ describe('updateStoredPrivacyData: USP', () => {
it('does not throw if window.__uspapi is undefined', async () => {
expect.assertions(1)
delete window.__uspapi
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await expect(updateStoredPrivacyData()).resolves.not.toThrow()
})

it('logs an error if window.__uspapi is undefined', async () => {
expect.assertions(1)
delete window.__uspapi
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logError).toHaveBeenCalledWith(
new Error(
Expand Down Expand Up @@ -205,8 +205,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(localStorageMgr.setItem).toHaveBeenCalledWith(
'tabCMP.uspPing.data',
Expand Down Expand Up @@ -234,8 +234,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
`Successfully updated USP ping local storage data. Value:`,
Expand Down Expand Up @@ -263,8 +263,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(localStorageMgr.setItem).toHaveBeenCalledWith(
'tabCMP.usp.data',
Expand Down Expand Up @@ -292,8 +292,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(localStorageMgr.setItem).toHaveBeenCalledWith(
'tabCMP.usp.data',
Expand All @@ -318,8 +318,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
'Successfully updated USP local storage data. Value:',
Expand All @@ -344,8 +344,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
'Could not update USP local storage data. The CMP errored.'
Expand All @@ -369,8 +369,8 @@ describe('updateStoredPrivacyData: USP', () => {
default:
}
})
const updateStoredPrivacyData = require('src/updateStoredPrivacyData')
.default
const updateStoredPrivacyData =
require('src/updateStoredPrivacyData').default
await updateStoredPrivacyData()
expect(logDebugging).toHaveBeenCalledWith(
'Could not update USP local storage data. The CMP errored and provided these data:',
Expand Down
5 changes: 2 additions & 3 deletions src/awaitCMPLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { logDebugging } from 'src/logger'
// proxy for when the Quantcast Choice CMP has fully
// loaded. Resolves if successful and rejects if
// it times out.
const awaitCMPLoad = async () => {
return new Promise((resolve, reject) => {
const awaitCMPLoad = async () =>
new Promise((resolve, reject) => {
logDebugging(`Polling for CMP to have loaded in updateStoredPrivacyData.`)
const intervalMs = 500
let timesChecked = 0
Expand All @@ -27,6 +27,5 @@ const awaitCMPLoad = async () => {
}
}, intervalMs)
})
}

export default awaitCMPLoad
Loading

0 comments on commit d1834ae

Please sign in to comment.