Skip to content

Commit

Permalink
Add tests for source-side set sizes (WICG#1332)
Browse files Browse the repository at this point in the history
In preparation for addressing WICG#1321.
  • Loading branch information
apasel422 authored Jun 11, 2024
1 parent 05c58f8 commit 29dcd98
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion ts/src/header-validator/source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,31 @@ const testCases: TestCase[] = [
},
],
},
{
name: 'destination-list-empty',
json: `{"destination": []}`,
expectedErrors: [
{
path: ['destination'],
msg: 'length must be in the range [1, 3]',
},
],
},
{
name: 'destination-list-too-long',
json: `{"destination": [
"https://a.test",
"https://b.test/1",
"https://b.test/2",
"https://c.test/3"
]}`,
expectedErrors: [
{
path: ['destination'],
msg: 'length must be in the range [1, 3]',
},
],
},

{
name: 'filter-data-wrong-type',
Expand Down Expand Up @@ -350,7 +375,7 @@ const testCases: TestCase[] = [
name: 'filter-data-too-many-values',
json: JSON.stringify({
destination: 'https://a.test',
filter_data: { a: Array.from({ length: 51 }, (_, i) => `${i}`) },
filter_data: { a: Array.from({ length: 51 }, () => '') },
}),
expectedErrors: [
{
Expand Down Expand Up @@ -2079,6 +2104,19 @@ const testCases: TestCase[] = [
},
],
},
{
name: 'trigger-data-too-many-within',
json: JSON.stringify({
destination: 'https://a.test',
trigger_data: Array.from({ length: 33 }, () => 0),
}),
expectedErrors: [
{
path: ['trigger_data'],
msg: 'length must be in the range [0, 32]',
},
],
},
{
name: 'trigger-data-duplicated-across',
json: `{
Expand Down

0 comments on commit 29dcd98

Please sign in to comment.