Skip to content

Commit fb496e6

Browse files
author
Sylvestre Gug
committed
test for stream
1 parent 55c793d commit fb496e6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/mssql.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,32 @@ describe("mssql", () => {
6868
);
6969
expect(row).to.equal(JSON.stringify({CustomerID: 12}));
7070
});
71+
72+
it("should stream the results of simple query", async () => {
73+
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
74+
sql: "SELECT TOP 2 CustomerID FROM test.SalesLT.Customer",
75+
params: [],
76+
});
77+
78+
const res = new MockRes(onEnd);
79+
80+
const index = mssql(credentials);
81+
await index(req, res);
82+
83+
function onEnd() {
84+
const [schema, row] = this._getString().split("\n");
85+
86+
expect(schema).to.equal(
87+
JSON.stringify({
88+
type: "array",
89+
items: {
90+
type: "object",
91+
properties: {CustomerID: {type: ["null", "integer"]}},
92+
},
93+
})
94+
);
95+
expect(row).to.equal(JSON.stringify({CustomerID: 12}));
96+
}
97+
});
7198
});
7299
});

0 commit comments

Comments
 (0)