Skip to content

Commit 9c100a0

Browse files
committed
added more tests
1 parent 9690528 commit 9c100a0

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

test/response.spec.ts

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ describe('Single object', async () => {
2121
...sampleFile,
2222
},
2323
};
24+
const nestedLevelTwo = {
25+
name: 'some name',
26+
data: {
27+
images: {
28+
...sampleImage,
29+
...sampleFile,
30+
},
31+
},
32+
};
2433

2534
const updatedSampleImage = {
2635
type: 'png',
@@ -38,15 +47,24 @@ describe('Single object', async () => {
3847
...updatedSampleImage,
3948
},
4049
};
50+
const updatedNestedLevelTwo = {
51+
name: 'some name',
52+
data: {
53+
images: {
54+
...updatedSampleFile,
55+
...updatedSampleImage,
56+
},
57+
},
58+
};
4159

42-
it('should update the key for a single value response', async () => {
60+
it('should update the keys for a single value response', async () => {
4361
const empty = await server.inject({
4462
method: 'POST',
4563
url: '/lenses',
4664
payload: sampleImage,
4765
});
4866

49-
expect(empty.result).to.contains(updatedSampleImage);
67+
expect(empty.result).to.eql(updatedSampleImage);
5068

5169
const fileImage = await server.inject({
5270
method: 'POST',
@@ -63,7 +81,7 @@ describe('Single object', async () => {
6381
});
6482
});
6583

66-
it('should update the key for a array of values in response', async () => {
84+
it('should update the keys for a array of values in response', async () => {
6785
const response = await server.inject({
6886
method: 'POST',
6987
url: '/lenses',
@@ -72,9 +90,31 @@ describe('Single object', async () => {
7290
const result = response.result as any[];
7391

7492
expect(result.length).to.eql(4);
75-
expect(result[0]).to.contains(updatedSampleImage);
76-
expect(result[1]).to.contains(updatedSampleFile);
77-
expect(result[2]).to.contains(updatedSampleImage);
78-
expect(result[3]).to.contains(updatedSampleFile);
93+
expect(result).to.eql([
94+
updatedSampleImage,
95+
updatedSampleFile,
96+
updatedSampleImage,
97+
updatedSampleFile,
98+
]);
99+
});
100+
101+
it('should update the keys for a nested object in response', async () => {
102+
const response = await server.inject({
103+
method: 'POST',
104+
url: '/nested/level-one',
105+
payload: nestedLevelOne,
106+
});
107+
const result = response.result;
108+
expect(result).to.eql(updatedNestedLevelOne);
109+
});
110+
111+
it('should update the keys for a nested two layers object in response', async () => {
112+
const response = await server.inject({
113+
method: 'POST',
114+
url: '/nested/level-two',
115+
payload: nestedLevelTwo,
116+
});
117+
const result = response.result;
118+
expect(result).to.eql(updatedNestedLevelTwo);
79119
});
80120
});

0 commit comments

Comments
 (0)