You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/utils/__tests__/Loqate.test.ts
+31-5Lines changed: 31 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ describe('Loqate', () => {
41
41
expect({ Items }).toEqual(suggestions);
42
42
});
43
43
44
-
it('should throw loqate errors',async()=>{
44
+
it('should throw errors',async()=>{
45
45
server.use(errorHandler);
46
46
47
47
constloqate=Loqate.create('some-key');
@@ -54,10 +54,36 @@ describe('Loqate', () => {
54
54
limit: 10,
55
55
containerId: 'some-container-id',
56
56
});
57
-
}).rejects.toThrowError(
58
-
newError(
59
-
'Loqate error: {"Error":"2","Description":"Unknown key","Cause":"The key you are using to access the service was not found.","Resolution":"Please check that the key is correct. It should be in the form AA11-AA11-AA11-AA11."}'
60
-
)
57
+
}).rejects.toThrowError(newError('Unknown key'));
58
+
});
59
+
60
+
it('should throw loqate errors',async()=>{
61
+
server.use(errorHandler);
62
+
63
+
constloqate=Loqate.create('some-key');
64
+
65
+
leterror;
66
+
try{
67
+
awaitloqate.find({
68
+
text: 'some-text',
69
+
language: 'some-language',
70
+
countries: ['GB','US'],
71
+
limit: 10,
72
+
containerId: 'some-container-id',
73
+
});
74
+
}catch(e){
75
+
error=e;
76
+
}
77
+
78
+
expect(error).toEqual(newError('Unknown key'));
79
+
expect(JSON.stringify(error)).toEqual(
80
+
JSON.stringify({
81
+
Cause: 'The key you are using to access the service was not found.',
82
+
Description: 'Unknown key',
83
+
Error: '2',
84
+
Resolution:
85
+
'Please check that the key is correct. It should be in the form AA11-AA11-AA11-AA11.',
0 commit comments