-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2761786
commit 64b4645
Showing
7 changed files
with
106 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,58 @@ | ||
const { populateConsentForGoogleDestinations } = require('./index'); | ||
|
||
describe('unit test for populateConsentForGoogleDestinations', () => { | ||
// Returns an empty object when no properties are provided. | ||
it('should return an empty object when no properties are provided', () => { | ||
it('should return an UNSPECIFIED object when no properties are provided', () => { | ||
const result = populateConsentForGoogleDestinations({}); | ||
expect(result).toEqual({}); | ||
expect(result).toEqual({ | ||
adPersonalization: 'UNSPECIFIED', | ||
adUserData: 'UNSPECIFIED', | ||
}); | ||
}); | ||
|
||
// Sets adUserData property of consent object when userDataConsent property is provided and its value is one of the allowed consent statuses. | ||
it('should set adUserData property of consent object when userDataConsent property is provided and its value is one of the allowed consent statuses', () => { | ||
const properties = { userDataConsent: 'GRANTED' }; | ||
const result = populateConsentForGoogleDestinations(properties); | ||
expect(result).toEqual({ adUserData: 'GRANTED' }); | ||
expect(result).toEqual({ adUserData: 'GRANTED', adPersonalization: 'UNSPECIFIED' }); | ||
}); | ||
|
||
// Sets adPersonalization property of consent object when personalizationConsent property is provided and its value is one of the allowed consent statuses. | ||
it('should set adPersonalization property of consent object when personalizationConsent property is provided and its value is one of the allowed consent statuses', () => { | ||
const properties = { personalizationConsent: 'DENIED' }; | ||
const result = populateConsentForGoogleDestinations(properties); | ||
expect(result).toEqual({ adPersonalization: 'DENIED' }); | ||
expect(result).toEqual({ adPersonalization: 'DENIED', adUserData: 'UNSPECIFIED' }); | ||
}); | ||
|
||
// Returns an empty object when properties parameter is not provided. | ||
it('should return an empty object when properties parameter is not provided', () => { | ||
it('should return an UNSPECIFIED object when properties parameter is not provided', () => { | ||
const result = populateConsentForGoogleDestinations(); | ||
expect(result).toEqual({}); | ||
expect(result).toEqual({ | ||
adPersonalization: 'UNSPECIFIED', | ||
adUserData: 'UNSPECIFIED', | ||
}); | ||
}); | ||
|
||
// Returns an empty object when properties parameter is null. | ||
it('should return an empty object when properties parameter is null', () => { | ||
it('should return an UNSPECIFIED object when properties parameter is null', () => { | ||
const result = populateConsentForGoogleDestinations(null); | ||
expect(result).toEqual({}); | ||
expect(result).toEqual({ | ||
adPersonalization: 'UNSPECIFIED', | ||
adUserData: 'UNSPECIFIED', | ||
}); | ||
}); | ||
|
||
// Returns an empty object when properties parameter is an empty object. | ||
it('should return an empty object when properties parameter is an empty object', () => { | ||
it('should return an UNSPECIFIED object when properties parameter is an UNSPECIFIED object', () => { | ||
const result = populateConsentForGoogleDestinations({}); | ||
expect(result).toEqual({}); | ||
expect(result).toEqual({ | ||
adPersonalization: 'UNSPECIFIED', | ||
adUserData: 'UNSPECIFIED', | ||
}); | ||
}); | ||
|
||
// Returns an empty object when properties parameter is an empty object. | ||
it('should return an empty object when properties parameter contains adUserData and adPersonalization with non-allowed values', () => { | ||
it('should return UNKNOWN when properties parameter contains adUserData and adPersonalization with non-allowed values', () => { | ||
const result = populateConsentForGoogleDestinations({ | ||
adUserData: 'RANDOM', | ||
userDataConsent: 'RANDOM', | ||
personalizationConsent: 'RANDOM', | ||
}); | ||
expect(result).toEqual({}); | ||
expect(result).toEqual({ | ||
adPersonalization: 'UNKNOWN', | ||
adUserData: 'UNKNOWN', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.