Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export class CompressedBase64UrlEncoder extends AbstractBase64UrlEncoder {

// Overriden
protected pad(bitString: string): string {
while (bitString.length % 8 > 0) {
bitString += "0";
}
Comment on lines -16 to -18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for spec compatibility because one base64 character represents 8-bits of data.

while (bitString.length % 6 > 0) {
bitString += "0";
}
Expand Down
38 changes: 19 additions & 19 deletions modules/cmpapi/test/GppModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("manifest.GppModel", (): void => {

let gppString = gppModel.encode();
expect(gppString).to.eql(
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA~1---~BAAAAAAAAABA.QA~BAAAAABA.QA~BAAAABA~BAAAAEA.QA~BAAAAAQA~BAAAAAEA.QA~BAAAAABA~BAAAAABA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAQA.QA~BAAAAABA.QA~BAAAAAAAQA.QA~BAAAAAQA.QA"
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA~1---~BAAAAAAAAABA.Q~BAAAAABA.Q~BAAAABA~BAAAAEA.Q~BAAAAAQ~BAAAAAEA.Q~BAAAAABA~BAAAAABA.Q~BAAAAAABA.Q~BAAAAAQ.Q~BAAAAAABA.Q~BAAAAAQ.Q~BAAAAAQ.Q~BAAAAABA.Q~BAAAAAAAQ.Q~BAAAAAQ.Q"
);
});

Expand All @@ -126,7 +126,7 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.hasSection("tcfcav1")).to.eql(false);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBABTA~1YNN");
expect(gppString).to.eql("DBABT~1YNN");

expect(gppModel.getSectionIds()).to.eql([6]);
expect(gppModel.hasSection("uspv1")).to.eql(true);
Expand Down Expand Up @@ -158,7 +158,7 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.hasSection("tcfcav1")).to.eql(false);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBABMA~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA");
expect(gppString).to.eql("DBABM~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA");

expect(gppString.split("~").length).to.eql(2);

Expand Down Expand Up @@ -201,7 +201,7 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.hasSection("tcfcav1")).to.eql(false);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBACNYA~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~1YNN");
expect(gppString).to.eql("DBACNY~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~1YNN");

expect(gppString.split("~").length).to.eql(3);

