Skip to content

Commit 449b21a

Browse files
committed
test: add case for handling nested empty JSON objects in getProtectedData
1 parent fe631ef commit 449b21a

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

packages/sdk/tests/e2e/dataProtectorCore/getProtectedData.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,35 @@ describe('dataProtectorCore.getProtectedData()', () => {
106106
);
107107
});
108108

109+
describe("When calling getProtectedData for a ProtectedData that contains nested empty JSON objects", () => {
110+
it(
111+
'should return the protectedData without the field corresponding to the nested empty JSON objects',
112+
async () => {
113+
// --- GIVEN
114+
const createdProtectedData = await dataProtectorCore.protectData({
115+
data: { email: '[email protected]', tag: { size: 10, emptyObject: {} } },
116+
name: 'test getProtectedData',
117+
});
118+
await waitForSubgraphIndexing();
119+
120+
// --- WHEN
121+
const result = await dataProtectorCore.getProtectedData({
122+
protectedDataAddress: createdProtectedData.address,
123+
});
124+
125+
// --- THEN
126+
expect(result.length).toEqual(1);
127+
expect(result[0].name).toEqual('test getProtectedData');
128+
expect(result[0].schema).toEqual({
129+
email: 'string',
130+
tag: {
131+
size: 'f64',
132+
},
133+
});
134+
}
135+
);
136+
});
137+
109138
describe('When calling getProtectedData with a specific owner', () => {
110139
it(
111140
"should return only this owner's protectedData",

packages/sdk/tests/e2e/dataProtectorCore/protectData.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ describe('dataProtectorCore.protectData()', () => {
5151
binary: {
5252
data: {
5353
pngImage,
54-
size: 10,
5554
},
56-
emptyObject:{}
5755
},
5856
},
5957
},
@@ -77,7 +75,6 @@ describe('dataProtectorCore.protectData()', () => {
7775
binary: {
7876
data: {
7977
pngImage: 'image/png',
80-
size: 'f64',
8178
},
8279
},
8380
},

0 commit comments

Comments
 (0)