@@ -3,7 +3,7 @@ import { expect, use } from 'chai';
3
3
import datetime from 'chai-datetime' ;
4
4
import Store from './store' ;
5
5
import { CmpApi } from "@iabtcf/cmpapi" ;
6
- import { encodeConsentData } from "./cookie/cookie" ;
6
+ import { encodeConsentData , applyDecodeFix } from "./cookie/cookie" ;
7
7
import { GVL , TCModel } from "@iabtcf/core" ;
8
8
import {
9
9
PURPOSE_CONSENTS ,
@@ -22,6 +22,10 @@ use(datetime);
22
22
describe ( 'store' , ( ) => {
23
23
let cmpApi ;
24
24
25
+ beforeAll ( ( ) => {
26
+ applyDecodeFix ( ) ;
27
+ } ) ;
28
+
25
29
beforeEach ( ( ) => {
26
30
cmpApi = new CmpApi ( 280 , 2 ) ;
27
31
} ) ;
@@ -68,6 +72,7 @@ describe('store', () => {
68
72
tcModel . publisherLegitimateInterests . set ( PUBLISHER_LEGITIMATE_INTERESTS ) ;
69
73
tcModel . specialFeatureOptins . set ( SPECIAL_FEATURE_OPT_INS ) ;
70
74
75
+ const maxVendorId = Math . max ( ...Object . keys ( VENDOR_LIST . vendors ) ) ;
71
76
const encoded = encodeConsentData ( tcModel ) ;
72
77
73
78
const store = new Store ( {
@@ -81,8 +86,8 @@ describe('store', () => {
81
86
// check if consents were applied to current state of tcModel
82
87
expect ( store . tcModel . purposeConsents . maxId ) . to . equal ( Math . max ( ...PURPOSE_CONSENTS ) ) ;
83
88
expect ( store . tcModel . purposeLegitimateInterests . maxId ) . to . equal ( Math . max ( ...PURPOSE_LEGITIMATE_INTERESTS ) ) ;
84
- expect ( store . tcModel . vendorConsents . maxId ) . to . equal ( Math . max ( ... VENDOR_CONSENTS ) ) ;
85
- expect ( store . tcModel . vendorLegitimateInterests . maxId ) . to . equal ( Math . max ( ... VENDOR_LEGITIMATE_INTERESTS ) ) ;
89
+ expect ( store . tcModel . vendorConsents . maxId ) . to . equal ( maxVendorId ) ;
90
+ expect ( store . tcModel . vendorLegitimateInterests . maxId ) . to . equal ( maxVendorId ) ;
86
91
expect ( store . tcModel . publisherConsents . maxId ) . to . equal ( Math . max ( ...PUBLISHER_CONSENTS ) ) ;
87
92
expect ( store . tcModel . publisherLegitimateInterests . maxId ) . to . equal ( Math . max ( ...PUBLISHER_LEGITIMATE_INTERESTS ) ) ;
88
93
expect ( store . tcModel . specialFeatureOptins . maxId ) . to . equal ( Math . max ( ...SPECIAL_FEATURE_OPT_INS ) ) ;
@@ -140,6 +145,7 @@ describe('store', () => {
140
145
tcModel . publisherLegitimateInterests . set ( PUBLISHER_LEGITIMATE_INTERESTS ) ;
141
146
tcModel . specialFeatureOptins . set ( SPECIAL_FEATURE_OPT_INS ) ;
142
147
148
+ const maxVendorId = Math . max ( ...Object . keys ( VENDOR_LIST . vendors ) ) ;
143
149
const encoded = encodeConsentData ( tcModel ) ;
144
150
145
151
const store = new Store ( {
@@ -150,8 +156,8 @@ describe('store', () => {
150
156
store . setCmpApi ( cmpApi ) ;
151
157
store . updateVendorList ( vendorList ) ;
152
158
153
- expect ( store . tcModel . vendorConsents . size ) . to . equal ( 6 ) ;
154
- expect ( store . tcModel . vendorConsents . maxId ) . to . equal ( 10 ) ;
159
+ expect ( store . tcModel . vendorConsents . size ) . to . equal ( VENDOR_CONSENTS . length ) ;
160
+ expect ( store . tcModel . vendorConsents . maxId ) . to . equal ( maxVendorId ) ;
155
161
expect ( store . tcModel . vendorConsents . has ( 10 ) ) . to . be . true ;
156
162
expect ( store . tcModel . vendorLegitimateInterests . has ( 10 ) ) . to . be . false ;
157
163
done ( ) ;
@@ -173,6 +179,7 @@ describe('store', () => {
173
179
tcModel . publisherLegitimateInterests . set ( PUBLISHER_LEGITIMATE_INTERESTS ) ;
174
180
tcModel . specialFeatureOptins . set ( SPECIAL_FEATURE_OPT_INS ) ;
175
181
182
+ const maxVendorId = Math . max ( ...Object . keys ( VENDOR_LIST . vendors ) ) ;
176
183
const encoded = encodeConsentData ( tcModel ) ;
177
184
178
185
const store = new Store ( {
@@ -191,7 +198,7 @@ describe('store', () => {
191
198
}
192
199
} ) ;
193
200
194
- expect ( vendorsWithoutConsentCount ) . to . equal ( Object . keys ( VENDOR_LIST . vendors ) . length - 2 ) ;
201
+ expect ( vendorsWithoutConsentCount ) . to . equal ( maxVendorId - VENDOR_CONSENTS . length ) ;
195
202
expect ( persistedConsentData . vendorConsents . has ( 4 ) ) . to . be . true ;
196
203
expect ( persistedConsentData . vendorConsents . has ( 5 ) ) . to . be . false ;
197
204
0 commit comments