Skip to content

Commit c34bcc7

Browse files
committed
add tests for wildcard blacklist paths
1 parent 1761e48 commit c34bcc7

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

packages/log/src/LogExport.test.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,94 @@ describe('getReduxDataString', () => {
8787
);
8888
expect(result).toBe(expected);
8989
});
90+
91+
it('should handle wildcards in blacklist paths', () => {
92+
const reduxData = {
93+
key1: 'not blacklisted',
94+
key2: {
95+
keyA: {
96+
key1: 'blacklisted',
97+
},
98+
keyB: {
99+
key1: 'blacklisted',
100+
},
101+
keyC: {
102+
key1: 'blacklisted',
103+
},
104+
},
105+
};
106+
const result = getReduxDataString(reduxData, [['key2', '*', 'key1']]);
107+
const expected = JSON.stringify(
108+
{
109+
key1: 'not blacklisted',
110+
key2: {
111+
keyA: {},
112+
keyB: {},
113+
keyC: {},
114+
},
115+
},
116+
null,
117+
2
118+
);
119+
expect(result).toBe(expected);
120+
});
121+
122+
it('should handle nested wildcards in blacklist paths', () => {
123+
const reduxData = {
124+
key1: 'not blacklisted',
125+
key2: {
126+
keyA: {
127+
key1: 'blacklisted',
128+
key2: {
129+
key3: 'blacklisted',
130+
},
131+
},
132+
keyB: {
133+
key1: 'blacklisted',
134+
key2: {
135+
key3: 'blacklisted',
136+
key4: 'blacklisted',
137+
},
138+
},
139+
},
140+
};
141+
const result = getReduxDataString(reduxData, [['key2', '*', '*']]);
142+
const expected = JSON.stringify(
143+
{
144+
key1: 'not blacklisted',
145+
key2: {
146+
keyA: {},
147+
keyB: {},
148+
},
149+
},
150+
null,
151+
2
152+
);
153+
expect(result).toBe(expected);
154+
});
155+
156+
it('should handle wildcard blacklist paths with no matches', () => {
157+
const reduxData = {
158+
key1: 'not blacklisted',
159+
key2: {
160+
keyA: {
161+
key1: 'not blacklisted',
162+
key2: {
163+
key3: 'not blacklisted',
164+
},
165+
},
166+
},
167+
};
168+
const result = getReduxDataString(reduxData, [['*', '*', '*', '*', '*']]); // Matching more than the depth of the object
169+
const expected = JSON.stringify(reduxData, null, 2);
170+
expect(result).toBe(expected);
171+
});
172+
173+
it('root wildcard should blacklist all', () => {
174+
const reduxData = {
175+
key1: 'should not be blacklisted',
176+
};
177+
const result = getReduxDataString(reduxData, [['*']]);
178+
expect(result).toBe('{}');
179+
});
90180
});

0 commit comments

Comments
 (0)