Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "offset" to Result. #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Xml/Response/Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export default class Result {
return this._numRemaining;
}

private _offset: number;
get offset(): number {
return this._offset;
}

private _resultId: string;
get resultId(): string {
return this._resultId;
Expand Down Expand Up @@ -151,6 +156,10 @@ export default class Result {
this._numRemaining = parseInt(dataAttr["numremaining"], 10);
}

if (dataAttr.hasOwnProperty("offset")) {
this._offset = parseInt(dataAttr["offset"], 10);
}

if (dataAttr.hasOwnProperty("resultId")) {
this._resultId = dataAttr["resultId"].toString();
}
Expand Down
6 changes: 4 additions & 2 deletions test/Xml/Response/ResultTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ describe("Result", () => {
<status>success</status>
<function>readByQuery</function>
<controlid>818b0a96-3faf-4931-97e6-1cf05818ea44</controlid>
<data listtype="class" count="1" totalcount="2" numremaining="1" resultId="myResultId">
<data listtype="class" count="1" totalcount="2" numremaining="1" offset="0" resultId="myResultId">
<class>
<RECORDNO>8</RECORDNO>
<CLASSID>C1234</CLASSID>
Expand Down Expand Up @@ -471,6 +471,7 @@ describe("Result", () => {
chai.assert.equal(result.count, 1);
chai.assert.equal(result.totalCount, 2);
chai.assert.equal(result.numRemaining, 1);
chai.assert.equal(result.offset, 0);
chai.assert.equal(result.resultId, "myResultId");
chai.assert.equal(result.data.length, 1);
});
Expand All @@ -497,7 +498,7 @@ describe("Result", () => {
<status>success</status>
<function>readByQuery</function>
<controlid>818b0a96-3faf-4931-97e6-1cf05818ea44</controlid>
<data listtype="class" count="2" totalcount="3" numremaining="1" resultId="myResultId">
<data listtype="class" count="2" totalcount="3" numremaining="1" offset="0" resultId="myResultId">
<class>
<RECORDNO>8</RECORDNO>
<CLASSID>C1234</CLASSID>
Expand Down Expand Up @@ -543,6 +544,7 @@ describe("Result", () => {
chai.assert.equal(result.count, 2);
chai.assert.equal(result.totalCount, 3);
chai.assert.equal(result.numRemaining, 1);
chai.assert.equal(result.offset, 0);
chai.assert.equal(result.resultId, "myResultId");
chai.assert.equal(result.data.length, 2);
});
Expand Down