| @@ 44-65 (lines=22) @@ | ||
| 41 | assert.include(logger.stack.error[0].error, error.toString()); |
|
| 42 | }); |
|
| 43 | ||
| 44 | test('Negative: function return rejected promise', async function () { |
|
| 45 | const logger = new Logger(); |
|
| 46 | const decorator = new Decorator({ logger }); |
|
| 47 | ||
| 48 | const error = new Error('mill share from cattle muscle musical structure progress'); |
|
| 49 | const decorated = decorator()(function double() { |
|
| 50 | return new Promise((res, rej) => { |
|
| 51 | setTimeout(() => { |
|
| 52 | return rej(error); |
|
| 53 | }, 50); |
|
| 54 | }); |
|
| 55 | }); |
|
| 56 | ||
| 57 | try { |
|
| 58 | await decorated(); |
|
| 59 | } catch (error_) { |
|
| 60 | assert.equal(error_.toString(), error.toString()); |
|
| 61 | } |
|
| 62 | ||
| 63 | assert.isEmpty(logger.stack.verbose); |
|
| 64 | assert.include(logger.stack.error[0].error, error.toString()); |
|
| 65 | }); |
|
| 66 | ||
| 67 | function errored(err) { |
|
| 68 | throw err; |
|
| @@ 21-42 (lines=22) @@ | ||
| 18 | assert.include(logger.stack.error[0].error, error.toString()); |
|
| 19 | }); |
|
| 20 | ||
| 21 | test('Negative: async function throws error', async function () { |
|
| 22 | const logger = new Logger(); |
|
| 23 | const decorator = new Decorator({ logger }); |
|
| 24 | ||
| 25 | const error = new Error('care toy degree shirt heart'); |
|
| 26 | const decorated = decorator()(async function double() { |
|
| 27 | await new Promise((res, rej) => { |
|
| 28 | setTimeout(() => { |
|
| 29 | return rej(error); |
|
| 30 | }, 50); |
|
| 31 | }); |
|
| 32 | }); |
|
| 33 | ||
| 34 | try { |
|
| 35 | await decorated(); |
|
| 36 | } catch (error_) { |
|
| 37 | assert.equal(error_.toString(), error.toString()); |
|
| 38 | } |
|
| 39 | ||
| 40 | assert.isEmpty(logger.stack.verbose); |
|
| 41 | assert.include(logger.stack.error[0].error, error.toString()); |
|
| 42 | }); |
|
| 43 | ||
| 44 | test('Negative: function return rejected promise', async function () { |
|
| 45 | const logger = new Logger(); |
|