Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Nov 19, 2023
1 parent ae53c6e commit 38d7e46
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/__tests__/gdpr-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as gdpr from '../gdpr-utils'

import { _isNull } from '../utils/type-utils'
import { document, assignableWindow } from '../utils/globals'
import { GDPROptions } from '../types'

const TOKENS = [
`test-token`,
Expand Down Expand Up @@ -31,7 +32,7 @@ function forPersistenceTypes(runTests: any) {
}

function assertPersistenceValue(
persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined,
persistenceType: GDPROptions['persistenceType'],
token: string,
value: string | number | null,
persistencePrefix = DEFAULT_PERSISTENCE_PREFIX
Expand Down Expand Up @@ -62,7 +63,7 @@ describe(`GDPR utils`, () => {
})

describe(`optIn`, () => {
forPersistenceTypes(function (persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined) {
forPersistenceTypes(function (persistenceType: GDPROptions['persistenceType']) {
it(`should set a cookie marking the user as opted-in for a given token`, () => {
TOKENS.forEach((token) => {
gdpr.optIn(token, { persistenceType })
Expand Down Expand Up @@ -147,7 +148,7 @@ describe(`GDPR utils`, () => {
})

describe(`optOut`, () => {
forPersistenceTypes(function (persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined) {
forPersistenceTypes(function (persistenceType: GDPROptions['persistenceType']) {
it(`should set a cookie marking the user as opted-out for a given token`, () => {
TOKENS.forEach((token) => {
gdpr.optOut(token, { persistenceType })
Expand Down Expand Up @@ -204,7 +205,7 @@ describe(`GDPR utils`, () => {
})

describe(`hasOptedIn`, () => {
forPersistenceTypes(function (persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined) {
forPersistenceTypes(function (persistenceType: GDPROptions['persistenceType']) {
it(`should return 'false' if the user hasn't opted in for a given token`, () => {
TOKENS.forEach((token) => {
expect(gdpr.hasOptedIn(token, { persistenceType })).toBe(false)
Expand Down Expand Up @@ -287,7 +288,7 @@ describe(`GDPR utils`, () => {
})

describe(`hasOptedOut`, () => {
forPersistenceTypes(function (persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined) {
forPersistenceTypes(function (persistenceType: GDPROptions['persistenceType']) {
it(`should return 'false' if the user hasn't opted out for a given token`, () => {
TOKENS.forEach((token) => {
expect(gdpr.hasOptedOut(token, { persistenceType })).toBe(false)
Expand Down Expand Up @@ -370,7 +371,7 @@ describe(`GDPR utils`, () => {
})

describe(`clearOptInOut`, () => {
forPersistenceTypes(function (persistenceType: 'cookie' | 'localStorage' | 'localStorage+cookie' | undefined) {
forPersistenceTypes(function (persistenceType: GDPROptions['persistenceType']) {
it(`should delete any opt cookies for a given token`, () => {
;[gdpr.optIn, gdpr.optOut].forEach((optFunc) => {
TOKENS.forEach((token) => {
Expand Down

0 comments on commit 38d7e46

Please sign in to comment.