|
1 | | -import { getTreatmentsRequestPayloadToGateType } from './dispatch'; |
2 | 1 | import { |
3 | 2 | articleIdentifierIsAllowed, |
4 | 3 | buildGetTreatmentsRequestPayload, |
5 | 4 | buildGuUserTreatmentsEnvelop, |
6 | 5 | buildLogTreatmentInteractionRequestPayload, |
| 6 | + getTreatmentsRequestPayloadToGateType, |
7 | 7 | gtrpIsAuxiaAudienceShare, |
8 | 8 | gtrpIsGuardianAudienceShare, |
9 | 9 | gtrpIsStaffTestConditionShowDefaultGate, |
| 10 | + gtrpUserHasConsented, |
10 | 11 | guDismissibleUserTreatment, |
11 | 12 | guMandatoryUserTreatment, |
12 | 13 | isValidContentType, |
@@ -872,3 +873,45 @@ describe('staffTestConditionToDefaultGate', () => { |
872 | 873 | }; |
873 | 874 | expect(staffTestConditionToDefaultGate(payload4)).toBe('GuMandatory'); |
874 | 875 | }); |
| 876 | + |
| 877 | +describe('gtrpUserHasConsented', () => { |
| 878 | + const payload1: GetTreatmentsRequestPayload = { |
| 879 | + browserId: 'sample', |
| 880 | + isSupporter: false, |
| 881 | + dailyArticleCount: 3, |
| 882 | + articleIdentifier: 'sample: article identifier', |
| 883 | + editionId: 'UK', |
| 884 | + contentType: 'Article', |
| 885 | + sectionId: 'uk-news', |
| 886 | + tagIds: ['type/article'], |
| 887 | + gateDismissCount: 0, |
| 888 | + countryCode: 'GB', |
| 889 | + mvtId: 250001, |
| 890 | + should_show_legacy_gate_tmp: true, |
| 891 | + hasConsented: true, |
| 892 | + shouldServeDismissible: false, |
| 893 | + showDefaultGate: undefined, |
| 894 | + gateDisplayCount: 0, |
| 895 | + }; |
| 896 | + expect(gtrpUserHasConsented(payload1)).toBe(true); |
| 897 | + |
| 898 | + const payload2: GetTreatmentsRequestPayload = { |
| 899 | + browserId: 'sample', |
| 900 | + isSupporter: false, |
| 901 | + dailyArticleCount: 3, |
| 902 | + articleIdentifier: 'sample: article identifier', |
| 903 | + editionId: 'UK', |
| 904 | + contentType: 'Article', |
| 905 | + sectionId: 'uk-news', |
| 906 | + tagIds: ['type/article'], |
| 907 | + gateDismissCount: 0, |
| 908 | + countryCode: 'GB', |
| 909 | + mvtId: 450001, |
| 910 | + should_show_legacy_gate_tmp: true, |
| 911 | + hasConsented: false, |
| 912 | + shouldServeDismissible: true, |
| 913 | + showDefaultGate: 'true', |
| 914 | + gateDisplayCount: 0, |
| 915 | + }; |
| 916 | + expect(gtrpUserHasConsented(payload2)).toBe(false); |
| 917 | +}); |
0 commit comments