@itwin/presentation-core-interop 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +8 -0
- package/.nycrc +14 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE.md +9 -0
- package/README.md +99 -0
- package/api/presentation-core-interop.api.md +38 -0
- package/api/presentation-core-interop.exports.csv +7 -0
- package/eslint.config.js +14 -0
- package/lib/cjs/core-interop/Formatting.d.ts +44 -0
- package/lib/cjs/core-interop/Formatting.d.ts.map +1 -0
- package/lib/cjs/core-interop/Formatting.js +147 -0
- package/lib/cjs/core-interop/Formatting.js.map +1 -0
- package/lib/cjs/core-interop/Logging.d.ts +32 -0
- package/lib/cjs/core-interop/Logging.d.ts.map +1 -0
- package/lib/cjs/core-interop/Logging.js +47 -0
- package/lib/cjs/core-interop/Logging.js.map +1 -0
- package/lib/cjs/core-interop/Metadata.d.ts +28 -0
- package/lib/cjs/core-interop/Metadata.d.ts.map +1 -0
- package/lib/cjs/core-interop/Metadata.js +51 -0
- package/lib/cjs/core-interop/Metadata.js.map +1 -0
- package/lib/cjs/core-interop/MetadataInternal.d.ts +9 -0
- package/lib/cjs/core-interop/MetadataInternal.d.ts.map +1 -0
- package/lib/cjs/core-interop/MetadataInternal.js +370 -0
- package/lib/cjs/core-interop/MetadataInternal.js.map +1 -0
- package/lib/cjs/core-interop/QueryExecutor.d.ts +31 -0
- package/lib/cjs/core-interop/QueryExecutor.d.ts.map +1 -0
- package/lib/cjs/core-interop/QueryExecutor.js +112 -0
- package/lib/cjs/core-interop/QueryExecutor.js.map +1 -0
- package/lib/cjs/core-interop/Transactions.d.ts +70 -0
- package/lib/cjs/core-interop/Transactions.d.ts.map +1 -0
- package/lib/cjs/core-interop/Transactions.js +61 -0
- package/lib/cjs/core-interop/Transactions.js.map +1 -0
- package/lib/cjs/presentation-core-interop.d.ts +6 -0
- package/lib/cjs/presentation-core-interop.d.ts.map +1 -0
- package/lib/cjs/presentation-core-interop.js +18 -0
- package/lib/cjs/presentation-core-interop.js.map +1 -0
- package/lib/cjs/test/Formatting.test.d.ts +2 -0
- package/lib/cjs/test/Formatting.test.d.ts.map +1 -0
- package/lib/cjs/test/Formatting.test.js +282 -0
- package/lib/cjs/test/Formatting.test.js.map +1 -0
- package/lib/cjs/test/Logging.test.d.ts +2 -0
- package/lib/cjs/test/Logging.test.d.ts.map +1 -0
- package/lib/cjs/test/Logging.test.js +57 -0
- package/lib/cjs/test/Logging.test.js.map +1 -0
- package/lib/cjs/test/Metadata.test.d.ts +2 -0
- package/lib/cjs/test/Metadata.test.d.ts.map +1 -0
- package/lib/cjs/test/Metadata.test.js +676 -0
- package/lib/cjs/test/Metadata.test.js.map +1 -0
- package/lib/cjs/test/QueryExecutor.test.d.ts +2 -0
- package/lib/cjs/test/QueryExecutor.test.d.ts.map +1 -0
- package/lib/cjs/test/QueryExecutor.test.js +178 -0
- package/lib/cjs/test/QueryExecutor.test.js.map +1 -0
- package/lib/cjs/test/Transactions.test.d.ts +2 -0
- package/lib/cjs/test/Transactions.test.d.ts.map +1 -0
- package/lib/cjs/test/Transactions.test.js +73 -0
- package/lib/cjs/test/Transactions.test.js.map +1 -0
- package/lib/cjs/test/index.d.ts +2 -0
- package/lib/cjs/test/index.d.ts.map +1 -0
- package/lib/cjs/test/index.js +43 -0
- package/lib/cjs/test/index.js.map +1 -0
- package/lib/esm/core-interop/Formatting.d.ts +44 -0
- package/lib/esm/core-interop/Formatting.d.ts.map +1 -0
- package/lib/esm/core-interop/Formatting.js +143 -0
- package/lib/esm/core-interop/Formatting.js.map +1 -0
- package/lib/esm/core-interop/Logging.d.ts +32 -0
- package/lib/esm/core-interop/Logging.d.ts.map +1 -0
- package/lib/esm/core-interop/Logging.js +43 -0
- package/lib/esm/core-interop/Logging.js.map +1 -0
- package/lib/esm/core-interop/Metadata.d.ts +28 -0
- package/lib/esm/core-interop/Metadata.d.ts.map +1 -0
- package/lib/esm/core-interop/Metadata.js +47 -0
- package/lib/esm/core-interop/Metadata.js.map +1 -0
- package/lib/esm/core-interop/MetadataInternal.d.ts +9 -0
- package/lib/esm/core-interop/MetadataInternal.d.ts.map +1 -0
- package/lib/esm/core-interop/MetadataInternal.js +364 -0
- package/lib/esm/core-interop/MetadataInternal.js.map +1 -0
- package/lib/esm/core-interop/QueryExecutor.d.ts +31 -0
- package/lib/esm/core-interop/QueryExecutor.d.ts.map +1 -0
- package/lib/esm/core-interop/QueryExecutor.js +108 -0
- package/lib/esm/core-interop/QueryExecutor.js.map +1 -0
- package/lib/esm/core-interop/Transactions.d.ts +70 -0
- package/lib/esm/core-interop/Transactions.d.ts.map +1 -0
- package/lib/esm/core-interop/Transactions.js +57 -0
- package/lib/esm/core-interop/Transactions.js.map +1 -0
- package/lib/esm/presentation-core-interop.d.ts +6 -0
- package/lib/esm/presentation-core-interop.d.ts.map +1 -0
- package/lib/esm/presentation-core-interop.js +10 -0
- package/lib/esm/presentation-core-interop.js.map +1 -0
- package/lib/esm/test/Formatting.test.d.ts +2 -0
- package/lib/esm/test/Formatting.test.d.ts.map +1 -0
- package/lib/esm/test/Formatting.test.js +277 -0
- package/lib/esm/test/Formatting.test.js.map +1 -0
- package/lib/esm/test/Logging.test.d.ts +2 -0
- package/lib/esm/test/Logging.test.d.ts.map +1 -0
- package/lib/esm/test/Logging.test.js +52 -0
- package/lib/esm/test/Logging.test.js.map +1 -0
- package/lib/esm/test/Metadata.test.d.ts +2 -0
- package/lib/esm/test/Metadata.test.d.ts.map +1 -0
- package/lib/esm/test/Metadata.test.js +671 -0
- package/lib/esm/test/Metadata.test.js.map +1 -0
- package/lib/esm/test/QueryExecutor.test.d.ts +2 -0
- package/lib/esm/test/QueryExecutor.test.d.ts.map +1 -0
- package/lib/esm/test/QueryExecutor.test.js +173 -0
- package/lib/esm/test/QueryExecutor.test.js.map +1 -0
- package/lib/esm/test/Transactions.test.d.ts +2 -0
- package/lib/esm/test/Transactions.test.d.ts.map +1 -0
- package/lib/esm/test/Transactions.test.js +68 -0
- package/lib/esm/test/Transactions.test.js.map +1 -0
- package/lib/esm/test/index.d.ts +2 -0
- package/lib/esm/test/index.d.ts.map +1 -0
- package/lib/esm/test/index.js +15 -0
- package/lib/esm/test/index.js.map +1 -0
- package/package.json +72 -0
- package/src/core-interop/Formatting.ts +194 -0
- package/src/core-interop/Logging.ts +58 -0
- package/src/core-interop/Metadata.ts +56 -0
- package/src/core-interop/MetadataInternal.ts +413 -0
- package/src/core-interop/QueryExecutor.ts +122 -0
- package/src/core-interop/Transactions.ts +92 -0
- package/src/presentation-core-interop.ts +10 -0
- package/src/test/Formatting.test.ts +358 -0
- package/src/test/Logging.test.ts +59 -0
- package/src/test/Metadata.test.ts +776 -0
- package/src/test/QueryExecutor.test.ts +217 -0
- package/src/test/Transactions.test.ts +74 -0
- package/src/test/index.ts +17 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import { expect } from "chai";
|
|
7
|
+
import sinon from "sinon";
|
|
8
|
+
import { QueryBinder, QueryOptions, QueryRowFormat } from "@itwin/core-common";
|
|
9
|
+
import { Point2d, Point3d } from "@itwin/core-geometry";
|
|
10
|
+
import { ECSqlBinding } from "@itwin/presentation-shared";
|
|
11
|
+
import { createECSqlQueryExecutor } from "../core-interop/QueryExecutor";
|
|
12
|
+
|
|
13
|
+
describe("createECSqlQueryExecutor", () => {
|
|
14
|
+
describe("createQueryReader", () => {
|
|
15
|
+
it("calls IModel's `createQueryReader` with default params", async () => {
|
|
16
|
+
const imodel = {
|
|
17
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub([{}, {}])),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
21
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql" });
|
|
22
|
+
for await (const _ of reader) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
26
|
+
expect(imodel.createQueryReader).to.be.calledOnceWithExactly(
|
|
27
|
+
"ecsql",
|
|
28
|
+
sinon.match((binder: QueryBinder) => Object.keys(binder.serialize()).length === 0),
|
|
29
|
+
sinon.match((options: QueryOptions) => Object.keys(options).length === 0),
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("calls IModel's `createQueryReader` with CTEs", async () => {
|
|
34
|
+
const imodel = {
|
|
35
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub([{}, {}])),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
39
|
+
const reader = executor.createQueryReader({ ctes: ["cte1", "cte2"], ecsql: "ecsql" });
|
|
40
|
+
for await (const _ of reader) {
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
44
|
+
expect(imodel.createQueryReader).to.be.calledOnceWith("WITH RECURSIVE cte1, cte2 ecsql");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("calls IModel's `createQueryReader` with `ECSqlPropertyNames` row format", async () => {
|
|
48
|
+
const imodel = {
|
|
49
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub([])),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
53
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql" }, { rowFormat: "ECSqlPropertyNames" });
|
|
54
|
+
for await (const _ of reader) {
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
58
|
+
expect(imodel.createQueryReader).to.be.calledOnceWithExactly(
|
|
59
|
+
"ecsql",
|
|
60
|
+
sinon.match((binder: QueryBinder) => Object.keys(binder.serialize()).length === 0),
|
|
61
|
+
sinon.match((options: QueryOptions) => options.rowFormat === QueryRowFormat.UseECSqlPropertyNames),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("calls IModel's `createQueryReader` with `Indexes` row format", async () => {
|
|
66
|
+
const imodel = {
|
|
67
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub([])),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
71
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql" }, { rowFormat: "Indexes" });
|
|
72
|
+
for await (const _ of reader) {
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
76
|
+
expect(imodel.createQueryReader).to.be.calledOnceWithExactly(
|
|
77
|
+
"ecsql",
|
|
78
|
+
sinon.match((binder: QueryBinder) => Object.keys(binder.serialize()).length === 0),
|
|
79
|
+
sinon.match((options: QueryOptions) => options.rowFormat === QueryRowFormat.UseECSqlPropertyIndexes),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("calls IModel's `createQueryReader` with different bindings", async () => {
|
|
84
|
+
const imodel = {
|
|
85
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub([])),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const bindings: ECSqlBinding[] = [
|
|
89
|
+
{
|
|
90
|
+
type: "boolean",
|
|
91
|
+
value: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: "double",
|
|
95
|
+
value: 1.23,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "id",
|
|
99
|
+
value: "0x123",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "idset",
|
|
103
|
+
value: ["0x123", "0x456"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: "int",
|
|
107
|
+
value: 123,
|
|
108
|
+
},
|
|
109
|
+
{ type: "long", value: 456 },
|
|
110
|
+
{
|
|
111
|
+
type: "point2d",
|
|
112
|
+
value: { x: 1.23, y: 4.56 },
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: "point3d",
|
|
116
|
+
value: { x: 1.23, y: 4.56, z: 7.89 },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "string",
|
|
120
|
+
value: "xxx",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "string",
|
|
124
|
+
value: undefined,
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const expectedBinder = new QueryBinder();
|
|
129
|
+
expectedBinder.bindBoolean(1, true);
|
|
130
|
+
expectedBinder.bindDouble(2, 1.23);
|
|
131
|
+
expectedBinder.bindId(3, "0x123");
|
|
132
|
+
expectedBinder.bindIdSet(4, ["0x123", "0x456"]);
|
|
133
|
+
expectedBinder.bindInt(5, 123);
|
|
134
|
+
expectedBinder.bindLong(6, 456);
|
|
135
|
+
expectedBinder.bindPoint2d(7, Point2d.create(1.23, 4.56));
|
|
136
|
+
expectedBinder.bindPoint3d(8, Point3d.create(1.23, 4.56, 7.89));
|
|
137
|
+
expectedBinder.bindString(9, "xxx");
|
|
138
|
+
expectedBinder.bindNull(10);
|
|
139
|
+
|
|
140
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
141
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql", bindings }, undefined);
|
|
142
|
+
for await (const _ of reader) {
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
146
|
+
expect(imodel.createQueryReader).to.be.calledOnceWithExactly(
|
|
147
|
+
"ecsql",
|
|
148
|
+
sinon.match((binder: QueryBinder) => JSON.stringify(expectedBinder.serialize()) === JSON.stringify(binder.serialize())),
|
|
149
|
+
sinon.match((options: QueryOptions) => Object.keys(options).length === 0),
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("creates iterable reader for rows as objects", async () => {
|
|
154
|
+
const rows = [{ x: 1 }, { y: 2 }];
|
|
155
|
+
const imodel = {
|
|
156
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub(rows)),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
160
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql" }, { rowFormat: "ECSqlPropertyNames" });
|
|
161
|
+
|
|
162
|
+
const resultRows = new Array<any>();
|
|
163
|
+
for await (const row of reader) {
|
|
164
|
+
resultRows.push(row);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
expect(resultRows).to.deep.eq(rows);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("creates iterable reader for rows as arrays", async () => {
|
|
171
|
+
const rows = [
|
|
172
|
+
[1, 2],
|
|
173
|
+
[3, 4],
|
|
174
|
+
];
|
|
175
|
+
const imodel = {
|
|
176
|
+
createQueryReader: sinon.stub().returns(createCoreECSqlReaderStub(rows)),
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const executor = createECSqlQueryExecutor(imodel);
|
|
180
|
+
const reader = executor.createQueryReader({ ecsql: "ecsql" }, { rowFormat: "Indexes" });
|
|
181
|
+
|
|
182
|
+
const resultRows = new Array<any>();
|
|
183
|
+
for await (const row of reader) {
|
|
184
|
+
resultRows.push(row);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
expect(resultRows).to.deep.eq(rows);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
function createCoreECSqlReaderStub(rows: object[]) {
|
|
193
|
+
let curr = -1;
|
|
194
|
+
const reader = {
|
|
195
|
+
next: sinon.fake(async () => {
|
|
196
|
+
++curr;
|
|
197
|
+
if (curr < rows.length) {
|
|
198
|
+
return { done: false, value: createQueryRowProxy(rows[curr]) };
|
|
199
|
+
}
|
|
200
|
+
return { done: true, value: undefined };
|
|
201
|
+
}),
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
...reader,
|
|
205
|
+
async *[Symbol.asyncIterator]() {
|
|
206
|
+
return reader;
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function createQueryRowProxy(data: object) {
|
|
212
|
+
return {
|
|
213
|
+
...data,
|
|
214
|
+
toArray: () => data,
|
|
215
|
+
toRow: () => data,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import { expect } from "chai";
|
|
7
|
+
import sinon from "sinon";
|
|
8
|
+
import { registerTxnListeners } from "../core-interop/Transactions";
|
|
9
|
+
|
|
10
|
+
describe("registerTxnListeners", () => {
|
|
11
|
+
it("calls provided callback on `onAppliedChanges` event", async () => {
|
|
12
|
+
const txns = createCoreTxnManager();
|
|
13
|
+
const callback = sinon.stub();
|
|
14
|
+
registerTxnListeners(txns, callback);
|
|
15
|
+
expect(txns.onChangesApplied.addListener).to.be.calledOnce;
|
|
16
|
+
txns.onChangesApplied.addListener.firstCall.callArg(0);
|
|
17
|
+
expect(callback).to.be.calledOnce;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("calls provided callback on `onCommit` and `onCommitted` event", async () => {
|
|
21
|
+
const txns = createCoreTxnManager();
|
|
22
|
+
const callback = sinon.stub();
|
|
23
|
+
registerTxnListeners(txns, callback);
|
|
24
|
+
expect(txns.onCommit.addListener).to.be.calledOnce;
|
|
25
|
+
expect(txns.onCommitted.addListener).to.be.calledOnce;
|
|
26
|
+
txns.onCommit.addListener.firstCall.callArg(0);
|
|
27
|
+
txns.onCommitted.addListener.firstCall.callArg(0);
|
|
28
|
+
expect(callback).to.be.calledOnce;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("doesn't call provided callback on `onCommitted` event if there was no `onCommit` event", async () => {
|
|
32
|
+
const txns = createCoreTxnManager();
|
|
33
|
+
const callback = sinon.stub();
|
|
34
|
+
registerTxnListeners(txns, callback);
|
|
35
|
+
expect(txns.onCommit.addListener).to.be.calledOnce;
|
|
36
|
+
expect(txns.onCommitted.addListener).to.be.calledOnce;
|
|
37
|
+
txns.onCommitted.addListener.firstCall.callArg(0);
|
|
38
|
+
expect(callback).to.not.be.called;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("unregisters from events when returned function is called", async () => {
|
|
42
|
+
const txns = createCoreTxnManager();
|
|
43
|
+
const unregister = registerTxnListeners(txns, sinon.stub());
|
|
44
|
+
expect(txns.onCommit.hasListeners()).to.be.true;
|
|
45
|
+
expect(txns.onCommitted.hasListeners()).to.be.true;
|
|
46
|
+
expect(txns.onChangesApplied.hasListeners()).to.be.true;
|
|
47
|
+
unregister();
|
|
48
|
+
expect(txns.onCommit.hasListeners()).to.be.false;
|
|
49
|
+
expect(txns.onCommitted.hasListeners()).to.be.false;
|
|
50
|
+
expect(txns.onChangesApplied.hasListeners()).to.be.false;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function createCoreTxnManager() {
|
|
54
|
+
return {
|
|
55
|
+
onCommit: createEventStub(),
|
|
56
|
+
onCommitted: createEventStub(),
|
|
57
|
+
onChangesApplied: createEventStub(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function createEventStub() {
|
|
62
|
+
let hasListeners = false;
|
|
63
|
+
return {
|
|
64
|
+
hasListeners: () => hasListeners,
|
|
65
|
+
addListener: sinon.fake(() => {
|
|
66
|
+
hasListeners = true;
|
|
67
|
+
return () => {
|
|
68
|
+
hasListeners = false;
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
removeListener: sinon.stub(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import * as chai from "chai";
|
|
7
|
+
import chaiAsPromised from "chai-as-promised";
|
|
8
|
+
import sinon from "sinon";
|
|
9
|
+
import sinonChai from "sinon-chai";
|
|
10
|
+
|
|
11
|
+
// setup chai
|
|
12
|
+
chai.use(chaiAsPromised);
|
|
13
|
+
chai.use(sinonChai);
|
|
14
|
+
|
|
15
|
+
beforeEach(function () {
|
|
16
|
+
sinon.restore();
|
|
17
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"inlineSources": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"lib": ["ES2022"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|