Skip to content

Commit 9012d44

Browse files
committed
improved unit test
1 parent c0d3968 commit 9012d44

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

test/infrastructure/Listener.spec.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Listener', () => {
3838
});
3939

4040
describe('onStatusWhenAddressIsTheSame', () => {
41-
it('Should forward status', (done) => {
41+
it('Should forward status', () => {
4242

4343

4444
const errorEncodedAddress = '906415867F121D037AF447E711B0F5E4D52EBBF066D96860EB';
@@ -69,28 +69,23 @@ describe('Listener', () => {
6969

7070
listener.status(errorAddress).subscribe((transactionStatusError) => {
7171
reportedStatus.push(transactionStatusError);
72-
}, err => {
73-
done(err);
7472
});
7573

7674
listener.handleMessage(statusInfoErrorDTO, null);
7775

78-
setTimeout(() => {
79-
expect(reportedStatus.length).to.be.equal(1);
80-
const transactionStatusError = reportedStatus[0];
81-
expect(transactionStatusError.address).to.deep.equal(errorAddress);
82-
expect(transactionStatusError.hash).to.be.equal(statusInfoErrorDTO.hash);
83-
expect(transactionStatusError.status).to.be.equal(statusInfoErrorDTO.status);
84-
deepEqual(transactionStatusError.deadline.toDTO(), UInt64.fromNumericString(statusInfoErrorDTO.deadline).toDTO());
85-
done();
86-
}, 100)
76+
expect(reportedStatus.length).to.be.equal(1);
77+
const transactionStatusError = reportedStatus[0];
78+
expect(transactionStatusError.address).to.deep.equal(errorAddress);
79+
expect(transactionStatusError.hash).to.be.equal(statusInfoErrorDTO.hash);
80+
expect(transactionStatusError.status).to.be.equal(statusInfoErrorDTO.status);
81+
deepEqual(transactionStatusError.deadline.toDTO(), UInt64.fromNumericString(statusInfoErrorDTO.deadline).toDTO());
8782

8883

8984
});
9085
});
9186

9287
describe('onStatusWhenAddressIsDifferentAddress', () => {
93-
it('Should not forward status', (done) => {
88+
it('Should not forward status', () => {
9489

9590

9691
const errorEncodedAddress = '906415867F121D037AF447E711B0F5E4D52EBBF066D96860EB';
@@ -123,16 +118,11 @@ describe('Listener', () => {
123118

124119
listener.status(subscribedAddress).subscribe((transactionStatusError) => {
125120
reportedStatus.push(transactionStatusError);
126-
}, err => {
127-
done(err);
128121
});
129122

130123
listener.handleMessage(statusInfoErrorDTO, null);
131-
132-
setTimeout(() => {
133-
expect(reportedStatus.length).to.be.equal(0);
134-
done();
135-
}, 100)
124+
125+
expect(reportedStatus.length).to.be.equal(0);
136126

137127

138128
});

0 commit comments

Comments
 (0)