Expand Down Expand Up @@ -385,7 +385,7 @@ describe("manifest.GppModel", (): void => {

let gppString = gppModel.encode();
expect(gppString).to.eql(
"DBACOeA~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAAA.fHHHA4444ao~1YNN"
"DBACOe~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAA.fHHHA4444ao~1YNN"
);

expect(gppString.split("~").length).to.eql(4);
Expand All @@ -402,7 +402,7 @@ describe("manifest.GppModel", (): void => {

it("should decode defaults from all sections", (): void => {
let gppString =
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA~1---~BAAAAAAAAABA.QA~BAAAAABA.QA~BAAAABA~BAAAAEA.QA~BAAAAAQA~BAAAAAEA.QA~BAAAAABA~BAAAAABA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAQA.QA~BAAAAABA.QA~BAAAAAAAQA.QA~BAAAAAQA.QA";
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA~1---~BAAAAAAAAABA.Q~BAAAAABA.Q~BAAAABA~BAAAAEA.Q~BAAAAAQ~BAAAAAEA.Q~BAAAAABA~BAAAAABA.Q~BAAAAAABA.Q~BAAAAAQ.Q~BAAAAAABA.Q~BAAAAAQ.Q~BAAAAAQ.Q~BAAAAABA.Q~BAAAAAAAQ.Q~BAAAAAQ.Q";
let gppModel = new GppModel(gppString);

expect(gppModel.hasSection("tcfeuv2")).to.eql(true);
Expand All @@ -427,7 +427,7 @@ describe("manifest.GppModel", (): void => {
});

it("should decode uspv1 section", (): void => {
let gppString = "DBABTA~1YNN";
let gppString = "DBABT~1YNN";
let gppModel = new GppModel(gppString);

expect(gppModel.getSectionIds()).to.eql([6]);
Expand All @@ -441,7 +441,7 @@ describe("manifest.GppModel", (): void => {
});

it("should decode tcfeuv2 sections", (): void => {
let gppString = "DBABMA~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA";
let gppString = "DBABM~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA";
let gppModel = new GppModel(gppString);

expect(gppModel.getSectionIds()).to.eql([2]);
Expand All @@ -465,7 +465,7 @@ describe("manifest.GppModel", (): void => {
});

it("should decode uspv1 and tcfeuv2 sections", (): void => {
let gppString = "DBACNYA~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~1YNN";
let gppString = "DBACNY~CPSG_8APSG_8ANwAAAENAwCAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~1YNN";
let gppModel = new GppModel(gppString);

expect(gppModel.getSectionIds()).to.eql([2, 6]);
Expand Down Expand Up @@ -665,7 +665,7 @@ describe("manifest.GppModel", (): void => {
gppModel.setFieldValue("tcfeuv2", "LastUpdated", utcDateTime);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOAAAABAAAAA.QAAA.IAAA");
expect(gppString).to.eql("DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOAAAABAAAAA.QAAA.IAAA");
});

it("should encode tcfeuv2 vendor consents [29]", (): void => {
Expand All @@ -675,7 +675,7 @@ describe("manifest.GppModel", (): void => {
gppModel.setFieldValue("tcfeuv2", "LastUpdated", utcDateTime);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOwAQAOgAAAA.QAAA.IAAA");
expect(gppString).to.eql("DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOwAQAOgAAAA.QAAA.IAAA");
});

it("should encode tcfeuv2 vendor consents [1, 173, 722]", (): void => {
Expand All @@ -685,25 +685,25 @@ describe("manifest.GppModel", (): void => {
gppModel.setFieldValue("tcfeuv2", "LastUpdated", utcDateTime);

let gppString = gppModel.encode();
expect(gppString).to.eql("DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAFpQAwAAgCtAWkAAAAAAA.QAAA.IAAA");
expect(gppString).to.eql("DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAFpQAwAAgCtAWkAAAAAAA.QAAA.IAAA");
});

it("should decode tcfeuv2 vendor consents [28]", (): void => {
let gppString = "DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOAAAABAAAAA.QAAA.IAAA";
let gppString = "DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOAAAABAAAAA.QAAA.IAAA";
let gppModel = new GppModel(gppString);

expect(gppModel.getFieldValue("tcfeuv2", "VendorConsents")).to.eql([28]);
});

it("should decode tcfeuv2 vendor consents [29]", (): void => {
let gppString = "DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOwAQAOgAAAA.QAAA.IAAA";
let gppString = "DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAOwAQAOgAAAA.QAAA.IAAA";
let gppModel = new GppModel(gppString);

expect(gppModel.getFieldValue("tcfeuv2", "VendorConsents")).to.eql([29]);
});

it("should decode tcfeuv2 vendor consents [1, 173, 722]", (): void => {
let gppString = "DBABMA~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAFpQAwAAgCtAWkAAAAAAA.QAAA.IAAA";
let gppString = "DBABM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAFpQAwAAgCtAWkAAAAAAA.QAAA.IAAA";
let gppModel = new GppModel(gppString);

expect(gppModel.getFieldValue("tcfeuv2", "VendorConsents")).to.eql([1, 173, 722]);
Expand Down Expand Up @@ -816,15 +816,15 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.encode()).to.eq("DBAA");

gppModel.setFieldValue("uspv1", UspV1Field.NOTICE, "Y");
expect(gppModel.encode()).to.eq("DBABTA~1Y--");
expect(gppModel.encode()).to.eq("DBABT~1Y--");
});

it("should handle empty string constructor", (): void => {
let gppModel = new GppModel("");
expect(gppModel.encode()).to.eq("DBAA");

gppModel.setFieldValue("uspv1", UspV1Field.NOTICE, "Y");
expect(gppModel.encode()).to.eq("DBABTA~1Y--");
expect(gppModel.encode()).to.eq("DBABT~1Y--");
});

it("should decode null", (): void => {
Expand All @@ -835,7 +835,7 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.encode()).to.eq("DBAA");

gppModel.setFieldValue("uspv1", UspV1Field.NOTICE, "Y");
expect(gppModel.encode()).to.eq("DBABTA~1Y--");
expect(gppModel.encode()).to.eq("DBABT~1Y--");
});

it("should decode empty string", (): void => {
Expand All @@ -846,7 +846,7 @@ describe("manifest.GppModel", (): void => {
expect(gppModel.encode()).to.eq("DBAA");

gppModel.setFieldValue("uspv1", UspV1Field.NOTICE, "Y");
expect(gppModel.encode()).to.eq("DBABTA~1Y--");
expect(gppModel.encode()).to.eq("DBABT~1Y--");
});

it("should fail to decode missing sections", (): void => {
Expand Down
18 changes: 14 additions & 4 deletions modules/cmpapi/test/encoder/section/HeaderV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,38 @@ describe("manifest.section.HeaderV1", (): void => {
expect(headerV1.encode()).to.eql("DBAA");
});

it("should encode section ids [2] to DBABMA", (): void => {
it("should encode section ids [2] to DBABM", (): void => {
let headerV1 = new HeaderV1();
headerV1.setFieldValue("SectionIds", [2]);
expect(headerV1.encode()).to.eql("DBABMA");
expect(headerV1.encode()).to.eql("DBABM");
});

it("should encode section ids [2,6] to DBACNYA", (): void => {
it("should encode section ids [2,6] to DBACNY", (): void => {
let headerV1 = new HeaderV1();
headerV1.setFieldValue("SectionIds", [2, 6]);
expect(headerV1.encode()).to.eql("DBACNYA");
expect(headerV1.encode()).to.eql("DBACNY");
});

it("should decode DBAA to section ids []", (): void => {
let headerV1 = new HeaderV1("DBAA");
expect(headerV1.getFieldValue("SectionIds")).to.eql([]);
});

it("should decode DBABM to section ids [2]", (): void => {
let headerV1 = new HeaderV1("DBABM");
expect(headerV1.getFieldValue("SectionIds")).to.eql([2]);
});

it("should decode DBABMA to section ids [2]", (): void => {
let headerV1 = new HeaderV1("DBABMA");
expect(headerV1.getFieldValue("SectionIds")).to.eql([2]);
});

it("should decode DBACNY to section ids [2, 6]", (): void => {
let headerV1 = new HeaderV1("DBACNY");
expect(headerV1.getFieldValue("SectionIds")).to.eql([2, 6]);
});

it("should decode DBACNYA to section ids [2, 6]", (): void => {
let headerV1 = new HeaderV1("DBACNYA");
expect(headerV1.getFieldValue("SectionIds")).to.eql([2, 6]);
Expand Down
28 changes: 14 additions & 14 deletions modules/cmpapi/test/encoder/section/TcfCaV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { TcfCaV1 } from "../../../src/encoder/section/TcfCaV1";
import { RangeEntry } from "../../../src/encoder/datatype";

describe("manifest.section.TcfCaV1", (): void => {
it("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA", (): void => {
it("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1();
tcfCaV1.setFieldValue(TcfCaV1Field.CREATED, new Date("2022-01-01T00:00:00Z"));
tcfCaV1.setFieldValue(TcfCaV1Field.LAST_UPDATED, new Date("2022-01-01T00:00:00Z"));
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA");
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA");
});

it("should encode to BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAAA.fHHHA4444ao", (): void => {
it("should encode to BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAA.fHHHA4444ao", (): void => {
let tcfCaV1 = new TcfCaV1();

tcfCaV1.setFieldValue(TcfCaV1Field.CMP_ID, 50);
Expand Down Expand Up @@ -145,27 +145,27 @@ describe("manifest.section.TcfCaV1", (): void => {
tcfCaV1.setFieldValue(TcfCaV1Field.CREATED, new Date("2022-01-01T00:00:00Z"));
tcfCaV1.setFieldValue(TcfCaV1Field.LAST_UPDATED, new Date("2022-01-01T00:00:00Z"));

expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAAA.fHHHA4444ao");
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAA.fHHHA4444ao");
});

it("should encode to BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA.IAGO5wAA", (): void => {
it("should encode to BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA.IAGO5wAA", (): void => {
let tcfCaV1 = new TcfCaV1();
tcfCaV1.setFieldValue(TcfCaV1Field.DISCLOSED_VENDORS, [1, 2, 3, 5, 6, 7, 10, 11, 12]);
tcfCaV1.setFieldValue(TcfCaV1Field.CREATED, new Date("2022-01-01T00:00:00Z"));
tcfCaV1.setFieldValue(TcfCaV1Field.LAST_UPDATED, new Date("2022-01-01T00:00:00Z"));
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA.IAGO5wAA");
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA.IAGO5wAA");
});

it("should encode to BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJA.YAAAAAAAAAA", (): void => {
it("should encode to BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJ.YAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1();
tcfCaV1.setFieldValue(TcfCaV1Field.PUB_RESTRICTIONS, [new RangeEntry(1, 1, [1, 2, 3, 5, 6, 7, 9])]);
tcfCaV1.setFieldValue(TcfCaV1Field.CREATED, new Date("2022-01-01T00:00:00Z"));
tcfCaV1.setFieldValue(TcfCaV1Field.LAST_UPDATED, new Date("2022-01-01T00:00:00Z"));
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJA.YAAAAAAAAAA");
expect(tcfCaV1.encode()).to.eql("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJ.YAAAAAAAAA");
});

it("should decode BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA");
it("should decode BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAA.YAAAAAAAAA");

expect(tcfCaV1.getFieldValue(TcfCaV1Field.CMP_ID)).to.eql(0);
expect(tcfCaV1.getFieldValue(TcfCaV1Field.CMP_VERSION)).to.eql(0);
Expand Down Expand Up @@ -301,8 +301,8 @@ describe("manifest.section.TcfCaV1", (): void => {
expect(tcfCaV1.getFieldValue(TcfCaV1Field.PUB_PURPOSES_SEGMENT_TYPE)).to.eql(3);
});

it("should decode BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAAA.fHHHA4444ao", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAAA.fHHHA4444ao");
it("should decode BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAA.fHHHA4444ao", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAyACAENGdCgf_gfgAfgfgBgABABAAABAB4AACACAA.fHHHA4444ao");

expect(tcfCaV1.getFieldValue(TcfCaV1Field.CMP_ID)).to.eql(50);
expect(tcfCaV1.getFieldValue(TcfCaV1Field.CMP_VERSION)).to.eql(2);
Expand Down Expand Up @@ -438,8 +438,8 @@ describe("manifest.section.TcfCaV1", (): void => {
expect(tcfCaV1.getFieldValue(TcfCaV1Field.PUB_PURPOSES_SEGMENT_TYPE)).to.eql(3);
});

it("should decode BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJA.YAAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJA.YAAAAAAAAAA");
it("should decode BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJ.YAAAAAAAAA", (): void => {
let tcfCaV1 = new TcfCaV1("BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAACCgBwABAAOAAoADgAJ.YAAAAAAAAA");

expect(tcfCaV1.getFieldValue(TcfCaV1Field.PUB_RESTRICTIONS).length).to.eql(1);
expect(tcfCaV1.getFieldValue(TcfCaV1Field.PUB_RESTRICTIONS)[0].key).to.eql(1);
Expand Down
30 changes: 24 additions & 6 deletions modules/cmpapi/test/encoder/section/UsCa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { UsCaField } from "../../../src/encoder/field/UsCaField";
import { UsCa } from "../../../src/encoder/section/UsCa";

describe("manifest.section.UsCa", (): void => {
it("should encode default to BAAAAABA.QA", (): void => {
it("should encode default to BAAAAABA.Q", (): void => {
let usCa = new UsCa();
expect(usCa.encode()).to.eql("BAAAAABA.QA");
expect(usCa.encode()).to.eql("BAAAAABA.Q");
});

it("should encode to BVWSSSVY.YA", (): void => {
it("should encode to BVWSSSVY.Y", (): void => {
let usCa = new UsCa();

usCa.setFieldValue(UsCaField.SALE_OPT_OUT_NOTICE, 1);
Expand All @@ -24,7 +24,7 @@ describe("manifest.section.UsCa", (): void => {
usCa.setFieldValue(UsCaField.MSPA_SERVICE_PROVIDER_MODE, 2);
usCa.setFieldValue(UsCaField.GPC, true);

expect(usCa.encode()).to.eql("BVWSSSVY.YA");
expect(usCa.encode()).to.eql("BVWSSSVY.Y");
});

it("should encode to BAAAAABA", (): void => {
Expand Down Expand Up @@ -81,6 +81,24 @@ describe("manifest.section.UsCa", (): void => {
}).to.throw();
});

it("should decode BVWSSSVY.Y", (): void => {
let usCa = new UsCa("BVWSSSVY.Y");

expect(1, usCa.getFieldValue(UsCaField.SALE_OPT_OUT_NOTICE));
expect(1, usCa.getFieldValue(UsCaField.SHARING_OPT_OUT_NOTICE));
expect(1, usCa.getFieldValue(UsCaField.SENSITIVE_DATA_LIMIT_USE_NOTICE));
expect(1, usCa.getFieldValue(UsCaField.SALE_OPT_OUT));
expect(1, usCa.getFieldValue(UsCaField.SHARING_OPT_OUT));
expect([2, 1, 0, 2, 1, 0, 2, 1, 0], usCa.getFieldValue(UsCaField.SENSITIVE_DATA_PROCESSING));
expect([2, 1], usCa.getFieldValue(UsCaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS));
expect(1, usCa.getFieldValue(UsCaField.PERSONAL_DATA_CONSENTS));
expect(1, usCa.getFieldValue(UsCaField.MSPA_COVERED_TRANSACTION));
expect(1, usCa.getFieldValue(UsCaField.MSPA_OPT_OUT_OPTION_MODE));
expect(2, usCa.getFieldValue(UsCaField.MSPA_SERVICE_PROVIDER_MODE));
expect(true, usCa.getFieldValue(UsCaField.GPC));
expect(true, usCa.getFieldValue(UsCaField.GPC_SEGMENT_INCLUDED));
});

it("should decode BVWSSSVY.YA", (): void => {
let usCa = new UsCa("BVWSSSVY.YA");

Expand All @@ -99,8 +117,8 @@ describe("manifest.section.UsCa", (): void => {
expect(true, usCa.getFieldValue(UsCaField.GPC_SEGMENT_INCLUDED));
});

it("should decode BAAAAAAA", (): void => {
let usCa = new UsCa("BbYbGwXY.YA");
it("should decode BbYbGwXY.Y", (): void => {
let usCa = new UsCa("BbYbGwXY.Y");

expect(1, usCa.getFieldValue(UsCaField.SALE_OPT_OUT_NOTICE));
expect(2, usCa.getFieldValue(UsCaField.SHARING_OPT_OUT_NOTICE));
Expand Down
Loading