|
| 1 | +import { describe } from 'mocha'; |
| 2 | +import { createProblemReportMessage } from '../../src'; |
| 3 | +import { expect } from 'chai'; |
| 4 | + |
| 5 | +describe('Problem Report Handler', () => { |
| 6 | + it('should create problem report', () => { |
| 7 | + const example = `{ |
| 8 | + "typ": "application/iden3comm-plain-json", |
| 9 | + "type": "https://didcomm.org/report-problem/2.0/problem-report", |
| 10 | + "pthid": "5333207e-7338-4ab3-ac34-bf9a20dab6ab", |
| 11 | + "ack": [ |
| 12 | + "23b610b3-aec8-4d1c-8a75-3b22e5483fb0", |
| 13 | + "86fe7cc6-adcd-4530-8e07-92c060b427c8" |
| 14 | + ], |
| 15 | + "body": { |
| 16 | + "code": "e.me.remote-server-down", |
| 17 | + "comment": "Remote server {1} is down when connecting from {2}", |
| 18 | + "args": [ |
| 19 | + "https://remote-server.org", |
| 20 | + "https://my-server.org" |
| 21 | + ], |
| 22 | + "escalate_to": "[email protected]" |
| 23 | + }, |
| 24 | + "from": "did:polygonid:polygon:mumbai:2qJG6RYgN1u6v7JAYSdfixSwktnZ7hMzd4t21SCdNu", |
| 25 | + "to": "did:polygonid:polygon:mumbai:2qFroxB5kwgCxgVrNGUM6EW3khJgCdHHnKTr3VnTcp" |
| 26 | + }`; |
| 27 | + const problemReport = createProblemReportMessage( |
| 28 | + '5333207e-7338-4ab3-ac34-bf9a20dab6ab', |
| 29 | + 'e.me.remote-server-down', |
| 30 | + { |
| 31 | + from: 'did:polygonid:polygon:mumbai:2qJG6RYgN1u6v7JAYSdfixSwktnZ7hMzd4t21SCdNu', |
| 32 | + to: 'did:polygonid:polygon:mumbai:2qFroxB5kwgCxgVrNGUM6EW3khJgCdHHnKTr3VnTcp', |
| 33 | + args: ['https://remote-server.org', 'https://my-server.org'], |
| 34 | + |
| 35 | + ack: ['23b610b3-aec8-4d1c-8a75-3b22e5483fb0', '86fe7cc6-adcd-4530-8e07-92c060b427c8'], |
| 36 | + comment: 'Remote server {1} is down when connecting from {2}' |
| 37 | + } |
| 38 | + ); |
| 39 | + delete problemReport.id; |
| 40 | + const expected = JSON.parse(example); |
| 41 | + expect(problemReport).to.be.deep.equal(expected); |
| 42 | + }); |
| 43 | +}); |
0 commit comments