UNPKG

3.27 kBJavaScriptView Raw
1import { errors } from '../src';
2
3describe('errors', function() {
4 describe('.CraftAiError', function() {
5 const e = new errors.CraftAiError('test');
6
7 it('specializes Error', function() {
8 expect(e).to.be.an.instanceof(Error);
9 });
10
11 it('has a "message" property', function() {
12 expect(e).to.have.property('message', 'test');
13 });
14 });
15
16 describe('.CraftAiUnknownError', function() {
17 const e = new errors.CraftAiUnknownError();
18
19 it('specializes Error', function() {
20 expect(e).to.be.an.instanceof(Error);
21 });
22
23 it('specializes errors.CraftAiError', function() {
24 expect(e).to.be.an.instanceof(errors.CraftAiError);
25 });
26
27 it('has a default "message" property', function() {
28 expect(e).to.have.property('message', 'Unknown error occured');
29 });
30 });
31
32 describe('.CraftAiNetworkError', function() {
33 const e = new errors.CraftAiNetworkError();
34
35 it('specializes Error', function() {
36 expect(e).to.be.an.instanceof(Error);
37 });
38
39 it('specializes errors.CraftAiError', function() {
40 expect(e).to.be.an.instanceof(errors.CraftAiError);
41 });
42
43 it('has a default "message" property', function() {
44 expect(e).to.have.property('message', 'Network issue, see err.more for details');
45 });
46 });
47
48 describe('.CraftAiCredentialsError', function() {
49 const e = new errors.CraftAiCredentialsError();
50
51 it('specializes Error', function() {
52 expect(e).to.be.an.instanceof(Error);
53 });
54
55 it('specializes errors.CraftAiError', function() {
56 expect(e).to.be.an.instanceof(errors.CraftAiError);
57 });
58
59 it('has a default "message" property', function() {
60 expect(e).to.have.property('message', 'Credentials error, make sure the given token is valid');
61 });
62 });
63
64 describe('.CraftAiInternalError', function() {
65 const e = new errors.CraftAiInternalError();
66
67 it('specializes Error', function() {
68 expect(e).to.be.an.instanceof(Error);
69 });
70
71 it('specializes errors.CraftAiError', function() {
72 expect(e).to.be.an.instanceof(errors.CraftAiError);
73 });
74
75 it('has a default "message" property', function() {
76 expect(e).to.have.property('message', 'Internal Error, see err.more for details');
77 });
78 });
79
80 describe('.CraftAiBadRequestError', function() {
81 const e = new errors.CraftAiBadRequestError();
82
83 it('specializes Error', function() {
84 expect(e).to.be.an.instanceof(Error);
85 });
86
87 it('specializes errors.CraftAiError', function() {
88 expect(e).to.be.an.instanceof(errors.CraftAiError);
89 });
90
91 it('has a default "message" property', function() {
92 expect(e).to.have.property('message', 'Bad Request, see err.more for details');
93 });
94 });
95
96 describe('.CraftAiLongRequestTimeOutError', function() {
97 const e = new errors.CraftAiLongRequestTimeOutError();
98
99 it('specializes Error', function() {
100 expect(e).to.be.an.instanceof(Error);
101 });
102
103 it('specializes errors.CraftAiError', function() {
104 expect(e).to.be.an.instanceof(errors.CraftAiError);
105 });
106
107 it('has a default "message" property', function() {
108 expect(e).to.have.property('message', 'Request timed out because the computation is not finished, please try again');
109 });
110 });
111});