Skip to content

Commit 3307204

Browse files
feat(responsetemplate): add isPending method
centralnicgroup-public/hexonet-api-documentation#1
1 parent a5e07d2 commit 3307204

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

dist/responsetemplate.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export declare class ResponseTemplate {
1111
isError(): boolean;
1212
isSuccess(): boolean;
1313
isTmpError(): boolean;
14+
isPending(): boolean;
1415
}

dist/responsetemplate.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/responsetemplate.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/responsetemplate.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,12 @@ export class ResponseTemplate {
106106
public isTmpError(): boolean {
107107
return this.hash.CODE.charAt(0) === "4";
108108
}
109+
110+
/**
111+
* Check if current operation is returned as pending
112+
* @returns boolean result
113+
*/
114+
public isPending(): boolean {
115+
return (this.hash.hasOwnProperty("PENDING")) ? this.hash.PENDING === "1" : false;
116+
}
109117
}

test/responsetemplate.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,16 @@ describe('ResponseTemplate class', function () {
4848
expect(tpl.getRuntime()).to.equal(0.12)
4949
})
5050
})
51+
52+
describe('#.isPending', function () {
53+
it('check return value [n/a in API response]', function () {
54+
const tpl = new ResponseTemplate('')
55+
expect(tpl.isPending()).to.be.false()
56+
})
57+
58+
it('check return value [in API response]', function () {
59+
const tpl = new ResponseTemplate('[RESPONSE]\r\ncode=200\r\ndescription=Command completed successfully\r\npending=1\r\nEOF\r\n')
60+
expect(tpl.isPending()).to.be.true()
61+
})
62+
})
5163
})

0 commit comments

Comments
 (0)