testeranto 0.171.0 → 0.173.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.
Files changed (195) hide show
  1. package/README.md +2 -4
  2. package/dist/common/src/PM/base.js +4 -0
  3. package/dist/common/src/PM/main.js +11 -4
  4. package/dist/common/src/PM/node.js +1 -1
  5. package/dist/common/src/PM/web.js +3 -3
  6. package/dist/common/src/ReportServer.js +2 -126
  7. package/dist/common/src/ReportServer.test.ts/index.js +78 -0
  8. package/dist/common/src/ReportServerLib.js +135 -0
  9. package/dist/common/src/components/pure/ProjectPageView.test/implementation.js +1 -1
  10. package/dist/common/src/lib/abstractBase.js +2 -0
  11. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +10 -9
  12. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.specification.js +7 -7
  13. package/dist/common/src/lib/basebuilder.js +8 -2
  14. package/dist/common/src/lib/pmProxy.js +54 -150
  15. package/dist/common/testeranto.config.js +35 -20
  16. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  17. package/dist/module/src/PM/base.js +4 -0
  18. package/dist/module/src/PM/main.js +11 -4
  19. package/dist/module/src/PM/node.js +1 -1
  20. package/dist/module/src/PM/web.js +3 -3
  21. package/dist/module/src/ReportServer.js +2 -123
  22. package/dist/module/src/ReportServer.test.ts/index.js +73 -0
  23. package/dist/module/src/ReportServerLib.js +128 -0
  24. package/dist/module/src/TestPage.js +29 -17
  25. package/dist/module/src/components/pure/ProjectPageView.test/implementation.js +1 -1
  26. package/dist/module/src/components/pure/TestPageView.js +29 -17
  27. package/dist/module/src/lib/abstractBase.js +2 -0
  28. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +10 -9
  29. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.specification.js +7 -7
  30. package/dist/module/src/lib/basebuilder.js +8 -2
  31. package/dist/module/src/lib/pmProxy.js +54 -150
  32. package/dist/module/testeranto.config.js +35 -20
  33. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  34. package/dist/prebuild/App.css +13 -9
  35. package/dist/prebuild/App.js +102 -99
  36. package/dist/prebuild/ReportServer.mjs +15 -9
  37. package/dist/prebuild/run.mjs +14 -4
  38. package/dist/types/src/PM/node.d.ts +1 -1
  39. package/dist/types/src/PM/web.d.ts +1 -1
  40. package/dist/types/src/ReportServer.test.ts/index.d.ts +29 -0
  41. package/dist/types/src/ReportServerLib.d.ts +2 -0
  42. package/dist/types/src/Types.d.ts +0 -1
  43. package/dist/types/src/components/pure/ProjectPageView.test/index.d.ts +1 -1
  44. package/dist/types/src/lib/abstractBase.d.ts +1 -1
  45. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.types.d.ts +7 -4
  46. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  47. package/package.json +6 -5
  48. package/src/PM/base.ts +5 -0
  49. package/src/PM/main.ts +12 -4
  50. package/src/PM/node.ts +1 -1
  51. package/src/PM/web.ts +3 -3
  52. package/src/ReportServer.test.ts/index.ts +194 -0
  53. package/src/ReportServer.ts +2 -132
  54. package/src/ReportServerLib.ts +144 -0
  55. package/src/TestPage.tsx +65 -5
  56. package/src/Types.ts +0 -1
  57. package/src/components/pure/ProjectPageView.test/implementation.tsx +1 -1
  58. package/src/components/pure/TestPageView.tsx +65 -5
  59. package/src/lib/abstractBase.ts +4 -1
  60. package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +22 -10
  61. package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +9 -9
  62. package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +7 -4
  63. package/src/lib/basebuilder.ts +7 -4
  64. package/src/lib/pmProxy.ts +78 -155
  65. package/testeranto/App.css +13 -9
  66. package/testeranto/App.js +102 -99
  67. package/testeranto/bundles/node/allTests/metafile.json +38 -781
  68. package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +983 -24
  69. package/testeranto/bundles/node/core/metafile.json +486 -0
  70. package/testeranto/bundles/{pure/allTests/chunk-VMUSFSZM.mjs → node/core/src/lib/baseBuilder.test/baseBuilder.test.node.mjs} +797 -412
  71. package/testeranto/bundles/node/staticSite/metafile.json +593 -0
  72. package/testeranto/bundles/node/staticSite/src/ReportServer.test.ts/index.mjs +1594 -0
  73. package/testeranto/bundles/pure/allTests/metafile.json +157 -585
  74. package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +740 -27
  75. package/testeranto/bundles/pure/core/metafile.json +626 -0
  76. package/testeranto/bundles/{web/allTests/chunk-U7AW26HL.mjs → pure/core/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs} +507 -410
  77. package/testeranto/bundles/pure/staticSite/metafile.json +8 -0
  78. package/testeranto/bundles/web/allTests/metafile.json +107 -15292
  79. package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +893 -45
  80. package/testeranto/bundles/web/core/metafile.json +780 -0
  81. package/testeranto/bundles/web/core/src/lib/baseBuilder.test/baseBuilder.test.web.html +19 -0
  82. package/testeranto/bundles/web/{allTests/chunk-RLDR6LJN.mjs → core/src/lib/baseBuilder.test/baseBuilder.test.web.mjs} +580 -518
  83. package/testeranto/bundles/web/staticSite/metafile.json +8 -0
  84. package/testeranto/projects.json +2 -1
  85. package/testeranto/reports/allTests/config.json +0 -64
  86. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +2 -0
  87. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +11 -13
  88. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +10 -0
  89. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
  90. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +10 -18
  91. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +25 -13
  92. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +2 -0
  93. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +8 -0
  94. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +24 -12
  95. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +2 -0
  96. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +49 -55
  97. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +12 -2
  98. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
  99. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +10 -18
  100. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +24 -12
  101. package/testeranto/reports/allTests/summary.json +6 -62
  102. package/testeranto/reports/core/config.json +24 -0
  103. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +2 -0
  104. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +32 -0
  105. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +2 -0
  106. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +26 -0
  107. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
  108. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +69 -0
  109. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +74 -0
  110. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +2 -0
  111. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +2 -0
  112. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +26 -0
  113. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +74 -0
  114. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +2 -0
  115. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +61 -0
  116. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +2 -0
  117. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +26 -0
  118. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
  119. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +69 -0
  120. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +74 -0
  121. package/testeranto/reports/core/summary.json +23 -0
  122. package/testeranto/reports/staticSite/config.json +24 -0
  123. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/lint_errors.txt +5 -0
  124. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/logs.txt +44 -0
  125. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/message.txt +2 -0
  126. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/prompt.txt +23 -0
  127. package/testeranto/reports/{allTests/src/lib/core.test/core.test → staticSite/src/ReportServer.test.ts/index}/node/type_errors.txt +21 -32
  128. package/testeranto/reports/staticSite/summary.json +9 -0
  129. package/testeranto/reportsnode_build_errors +17 -0
  130. package/testeranto.config.ts +37 -20
  131. package/testeranto/bundles/node/allTests/chunk-3EUGBAOM.mjs +0 -113
  132. package/testeranto/bundles/node/allTests/chunk-E75CSRER.mjs +0 -800
  133. package/testeranto/bundles/node/allTests/chunk-M6DO7VMB.mjs +0 -252
  134. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test/node.test.mjs +0 -323
  135. package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +0 -411
  136. package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +0 -528
  137. package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +0 -4650
  138. package/testeranto/bundles/pure/allTests/chunk-KHDVEHF7.mjs +0 -185
  139. package/testeranto/bundles/pure/allTests/src/Pure.test.mjs +0 -429
  140. package/testeranto/bundles/pure/allTests/src/lib/BaseSuite.test/pure.test.mjs +0 -425
  141. package/testeranto/bundles/web/allTests/chunk-HPYA4YZC.mjs +0 -2283
  142. package/testeranto/bundles/web/allTests/src/components/pure/ProjectPageView.test/index.html +0 -19
  143. package/testeranto/bundles/web/allTests/src/components/pure/ProjectPageView.test/index.mjs +0 -37524
  144. package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.html +0 -19
  145. package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.mjs +0 -440
  146. package/testeranto/reports/allTests/src/Pure.test/pure/lint_errors.txt +0 -0
  147. package/testeranto/reports/allTests/src/Pure.test/pure/message.txt +0 -2
  148. package/testeranto/reports/allTests/src/Pure.test/pure/prompt.txt +0 -13
  149. package/testeranto/reports/allTests/src/Pure.test/pure/type_errors.txt +0 -101
  150. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/lint_errors.txt +0 -13
  151. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/logs.txt +0 -50
  152. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/message.txt +0 -2
  153. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/prompt.txt +0 -17
  154. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/tests.json +0 -32
  155. package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/type_errors.txt +0 -68
  156. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/lint_errors.txt +0 -0
  157. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/logs.txt +0 -52
  158. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/message.txt +0 -2
  159. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/prompt.txt +0 -13
  160. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/tests.json +0 -31
  161. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/type_errors.txt +0 -111
  162. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/bdd_errors.txt +0 -1
  163. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/lint_errors.txt +0 -0
  164. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/message.txt +0 -2
  165. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/prompt.txt +0 -14
  166. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/tests.json +0 -31
  167. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/type_errors.txt +0 -111
  168. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/bdd_errors.txt +0 -1
  169. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/lint_errors.txt +0 -0
  170. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/logs.txt +0 -108
  171. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/message.txt +0 -2
  172. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/prompt.txt +0 -14
  173. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/tests.json +0 -31
  174. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/type_errors.txt +0 -111
  175. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/bdd_errors.txt +0 -1
  176. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.txt +0 -0
  177. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/logs.txt +0 -700
  178. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message.txt +0 -2
  179. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +0 -16
  180. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/tests.json +0 -164
  181. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +0 -138
  182. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.txt +0 -21
  183. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/logs.txt +0 -7
  184. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message.txt +0 -2
  185. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +0 -18
  186. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/bdd_errors.txt +0 -1
  187. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.txt +0 -20
  188. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +0 -31
  189. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message.txt +0 -2
  190. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +0 -16
  191. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/tests.json +0 -134
  192. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +0 -76
  193. package/testeranto/reportsweb_build_errors +0 -25
  194. /package/testeranto/reports/{allTests/src/components/pure/ProjectPageView.test/index/web → core/src/lib/baseBuilder.test/baseBuilder.test.node/node}/bdd_errors.txt +0 -0
  195. /package/testeranto/reports/{allTests/src/lib/BaseSuite.test/node.test/node → core/src/lib/baseBuilder.test/baseBuilder.test.web/web}/bdd_errors.txt +0 -0
@@ -1,4650 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
- import {
3
- Node_default
4
- } from "../../../chunk-M6DO7VMB.mjs";
5
- import {
6
- andWhenProxy,
7
- butThenProxy
8
- } from "../../../chunk-E75CSRER.mjs";
9
-
10
- // src/lib/pmProxy.test/mockPMBase.ts
11
- var MockPMBase = class {
12
- constructor(configs) {
13
- this.calls = {};
14
- this.testResourceConfiguration = {};
15
- this.configs = configs || {};
16
- }
17
- // Common tracking functionality
18
- trackCall(method, args) {
19
- if (!this.calls[method]) {
20
- this.calls[method] = [];
21
- }
22
- this.calls[method].push(args);
23
- }
24
- getCallCount(method) {
25
- return this.calls[method]?.length || 0;
26
- }
27
- getLastCall(method) {
28
- const calls = this.calls[method];
29
- return calls ? calls[calls.length - 1] : null;
30
- }
31
- // Minimal implementations of required methods
32
- launchSideCar(n, testName, projectName) {
33
- this.trackCall("launchSideCar", { n, testName, projectName });
34
- return Promise.resolve();
35
- }
36
- end(uid) {
37
- this.trackCall("end", { uid });
38
- console.debug(`Ending test with uid ${uid}`);
39
- return Promise.resolve(true);
40
- }
41
- // Add debug method
42
- debug(message) {
43
- console.debug(`[MockPMBase] ${message}`);
44
- this.trackCall("debug", { message });
45
- }
46
- writeFileSync(path, content, testName) {
47
- this.trackCall("writeFileSync", { path, content, testName });
48
- return Promise.resolve(true);
49
- }
50
- createWriteStream(path, testName) {
51
- this.trackCall("createWriteStream", { path, testName });
52
- return Promise.resolve(0);
53
- }
54
- screencast(opts, testName, page) {
55
- this.trackCall("screencast", { opts, testName, page });
56
- return Promise.resolve({});
57
- }
58
- customScreenShot(opts, testName, pageUid) {
59
- this.trackCall("customScreenShot", { opts, testName, pageUid });
60
- return Promise.resolve({});
61
- }
62
- testArtiFactoryfileWriter(tLog, callback) {
63
- return (fPath, value) => {
64
- this.trackCall("testArtiFactoryfileWriter", { fPath, value });
65
- callback(Promise.resolve());
66
- };
67
- }
68
- // Other required PM_Base methods with minimal implementations
69
- closePage(p) {
70
- return Promise.resolve();
71
- }
72
- $(selector, p) {
73
- return Promise.resolve();
74
- }
75
- click(selector, page) {
76
- return Promise.resolve();
77
- }
78
- goto(p, url) {
79
- return Promise.resolve();
80
- }
81
- newPage() {
82
- return Promise.resolve("mock-page");
83
- }
84
- pages() {
85
- return Promise.resolve(["mock-page"]);
86
- }
87
- waitForSelector(p, s) {
88
- return Promise.resolve(true);
89
- }
90
- focusOn(selector, p) {
91
- return Promise.resolve();
92
- }
93
- typeInto(value, p) {
94
- return Promise.resolve();
95
- }
96
- getAttribute(selector, attribute, p) {
97
- return Promise.resolve();
98
- }
99
- getInnerHtml(selector, p) {
100
- return Promise.resolve();
101
- }
102
- isDisabled(selector, p) {
103
- return Promise.resolve(false);
104
- }
105
- screencastStop(s) {
106
- return Promise.resolve();
107
- }
108
- existsSync(destFolder) {
109
- return false;
110
- }
111
- mkdirSync(fp) {
112
- return Promise.resolve();
113
- }
114
- write(uid, contents) {
115
- return Promise.resolve(true);
116
- }
117
- page(p) {
118
- return "mock-page";
119
- }
120
- doInPage(p, cb) {
121
- return Promise.resolve();
122
- }
123
- customclose() {
124
- return Promise.resolve();
125
- }
126
- };
127
-
128
- // src/lib/pmProxy.test/implementation.ts
129
- var implementation = {
130
- suites: {
131
- Default: "PM Proxy Tests"
132
- },
133
- givens: {
134
- SomeBaseString: (s) => s
135
- },
136
- whens: {
137
- // functions have no mutations
138
- },
139
- thens: {
140
- theButTheProxyReturns: (method, expectedPath) => (store) => {
141
- const mockPm = new MockPMBase();
142
- const filepath = "test/path";
143
- const proxiedPm = store.butThenProxy(mockPm, filepath);
144
- let actualPath;
145
- let actualContent;
146
- try {
147
- switch (method) {
148
- case "writeFileSync":
149
- const content = expectedPath.includes("content") ? "test content" : "default content";
150
- proxiedPm.writeFileSync(
151
- expectedPath.includes("empty") ? "" : expectedPath.includes("nested") ? "nested/folder/test.txt" : expectedPath.includes("spaces") ? "file with spaces.txt" : expectedPath.includes("invalid") ? "../invalid.txt" : "test.txt",
152
- content
153
- );
154
- actualPath = mockPm.getLastCall("writeFileSync")?.path;
155
- actualContent = mockPm.getLastCall("writeFileSync")?.content;
156
- break;
157
- case "createWriteStream":
158
- proxiedPm.createWriteStream(
159
- expectedPath.includes("empty") ? "" : "stream.txt"
160
- );
161
- actualPath = mockPm.getLastCall("createWriteStream")?.path;
162
- break;
163
- case "screencast":
164
- proxiedPm.screencast(
165
- {
166
- path: "screen.png",
167
- quality: 80,
168
- fullPage: true
169
- },
170
- "test"
171
- );
172
- actualPath = mockPm.getLastCall("screencast")?.opts?.path;
173
- actualContent = mockPm.getLastCall("screencast")?.opts;
174
- break;
175
- case "customScreenShot":
176
- proxiedPm.customScreenShot({ path: "shot.png" }, "test");
177
- actualPath = mockPm.getLastCall("customScreenShot")?.opts?.path;
178
- break;
179
- default:
180
- throw new Error(`Unknown method: ${method}`);
181
- }
182
- if (expectedPath === void 0) {
183
- return [void 0, void 0];
184
- }
185
- return [actualPath, expectedPath, actualContent];
186
- } catch (error) {
187
- return [error.message, expectedPath];
188
- }
189
- },
190
- verifyContent: (expectedContent) => (result) => {
191
- const actualContent = result[2];
192
- if (JSON.stringify(actualContent) !== JSON.stringify(expectedContent)) {
193
- throw new Error(
194
- `Content mismatch. Expected: ${JSON.stringify(
195
- expectedContent
196
- )}, Got: ${JSON.stringify(actualContent)}`
197
- );
198
- }
199
- return result;
200
- }
201
- }
202
- };
203
-
204
- // src/lib/pmProxy.test/specification.ts
205
- var specification = (Suite, Given, When, Then) => [
206
- Suite.Default("PM Proxy Functionality", {
207
- // Basic path rewriting tests
208
- writeFileProxyTest: Given.SomeBaseString(
209
- ["butThenProxy should rewrite writeFileSync paths"],
210
- [],
211
- [
212
- Then.theButTheProxyReturns(
213
- "writeFileSync",
214
- "test/path/butThen/test.txt"
215
- )
216
- ],
217
- "writeFileSync test"
218
- ),
219
- createWriteStreamProxyTest: Given.SomeBaseString(
220
- ["butThenProxy should rewrite createWriteStream paths"],
221
- [],
222
- [
223
- Then.theButTheProxyReturns(
224
- "createWriteStream",
225
- "test/path/butThen/stream.txt"
226
- )
227
- ],
228
- "createWriteStream test"
229
- ),
230
- screencastProxyTest: Given.SomeBaseString(
231
- ["butThenProxy should rewrite screencast paths"],
232
- [],
233
- [
234
- Then.theButTheProxyReturns(
235
- "screencast",
236
- "test/path/butThen/screen.png"
237
- )
238
- ],
239
- "screencast test"
240
- ),
241
- customScreenShotProxyTest: Given.SomeBaseString(
242
- ["butThenProxy should rewrite customScreenShot paths"],
243
- [],
244
- [
245
- Then.theButTheProxyReturns(
246
- "customScreenShot",
247
- "test/path/butThen/shot.png"
248
- )
249
- ],
250
- "customScreenShot test"
251
- ),
252
- // Edge cases
253
- emptyPathTest: Given.SomeBaseString(
254
- ["butThenProxy should handle empty paths"],
255
- [],
256
- [Then.theButTheProxyReturns("writeFileSync", "test/path/butThen/")],
257
- "empty path test"
258
- ),
259
- nestedPathTest: Given.SomeBaseString(
260
- ["butThenProxy should handle nested paths"],
261
- [],
262
- [
263
- Then.theButTheProxyReturns(
264
- "writeFileSync",
265
- "test/path/butThen/nested/folder/test.txt"
266
- )
267
- ],
268
- "nested path test"
269
- ),
270
- specialCharsTest: Given.SomeBaseString(
271
- ["butThenProxy should handle special characters in paths"],
272
- [],
273
- [
274
- Then.theButTheProxyReturns(
275
- "writeFileSync",
276
- "test/path/butThen/file with spaces.txt"
277
- )
278
- ],
279
- "special chars test"
280
- )
281
- }),
282
- Suite.Default("Proxy Type Coverage", {
283
- // Test all proxy types
284
- butThenProxyTest: Given.SomeBaseString(
285
- ["butThenProxy should work correctly"],
286
- [],
287
- [
288
- Then.theButTheProxyReturns(
289
- "writeFileSync",
290
- "test/path/butThen/test.txt"
291
- )
292
- ],
293
- "butThenProxy test"
294
- ),
295
- andWhenProxyTest: Given.SomeBaseString(
296
- ["andWhenProxy should work correctly"],
297
- [],
298
- [
299
- Then.theButTheProxyReturns(
300
- "writeFileSync",
301
- "test/path/andWhen/test.txt"
302
- )
303
- ],
304
- "andWhenProxy test"
305
- ),
306
- beforeEachProxyTest: Given.SomeBaseString(
307
- ["beforeEachProxy should work correctly"],
308
- [],
309
- [
310
- Then.theButTheProxyReturns(
311
- "writeFileSync",
312
- "suite-1/beforeEach/test.txt"
313
- )
314
- ],
315
- "beforeEachProxy test"
316
- ),
317
- afterEachProxyTest: Given.SomeBaseString(
318
- ["afterEachProxy should work correctly"],
319
- [],
320
- [
321
- Then.theButTheProxyReturns(
322
- "writeFileSync",
323
- "suite-1/given-1/afterEach/test.txt"
324
- )
325
- ],
326
- "afterEachProxy test"
327
- )
328
- }),
329
- Suite.Default("Content Preservation", {
330
- // Verify content is preserved
331
- contentPreservationTest: Given.SomeBaseString(
332
- ["Proxies should preserve file content"],
333
- [],
334
- [
335
- Then.theButTheProxyReturns(
336
- "writeFileSync",
337
- "test/path/butThen/test.txt"
338
- ),
339
- Then.verifyContent("test content")
340
- ],
341
- "content preservation test"
342
- ),
343
- objectContentTest: Given.SomeBaseString(
344
- ["Proxies should preserve object content"],
345
- [],
346
- [
347
- Then.theButTheProxyReturns(
348
- "screencast",
349
- "test/path/butThen/screen.png"
350
- ),
351
- Then.verifyContent({ quality: 80, fullPage: true })
352
- ],
353
- "object content test"
354
- )
355
- }),
356
- Suite.Default("Error Cases", {
357
- invalidPathTest: Given.SomeBaseString(
358
- ["Proxies should handle invalid paths"],
359
- [],
360
- [
361
- Then.theButTheProxyReturns(
362
- "writeFileSync",
363
- "test/path/butThen/../invalid.txt"
364
- )
365
- ],
366
- "invalid path test"
367
- ),
368
- undefinedInputTest: Given.SomeBaseString(
369
- ["Proxies should handle undefined inputs"],
370
- [],
371
- [Then.theButTheProxyReturns("writeFileSync", void 0)],
372
- "undefined input test"
373
- )
374
- })
375
- ];
376
-
377
- // node_modules/chai/chai.js
378
- var __defProp = Object.defineProperty;
379
- var __getOwnPropNames = Object.getOwnPropertyNames;
380
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
381
- var __commonJS = (cb, mod) => function __require() {
382
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
383
- };
384
- var __export = (target, all) => {
385
- for (var name in all)
386
- __defProp(target, name, { get: all[name], enumerable: true });
387
- };
388
- var require_util = __commonJS({
389
- "(disabled):util"() {
390
- }
391
- });
392
- var utils_exports = {};
393
- __export(utils_exports, {
394
- addChainableMethod: () => addChainableMethod,
395
- addLengthGuard: () => addLengthGuard,
396
- addMethod: () => addMethod,
397
- addProperty: () => addProperty,
398
- checkError: () => check_error_exports,
399
- compareByInspect: () => compareByInspect,
400
- eql: () => deep_eql_default,
401
- expectTypes: () => expectTypes,
402
- flag: () => flag,
403
- getActual: () => getActual,
404
- getMessage: () => getMessage2,
405
- getName: () => getName,
406
- getOperator: () => getOperator,
407
- getOwnEnumerableProperties: () => getOwnEnumerableProperties,
408
- getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
409
- getPathInfo: () => getPathInfo,
410
- hasProperty: () => hasProperty,
411
- inspect: () => inspect2,
412
- isNaN: () => isNaN2,
413
- isNumeric: () => isNumeric,
414
- isProxyEnabled: () => isProxyEnabled,
415
- isRegExp: () => isRegExp2,
416
- objDisplay: () => objDisplay,
417
- overwriteChainableMethod: () => overwriteChainableMethod,
418
- overwriteMethod: () => overwriteMethod,
419
- overwriteProperty: () => overwriteProperty,
420
- proxify: () => proxify,
421
- test: () => test,
422
- transferFlags: () => transferFlags,
423
- type: () => type
424
- });
425
- var check_error_exports = {};
426
- __export(check_error_exports, {
427
- compatibleConstructor: () => compatibleConstructor,
428
- compatibleInstance: () => compatibleInstance,
429
- compatibleMessage: () => compatibleMessage,
430
- getConstructorName: () => getConstructorName,
431
- getMessage: () => getMessage
432
- });
433
- function isErrorInstance(obj) {
434
- return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
435
- }
436
- __name(isErrorInstance, "isErrorInstance");
437
- function isRegExp(obj) {
438
- return Object.prototype.toString.call(obj) === "[object RegExp]";
439
- }
440
- __name(isRegExp, "isRegExp");
441
- function compatibleInstance(thrown, errorLike) {
442
- return isErrorInstance(errorLike) && thrown === errorLike;
443
- }
444
- __name(compatibleInstance, "compatibleInstance");
445
- function compatibleConstructor(thrown, errorLike) {
446
- if (isErrorInstance(errorLike)) {
447
- return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
448
- } else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) {
449
- return thrown.constructor === errorLike || thrown instanceof errorLike;
450
- }
451
- return false;
452
- }
453
- __name(compatibleConstructor, "compatibleConstructor");
454
- function compatibleMessage(thrown, errMatcher) {
455
- const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
456
- if (isRegExp(errMatcher)) {
457
- return errMatcher.test(comparisonString);
458
- } else if (typeof errMatcher === "string") {
459
- return comparisonString.indexOf(errMatcher) !== -1;
460
- }
461
- return false;
462
- }
463
- __name(compatibleMessage, "compatibleMessage");
464
- function getConstructorName(errorLike) {
465
- let constructorName = errorLike;
466
- if (isErrorInstance(errorLike)) {
467
- constructorName = errorLike.constructor.name;
468
- } else if (typeof errorLike === "function") {
469
- constructorName = errorLike.name;
470
- if (constructorName === "") {
471
- const newConstructorName = new errorLike().name;
472
- constructorName = newConstructorName || constructorName;
473
- }
474
- }
475
- return constructorName;
476
- }
477
- __name(getConstructorName, "getConstructorName");
478
- function getMessage(errorLike) {
479
- let msg = "";
480
- if (errorLike && errorLike.message) {
481
- msg = errorLike.message;
482
- } else if (typeof errorLike === "string") {
483
- msg = errorLike;
484
- }
485
- return msg;
486
- }
487
- __name(getMessage, "getMessage");
488
- function flag(obj, key, value) {
489
- var flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
490
- if (arguments.length === 3) {
491
- flags[key] = value;
492
- } else {
493
- return flags[key];
494
- }
495
- }
496
- __name(flag, "flag");
497
- function test(obj, args) {
498
- var negate = flag(obj, "negate"), expr = args[0];
499
- return negate ? !expr : expr;
500
- }
501
- __name(test, "test");
502
- function type(obj) {
503
- if (typeof obj === "undefined") {
504
- return "undefined";
505
- }
506
- if (obj === null) {
507
- return "null";
508
- }
509
- const stringTag = obj[Symbol.toStringTag];
510
- if (typeof stringTag === "string") {
511
- return stringTag;
512
- }
513
- const type3 = Object.prototype.toString.call(obj).slice(8, -1);
514
- return type3;
515
- }
516
- __name(type, "type");
517
- var canElideFrames = "captureStackTrace" in Error;
518
- var AssertionError = class _AssertionError extends Error {
519
- static {
520
- __name(this, "AssertionError");
521
- }
522
- message;
523
- get name() {
524
- return "AssertionError";
525
- }
526
- get ok() {
527
- return false;
528
- }
529
- constructor(message = "Unspecified AssertionError", props, ssf) {
530
- super(message);
531
- this.message = message;
532
- if (canElideFrames) {
533
- Error.captureStackTrace(this, ssf || _AssertionError);
534
- }
535
- for (const key in props) {
536
- if (!(key in this)) {
537
- this[key] = props[key];
538
- }
539
- }
540
- }
541
- toJSON(stack) {
542
- return {
543
- ...this,
544
- name: this.name,
545
- message: this.message,
546
- ok: false,
547
- stack: stack !== false ? this.stack : void 0
548
- };
549
- }
550
- };
551
- function expectTypes(obj, types) {
552
- var flagMsg = flag(obj, "message");
553
- var ssfi = flag(obj, "ssfi");
554
- flagMsg = flagMsg ? flagMsg + ": " : "";
555
- obj = flag(obj, "object");
556
- types = types.map(function(t) {
557
- return t.toLowerCase();
558
- });
559
- types.sort();
560
- var str = types.map(function(t, index) {
561
- var art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a";
562
- var or = types.length > 1 && index === types.length - 1 ? "or " : "";
563
- return or + art + " " + t;
564
- }).join(", ");
565
- var objType = type(obj).toLowerCase();
566
- if (!types.some(function(expected) {
567
- return objType === expected;
568
- })) {
569
- throw new AssertionError(
570
- flagMsg + "object tested must be " + str + ", but " + objType + " given",
571
- void 0,
572
- ssfi
573
- );
574
- }
575
- }
576
- __name(expectTypes, "expectTypes");
577
- function getActual(obj, args) {
578
- return args.length > 4 ? args[4] : obj._obj;
579
- }
580
- __name(getActual, "getActual");
581
- var ansiColors = {
582
- bold: ["1", "22"],
583
- dim: ["2", "22"],
584
- italic: ["3", "23"],
585
- underline: ["4", "24"],
586
- // 5 & 6 are blinking
587
- inverse: ["7", "27"],
588
- hidden: ["8", "28"],
589
- strike: ["9", "29"],
590
- // 10-20 are fonts
591
- // 21-29 are resets for 1-9
592
- black: ["30", "39"],
593
- red: ["31", "39"],
594
- green: ["32", "39"],
595
- yellow: ["33", "39"],
596
- blue: ["34", "39"],
597
- magenta: ["35", "39"],
598
- cyan: ["36", "39"],
599
- white: ["37", "39"],
600
- brightblack: ["30;1", "39"],
601
- brightred: ["31;1", "39"],
602
- brightgreen: ["32;1", "39"],
603
- brightyellow: ["33;1", "39"],
604
- brightblue: ["34;1", "39"],
605
- brightmagenta: ["35;1", "39"],
606
- brightcyan: ["36;1", "39"],
607
- brightwhite: ["37;1", "39"],
608
- grey: ["90", "39"]
609
- };
610
- var styles = {
611
- special: "cyan",
612
- number: "yellow",
613
- bigint: "yellow",
614
- boolean: "yellow",
615
- undefined: "grey",
616
- null: "bold",
617
- string: "green",
618
- symbol: "green",
619
- date: "magenta",
620
- regexp: "red"
621
- };
622
- var truncator = "\u2026";
623
- function colorise(value, styleType) {
624
- const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
625
- if (!color) {
626
- return String(value);
627
- }
628
- return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
629
- }
630
- __name(colorise, "colorise");
631
- function normaliseOptions({
632
- showHidden = false,
633
- depth = 2,
634
- colors = false,
635
- customInspect = true,
636
- showProxy = false,
637
- maxArrayLength = Infinity,
638
- breakLength = Infinity,
639
- seen = [],
640
- // eslint-disable-next-line no-shadow
641
- truncate: truncate2 = Infinity,
642
- stylize = String
643
- } = {}, inspect3) {
644
- const options = {
645
- showHidden: Boolean(showHidden),
646
- depth: Number(depth),
647
- colors: Boolean(colors),
648
- customInspect: Boolean(customInspect),
649
- showProxy: Boolean(showProxy),
650
- maxArrayLength: Number(maxArrayLength),
651
- breakLength: Number(breakLength),
652
- truncate: Number(truncate2),
653
- seen,
654
- inspect: inspect3,
655
- stylize
656
- };
657
- if (options.colors) {
658
- options.stylize = colorise;
659
- }
660
- return options;
661
- }
662
- __name(normaliseOptions, "normaliseOptions");
663
- function isHighSurrogate(char) {
664
- return char >= "\uD800" && char <= "\uDBFF";
665
- }
666
- __name(isHighSurrogate, "isHighSurrogate");
667
- function truncate(string, length, tail = truncator) {
668
- string = String(string);
669
- const tailLength = tail.length;
670
- const stringLength = string.length;
671
- if (tailLength > length && stringLength > tailLength) {
672
- return tail;
673
- }
674
- if (stringLength > length && stringLength > tailLength) {
675
- let end = length - tailLength;
676
- if (end > 0 && isHighSurrogate(string[end - 1])) {
677
- end = end - 1;
678
- }
679
- return `${string.slice(0, end)}${tail}`;
680
- }
681
- return string;
682
- }
683
- __name(truncate, "truncate");
684
- function inspectList(list, options, inspectItem, separator = ", ") {
685
- inspectItem = inspectItem || options.inspect;
686
- const size = list.length;
687
- if (size === 0)
688
- return "";
689
- const originalLength = options.truncate;
690
- let output = "";
691
- let peek = "";
692
- let truncated = "";
693
- for (let i = 0; i < size; i += 1) {
694
- const last = i + 1 === list.length;
695
- const secondToLast = i + 2 === list.length;
696
- truncated = `${truncator}(${list.length - i})`;
697
- const value = list[i];
698
- options.truncate = originalLength - output.length - (last ? 0 : separator.length);
699
- const string = peek || inspectItem(value, options) + (last ? "" : separator);
700
- const nextLength = output.length + string.length;
701
- const truncatedLength = nextLength + truncated.length;
702
- if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
703
- break;
704
- }
705
- if (!last && !secondToLast && truncatedLength > originalLength) {
706
- break;
707
- }
708
- peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
709
- if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
710
- break;
711
- }
712
- output += string;
713
- if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
714
- truncated = `${truncator}(${list.length - i - 1})`;
715
- break;
716
- }
717
- truncated = "";
718
- }
719
- return `${output}${truncated}`;
720
- }
721
- __name(inspectList, "inspectList");
722
- function quoteComplexKey(key) {
723
- if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
724
- return key;
725
- }
726
- return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
727
- }
728
- __name(quoteComplexKey, "quoteComplexKey");
729
- function inspectProperty([key, value], options) {
730
- options.truncate -= 2;
731
- if (typeof key === "string") {
732
- key = quoteComplexKey(key);
733
- } else if (typeof key !== "number") {
734
- key = `[${options.inspect(key, options)}]`;
735
- }
736
- options.truncate -= key.length;
737
- value = options.inspect(value, options);
738
- return `${key}: ${value}`;
739
- }
740
- __name(inspectProperty, "inspectProperty");
741
- function inspectArray(array, options) {
742
- const nonIndexProperties = Object.keys(array).slice(array.length);
743
- if (!array.length && !nonIndexProperties.length)
744
- return "[]";
745
- options.truncate -= 4;
746
- const listContents = inspectList(array, options);
747
- options.truncate -= listContents.length;
748
- let propertyContents = "";
749
- if (nonIndexProperties.length) {
750
- propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
751
- }
752
- return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
753
- }
754
- __name(inspectArray, "inspectArray");
755
- var getArrayName = /* @__PURE__ */ __name((array) => {
756
- if (typeof Buffer === "function" && array instanceof Buffer) {
757
- return "Buffer";
758
- }
759
- if (array[Symbol.toStringTag]) {
760
- return array[Symbol.toStringTag];
761
- }
762
- return array.constructor.name;
763
- }, "getArrayName");
764
- function inspectTypedArray(array, options) {
765
- const name = getArrayName(array);
766
- options.truncate -= name.length + 4;
767
- const nonIndexProperties = Object.keys(array).slice(array.length);
768
- if (!array.length && !nonIndexProperties.length)
769
- return `${name}[]`;
770
- let output = "";
771
- for (let i = 0; i < array.length; i++) {
772
- const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
773
- options.truncate -= string.length;
774
- if (array[i] !== array.length && options.truncate <= 3) {
775
- output += `${truncator}(${array.length - array[i] + 1})`;
776
- break;
777
- }
778
- output += string;
779
- }
780
- let propertyContents = "";
781
- if (nonIndexProperties.length) {
782
- propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
783
- }
784
- return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
785
- }
786
- __name(inspectTypedArray, "inspectTypedArray");
787
- function inspectDate(dateObject, options) {
788
- const stringRepresentation = dateObject.toJSON();
789
- if (stringRepresentation === null) {
790
- return "Invalid Date";
791
- }
792
- const split = stringRepresentation.split("T");
793
- const date = split[0];
794
- return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
795
- }
796
- __name(inspectDate, "inspectDate");
797
- function inspectFunction(func, options) {
798
- const functionType = func[Symbol.toStringTag] || "Function";
799
- const name = func.name;
800
- if (!name) {
801
- return options.stylize(`[${functionType}]`, "special");
802
- }
803
- return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
804
- }
805
- __name(inspectFunction, "inspectFunction");
806
- function inspectMapEntry([key, value], options) {
807
- options.truncate -= 4;
808
- key = options.inspect(key, options);
809
- options.truncate -= key.length;
810
- value = options.inspect(value, options);
811
- return `${key} => ${value}`;
812
- }
813
- __name(inspectMapEntry, "inspectMapEntry");
814
- function mapToEntries(map) {
815
- const entries = [];
816
- map.forEach((value, key) => {
817
- entries.push([key, value]);
818
- });
819
- return entries;
820
- }
821
- __name(mapToEntries, "mapToEntries");
822
- function inspectMap(map, options) {
823
- const size = map.size - 1;
824
- if (size <= 0) {
825
- return "Map{}";
826
- }
827
- options.truncate -= 7;
828
- return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
829
- }
830
- __name(inspectMap, "inspectMap");
831
- var isNaN = Number.isNaN || ((i) => i !== i);
832
- function inspectNumber(number, options) {
833
- if (isNaN(number)) {
834
- return options.stylize("NaN", "number");
835
- }
836
- if (number === Infinity) {
837
- return options.stylize("Infinity", "number");
838
- }
839
- if (number === -Infinity) {
840
- return options.stylize("-Infinity", "number");
841
- }
842
- if (number === 0) {
843
- return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
844
- }
845
- return options.stylize(truncate(String(number), options.truncate), "number");
846
- }
847
- __name(inspectNumber, "inspectNumber");
848
- function inspectBigInt(number, options) {
849
- let nums = truncate(number.toString(), options.truncate - 1);
850
- if (nums !== truncator)
851
- nums += "n";
852
- return options.stylize(nums, "bigint");
853
- }
854
- __name(inspectBigInt, "inspectBigInt");
855
- function inspectRegExp(value, options) {
856
- const flags = value.toString().split("/")[2];
857
- const sourceLength = options.truncate - (2 + flags.length);
858
- const source = value.source;
859
- return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
860
- }
861
- __name(inspectRegExp, "inspectRegExp");
862
- function arrayFromSet(set2) {
863
- const values = [];
864
- set2.forEach((value) => {
865
- values.push(value);
866
- });
867
- return values;
868
- }
869
- __name(arrayFromSet, "arrayFromSet");
870
- function inspectSet(set2, options) {
871
- if (set2.size === 0)
872
- return "Set{}";
873
- options.truncate -= 7;
874
- return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
875
- }
876
- __name(inspectSet, "inspectSet");
877
- var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
878
- var escapeCharacters = {
879
- "\b": "\\b",
880
- " ": "\\t",
881
- "\n": "\\n",
882
- "\f": "\\f",
883
- "\r": "\\r",
884
- "'": "\\'",
885
- "\\": "\\\\"
886
- };
887
- var hex = 16;
888
- var unicodeLength = 4;
889
- function escape(char) {
890
- return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
891
- }
892
- __name(escape, "escape");
893
- function inspectString(string, options) {
894
- if (stringEscapeChars.test(string)) {
895
- string = string.replace(stringEscapeChars, escape);
896
- }
897
- return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
898
- }
899
- __name(inspectString, "inspectString");
900
- function inspectSymbol(value) {
901
- if ("description" in Symbol.prototype) {
902
- return value.description ? `Symbol(${value.description})` : "Symbol()";
903
- }
904
- return value.toString();
905
- }
906
- __name(inspectSymbol, "inspectSymbol");
907
- var getPromiseValue = /* @__PURE__ */ __name(() => "Promise{\u2026}", "getPromiseValue");
908
- try {
909
- const { getPromiseDetails, kPending, kRejected } = process.binding("util");
910
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
911
- getPromiseValue = /* @__PURE__ */ __name((value, options) => {
912
- const [state, innerValue] = getPromiseDetails(value);
913
- if (state === kPending) {
914
- return "Promise{<pending>}";
915
- }
916
- return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
917
- }, "getPromiseValue");
918
- }
919
- } catch (notNode) {
920
- }
921
- var promise_default = getPromiseValue;
922
- function inspectObject(object, options) {
923
- const properties = Object.getOwnPropertyNames(object);
924
- const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
925
- if (properties.length === 0 && symbols.length === 0) {
926
- return "{}";
927
- }
928
- options.truncate -= 4;
929
- options.seen = options.seen || [];
930
- if (options.seen.includes(object)) {
931
- return "[Circular]";
932
- }
933
- options.seen.push(object);
934
- const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
935
- const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
936
- options.seen.pop();
937
- let sep = "";
938
- if (propertyContents && symbolContents) {
939
- sep = ", ";
940
- }
941
- return `{ ${propertyContents}${sep}${symbolContents} }`;
942
- }
943
- __name(inspectObject, "inspectObject");
944
- var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
945
- function inspectClass(value, options) {
946
- let name = "";
947
- if (toStringTag && toStringTag in value) {
948
- name = value[toStringTag];
949
- }
950
- name = name || value.constructor.name;
951
- if (!name || name === "_class") {
952
- name = "<Anonymous Class>";
953
- }
954
- options.truncate -= name.length;
955
- return `${name}${inspectObject(value, options)}`;
956
- }
957
- __name(inspectClass, "inspectClass");
958
- function inspectArguments(args, options) {
959
- if (args.length === 0)
960
- return "Arguments[]";
961
- options.truncate -= 13;
962
- return `Arguments[ ${inspectList(args, options)} ]`;
963
- }
964
- __name(inspectArguments, "inspectArguments");
965
- var errorKeys = [
966
- "stack",
967
- "line",
968
- "column",
969
- "name",
970
- "message",
971
- "fileName",
972
- "lineNumber",
973
- "columnNumber",
974
- "number",
975
- "description",
976
- "cause"
977
- ];
978
- function inspectObject2(error, options) {
979
- const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
980
- const name = error.name;
981
- options.truncate -= name.length;
982
- let message = "";
983
- if (typeof error.message === "string") {
984
- message = truncate(error.message, options.truncate);
985
- } else {
986
- properties.unshift("message");
987
- }
988
- message = message ? `: ${message}` : "";
989
- options.truncate -= message.length + 5;
990
- options.seen = options.seen || [];
991
- if (options.seen.includes(error)) {
992
- return "[Circular]";
993
- }
994
- options.seen.push(error);
995
- const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
996
- return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
997
- }
998
- __name(inspectObject2, "inspectObject");
999
- function inspectAttribute([key, value], options) {
1000
- options.truncate -= 3;
1001
- if (!value) {
1002
- return `${options.stylize(String(key), "yellow")}`;
1003
- }
1004
- return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
1005
- }
1006
- __name(inspectAttribute, "inspectAttribute");
1007
- function inspectHTMLCollection(collection, options) {
1008
- return inspectList(collection, options, inspectHTML, "\n");
1009
- }
1010
- __name(inspectHTMLCollection, "inspectHTMLCollection");
1011
- function inspectHTML(element, options) {
1012
- const properties = element.getAttributeNames();
1013
- const name = element.tagName.toLowerCase();
1014
- const head = options.stylize(`<${name}`, "special");
1015
- const headClose = options.stylize(`>`, "special");
1016
- const tail = options.stylize(`</${name}>`, "special");
1017
- options.truncate -= name.length * 2 + 5;
1018
- let propertyContents = "";
1019
- if (properties.length > 0) {
1020
- propertyContents += " ";
1021
- propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
1022
- }
1023
- options.truncate -= propertyContents.length;
1024
- const truncate2 = options.truncate;
1025
- let children = inspectHTMLCollection(element.children, options);
1026
- if (children && children.length > truncate2) {
1027
- children = `${truncator}(${element.children.length})`;
1028
- }
1029
- return `${head}${propertyContents}${headClose}${children}${tail}`;
1030
- }
1031
- __name(inspectHTML, "inspectHTML");
1032
- var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
1033
- var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
1034
- var nodeInspect = false;
1035
- try {
1036
- const nodeUtil = require_util();
1037
- nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
1038
- } catch (noNodeInspect) {
1039
- nodeInspect = false;
1040
- }
1041
- var constructorMap = /* @__PURE__ */ new WeakMap();
1042
- var stringTagMap = {};
1043
- var baseTypesMap = {
1044
- undefined: (value, options) => options.stylize("undefined", "undefined"),
1045
- null: (value, options) => options.stylize("null", "null"),
1046
- boolean: (value, options) => options.stylize(String(value), "boolean"),
1047
- Boolean: (value, options) => options.stylize(String(value), "boolean"),
1048
- number: inspectNumber,
1049
- Number: inspectNumber,
1050
- bigint: inspectBigInt,
1051
- BigInt: inspectBigInt,
1052
- string: inspectString,
1053
- String: inspectString,
1054
- function: inspectFunction,
1055
- Function: inspectFunction,
1056
- symbol: inspectSymbol,
1057
- // A Symbol polyfill will return `Symbol` not `symbol` from typedetect
1058
- Symbol: inspectSymbol,
1059
- Array: inspectArray,
1060
- Date: inspectDate,
1061
- Map: inspectMap,
1062
- Set: inspectSet,
1063
- RegExp: inspectRegExp,
1064
- Promise: promise_default,
1065
- // WeakSet, WeakMap are totally opaque to us
1066
- WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
1067
- WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
1068
- Arguments: inspectArguments,
1069
- Int8Array: inspectTypedArray,
1070
- Uint8Array: inspectTypedArray,
1071
- Uint8ClampedArray: inspectTypedArray,
1072
- Int16Array: inspectTypedArray,
1073
- Uint16Array: inspectTypedArray,
1074
- Int32Array: inspectTypedArray,
1075
- Uint32Array: inspectTypedArray,
1076
- Float32Array: inspectTypedArray,
1077
- Float64Array: inspectTypedArray,
1078
- Generator: () => "",
1079
- DataView: () => "",
1080
- ArrayBuffer: () => "",
1081
- Error: inspectObject2,
1082
- HTMLCollection: inspectHTMLCollection,
1083
- NodeList: inspectHTMLCollection
1084
- };
1085
- var inspectCustom = /* @__PURE__ */ __name((value, options, type3) => {
1086
- if (chaiInspect in value && typeof value[chaiInspect] === "function") {
1087
- return value[chaiInspect](options);
1088
- }
1089
- if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === "function") {
1090
- return value[nodeInspect](options.depth, options);
1091
- }
1092
- if ("inspect" in value && typeof value.inspect === "function") {
1093
- return value.inspect(options.depth, options);
1094
- }
1095
- if ("constructor" in value && constructorMap.has(value.constructor)) {
1096
- return constructorMap.get(value.constructor)(value, options);
1097
- }
1098
- if (stringTagMap[type3]) {
1099
- return stringTagMap[type3](value, options);
1100
- }
1101
- return "";
1102
- }, "inspectCustom");
1103
- var toString = Object.prototype.toString;
1104
- function inspect(value, opts = {}) {
1105
- const options = normaliseOptions(opts, inspect);
1106
- const { customInspect } = options;
1107
- let type3 = value === null ? "null" : typeof value;
1108
- if (type3 === "object") {
1109
- type3 = toString.call(value).slice(8, -1);
1110
- }
1111
- if (type3 in baseTypesMap) {
1112
- return baseTypesMap[type3](value, options);
1113
- }
1114
- if (customInspect && value) {
1115
- const output = inspectCustom(value, options, type3);
1116
- if (output) {
1117
- if (typeof output === "string")
1118
- return output;
1119
- return inspect(output, options);
1120
- }
1121
- }
1122
- const proto = value ? Object.getPrototypeOf(value) : false;
1123
- if (proto === Object.prototype || proto === null) {
1124
- return inspectObject(value, options);
1125
- }
1126
- if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
1127
- return inspectHTML(value, options);
1128
- }
1129
- if ("constructor" in value) {
1130
- if (value.constructor !== Object) {
1131
- return inspectClass(value, options);
1132
- }
1133
- return inspectObject(value, options);
1134
- }
1135
- if (value === Object(value)) {
1136
- return inspectObject(value, options);
1137
- }
1138
- return options.stylize(String(value), type3);
1139
- }
1140
- __name(inspect, "inspect");
1141
- var config = {
1142
- /**
1143
- * ### config.includeStack
1144
- *
1145
- * User configurable property, influences whether stack trace
1146
- * is included in Assertion error message. Default of false
1147
- * suppresses stack trace in the error message.
1148
- *
1149
- * chai.config.includeStack = true; // enable stack on error
1150
- *
1151
- * @param {boolean}
1152
- * @public
1153
- */
1154
- includeStack: false,
1155
- /**
1156
- * ### config.showDiff
1157
- *
1158
- * User configurable property, influences whether or not
1159
- * the `showDiff` flag should be included in the thrown
1160
- * AssertionErrors. `false` will always be `false`; `true`
1161
- * will be true when the assertion has requested a diff
1162
- * be shown.
1163
- *
1164
- * @param {boolean}
1165
- * @public
1166
- */
1167
- showDiff: true,
1168
- /**
1169
- * ### config.truncateThreshold
1170
- *
1171
- * User configurable property, sets length threshold for actual and
1172
- * expected values in assertion errors. If this threshold is exceeded, for
1173
- * example for large data structures, the value is replaced with something
1174
- * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
1175
- *
1176
- * Set it to zero if you want to disable truncating altogether.
1177
- *
1178
- * This is especially userful when doing assertions on arrays: having this
1179
- * set to a reasonable large value makes the failure messages readily
1180
- * inspectable.
1181
- *
1182
- * chai.config.truncateThreshold = 0; // disable truncating
1183
- *
1184
- * @param {number}
1185
- * @public
1186
- */
1187
- truncateThreshold: 40,
1188
- /**
1189
- * ### config.useProxy
1190
- *
1191
- * User configurable property, defines if chai will use a Proxy to throw
1192
- * an error when a non-existent property is read, which protects users
1193
- * from typos when using property-based assertions.
1194
- *
1195
- * Set it to false if you want to disable this feature.
1196
- *
1197
- * chai.config.useProxy = false; // disable use of Proxy
1198
- *
1199
- * This feature is automatically disabled regardless of this config value
1200
- * in environments that don't support proxies.
1201
- *
1202
- * @param {boolean}
1203
- * @public
1204
- */
1205
- useProxy: true,
1206
- /**
1207
- * ### config.proxyExcludedKeys
1208
- *
1209
- * User configurable property, defines which properties should be ignored
1210
- * instead of throwing an error if they do not exist on the assertion.
1211
- * This is only applied if the environment Chai is running in supports proxies and
1212
- * if the `useProxy` configuration setting is enabled.
1213
- * By default, `then` and `inspect` will not throw an error if they do not exist on the
1214
- * assertion object because the `.inspect` property is read by `util.inspect` (for example, when
1215
- * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
1216
- *
1217
- * // By default these keys will not throw an error if they do not exist on the assertion object
1218
- * chai.config.proxyExcludedKeys = ['then', 'inspect'];
1219
- *
1220
- * @param {Array}
1221
- * @public
1222
- */
1223
- proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"],
1224
- /**
1225
- * ### config.deepEqual
1226
- *
1227
- * User configurable property, defines which a custom function to use for deepEqual
1228
- * comparisons.
1229
- * By default, the function used is the one from the `deep-eql` package without custom comparator.
1230
- *
1231
- * // use a custom comparator
1232
- * chai.config.deepEqual = (expected, actual) => {
1233
- * return chai.util.eql(expected, actual, {
1234
- * comparator: (expected, actual) => {
1235
- * // for non number comparison, use the default behavior
1236
- * if(typeof expected !== 'number') return null;
1237
- * // allow a difference of 10 between compared numbers
1238
- * return typeof actual === 'number' && Math.abs(actual - expected) < 10
1239
- * }
1240
- * })
1241
- * };
1242
- *
1243
- * @param {Function}
1244
- * @public
1245
- */
1246
- deepEqual: null
1247
- };
1248
- function inspect2(obj, showHidden, depth, colors) {
1249
- var options = {
1250
- colors,
1251
- depth: typeof depth === "undefined" ? 2 : depth,
1252
- showHidden,
1253
- truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
1254
- };
1255
- return inspect(obj, options);
1256
- }
1257
- __name(inspect2, "inspect");
1258
- function objDisplay(obj) {
1259
- var str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
1260
- if (config.truncateThreshold && str.length >= config.truncateThreshold) {
1261
- if (type3 === "[object Function]") {
1262
- return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
1263
- } else if (type3 === "[object Array]") {
1264
- return "[ Array(" + obj.length + ") ]";
1265
- } else if (type3 === "[object Object]") {
1266
- var keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
1267
- return "{ Object (" + kstr + ") }";
1268
- } else {
1269
- return str;
1270
- }
1271
- } else {
1272
- return str;
1273
- }
1274
- }
1275
- __name(objDisplay, "objDisplay");
1276
- function getMessage2(obj, args) {
1277
- var negate = flag(obj, "negate"), val = flag(obj, "object"), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, "message");
1278
- if (typeof msg === "function")
1279
- msg = msg();
1280
- msg = msg || "";
1281
- msg = msg.replace(/#\{this\}/g, function() {
1282
- return objDisplay(val);
1283
- }).replace(/#\{act\}/g, function() {
1284
- return objDisplay(actual);
1285
- }).replace(/#\{exp\}/g, function() {
1286
- return objDisplay(expected);
1287
- });
1288
- return flagMsg ? flagMsg + ": " + msg : msg;
1289
- }
1290
- __name(getMessage2, "getMessage");
1291
- function transferFlags(assertion, object, includeAll) {
1292
- var flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
1293
- if (!object.__flags) {
1294
- object.__flags = /* @__PURE__ */ Object.create(null);
1295
- }
1296
- includeAll = arguments.length === 3 ? includeAll : true;
1297
- for (var flag3 in flags) {
1298
- if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
1299
- object.__flags[flag3] = flags[flag3];
1300
- }
1301
- }
1302
- }
1303
- __name(transferFlags, "transferFlags");
1304
- function type2(obj) {
1305
- if (typeof obj === "undefined") {
1306
- return "undefined";
1307
- }
1308
- if (obj === null) {
1309
- return "null";
1310
- }
1311
- const stringTag = obj[Symbol.toStringTag];
1312
- if (typeof stringTag === "string") {
1313
- return stringTag;
1314
- }
1315
- const sliceStart = 8;
1316
- const sliceEnd = -1;
1317
- return Object.prototype.toString.call(obj).slice(sliceStart, sliceEnd);
1318
- }
1319
- __name(type2, "type");
1320
- function FakeMap() {
1321
- this._key = "chai/deep-eql__" + Math.random() + Date.now();
1322
- }
1323
- __name(FakeMap, "FakeMap");
1324
- FakeMap.prototype = {
1325
- get: /* @__PURE__ */ __name(function get(key) {
1326
- return key[this._key];
1327
- }, "get"),
1328
- set: /* @__PURE__ */ __name(function set(key, value) {
1329
- if (Object.isExtensible(key)) {
1330
- Object.defineProperty(key, this._key, {
1331
- value,
1332
- configurable: true
1333
- });
1334
- }
1335
- }, "set")
1336
- };
1337
- var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
1338
- function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
1339
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
1340
- return null;
1341
- }
1342
- var leftHandMap = memoizeMap.get(leftHandOperand);
1343
- if (leftHandMap) {
1344
- var result = leftHandMap.get(rightHandOperand);
1345
- if (typeof result === "boolean") {
1346
- return result;
1347
- }
1348
- }
1349
- return null;
1350
- }
1351
- __name(memoizeCompare, "memoizeCompare");
1352
- function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
1353
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
1354
- return;
1355
- }
1356
- var leftHandMap = memoizeMap.get(leftHandOperand);
1357
- if (leftHandMap) {
1358
- leftHandMap.set(rightHandOperand, result);
1359
- } else {
1360
- leftHandMap = new MemoizeMap();
1361
- leftHandMap.set(rightHandOperand, result);
1362
- memoizeMap.set(leftHandOperand, leftHandMap);
1363
- }
1364
- }
1365
- __name(memoizeSet, "memoizeSet");
1366
- var deep_eql_default = deepEqual;
1367
- function deepEqual(leftHandOperand, rightHandOperand, options) {
1368
- if (options && options.comparator) {
1369
- return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
1370
- }
1371
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
1372
- if (simpleResult !== null) {
1373
- return simpleResult;
1374
- }
1375
- return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
1376
- }
1377
- __name(deepEqual, "deepEqual");
1378
- function simpleEqual(leftHandOperand, rightHandOperand) {
1379
- if (leftHandOperand === rightHandOperand) {
1380
- return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
1381
- }
1382
- if (leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare
1383
- rightHandOperand !== rightHandOperand) {
1384
- return true;
1385
- }
1386
- if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
1387
- return false;
1388
- }
1389
- return null;
1390
- }
1391
- __name(simpleEqual, "simpleEqual");
1392
- function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
1393
- options = options || {};
1394
- options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
1395
- var comparator = options && options.comparator;
1396
- var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
1397
- if (memoizeResultLeft !== null) {
1398
- return memoizeResultLeft;
1399
- }
1400
- var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
1401
- if (memoizeResultRight !== null) {
1402
- return memoizeResultRight;
1403
- }
1404
- if (comparator) {
1405
- var comparatorResult = comparator(leftHandOperand, rightHandOperand);
1406
- if (comparatorResult === false || comparatorResult === true) {
1407
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
1408
- return comparatorResult;
1409
- }
1410
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
1411
- if (simpleResult !== null) {
1412
- return simpleResult;
1413
- }
1414
- }
1415
- var leftHandType = type2(leftHandOperand);
1416
- if (leftHandType !== type2(rightHandOperand)) {
1417
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
1418
- return false;
1419
- }
1420
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
1421
- var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
1422
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
1423
- return result;
1424
- }
1425
- __name(extensiveDeepEqual, "extensiveDeepEqual");
1426
- function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
1427
- switch (leftHandType) {
1428
- case "String":
1429
- case "Number":
1430
- case "Boolean":
1431
- case "Date":
1432
- return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
1433
- case "Promise":
1434
- case "Symbol":
1435
- case "function":
1436
- case "WeakMap":
1437
- case "WeakSet":
1438
- return leftHandOperand === rightHandOperand;
1439
- case "Error":
1440
- return keysEqual(leftHandOperand, rightHandOperand, ["name", "message", "code"], options);
1441
- case "Arguments":
1442
- case "Int8Array":
1443
- case "Uint8Array":
1444
- case "Uint8ClampedArray":
1445
- case "Int16Array":
1446
- case "Uint16Array":
1447
- case "Int32Array":
1448
- case "Uint32Array":
1449
- case "Float32Array":
1450
- case "Float64Array":
1451
- case "Array":
1452
- return iterableEqual(leftHandOperand, rightHandOperand, options);
1453
- case "RegExp":
1454
- return regexpEqual(leftHandOperand, rightHandOperand);
1455
- case "Generator":
1456
- return generatorEqual(leftHandOperand, rightHandOperand, options);
1457
- case "DataView":
1458
- return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
1459
- case "ArrayBuffer":
1460
- return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
1461
- case "Set":
1462
- return entriesEqual(leftHandOperand, rightHandOperand, options);
1463
- case "Map":
1464
- return entriesEqual(leftHandOperand, rightHandOperand, options);
1465
- case "Temporal.PlainDate":
1466
- case "Temporal.PlainTime":
1467
- case "Temporal.PlainDateTime":
1468
- case "Temporal.Instant":
1469
- case "Temporal.ZonedDateTime":
1470
- case "Temporal.PlainYearMonth":
1471
- case "Temporal.PlainMonthDay":
1472
- return leftHandOperand.equals(rightHandOperand);
1473
- case "Temporal.Duration":
1474
- return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
1475
- case "Temporal.TimeZone":
1476
- case "Temporal.Calendar":
1477
- return leftHandOperand.toString() === rightHandOperand.toString();
1478
- default:
1479
- return objectEqual(leftHandOperand, rightHandOperand, options);
1480
- }
1481
- }
1482
- __name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
1483
- function regexpEqual(leftHandOperand, rightHandOperand) {
1484
- return leftHandOperand.toString() === rightHandOperand.toString();
1485
- }
1486
- __name(regexpEqual, "regexpEqual");
1487
- function entriesEqual(leftHandOperand, rightHandOperand, options) {
1488
- try {
1489
- if (leftHandOperand.size !== rightHandOperand.size) {
1490
- return false;
1491
- }
1492
- if (leftHandOperand.size === 0) {
1493
- return true;
1494
- }
1495
- } catch (sizeError) {
1496
- return false;
1497
- }
1498
- var leftHandItems = [];
1499
- var rightHandItems = [];
1500
- leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
1501
- leftHandItems.push([key, value]);
1502
- }, "gatherEntries"));
1503
- rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
1504
- rightHandItems.push([key, value]);
1505
- }, "gatherEntries"));
1506
- return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
1507
- }
1508
- __name(entriesEqual, "entriesEqual");
1509
- function iterableEqual(leftHandOperand, rightHandOperand, options) {
1510
- var length = leftHandOperand.length;
1511
- if (length !== rightHandOperand.length) {
1512
- return false;
1513
- }
1514
- if (length === 0) {
1515
- return true;
1516
- }
1517
- var index = -1;
1518
- while (++index < length) {
1519
- if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
1520
- return false;
1521
- }
1522
- }
1523
- return true;
1524
- }
1525
- __name(iterableEqual, "iterableEqual");
1526
- function generatorEqual(leftHandOperand, rightHandOperand, options) {
1527
- return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
1528
- }
1529
- __name(generatorEqual, "generatorEqual");
1530
- function hasIteratorFunction(target) {
1531
- return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function";
1532
- }
1533
- __name(hasIteratorFunction, "hasIteratorFunction");
1534
- function getIteratorEntries(target) {
1535
- if (hasIteratorFunction(target)) {
1536
- try {
1537
- return getGeneratorEntries(target[Symbol.iterator]());
1538
- } catch (iteratorError) {
1539
- return [];
1540
- }
1541
- }
1542
- return [];
1543
- }
1544
- __name(getIteratorEntries, "getIteratorEntries");
1545
- function getGeneratorEntries(generator) {
1546
- var generatorResult = generator.next();
1547
- var accumulator = [generatorResult.value];
1548
- while (generatorResult.done === false) {
1549
- generatorResult = generator.next();
1550
- accumulator.push(generatorResult.value);
1551
- }
1552
- return accumulator;
1553
- }
1554
- __name(getGeneratorEntries, "getGeneratorEntries");
1555
- function getEnumerableKeys(target) {
1556
- var keys = [];
1557
- for (var key in target) {
1558
- keys.push(key);
1559
- }
1560
- return keys;
1561
- }
1562
- __name(getEnumerableKeys, "getEnumerableKeys");
1563
- function getEnumerableSymbols(target) {
1564
- var keys = [];
1565
- var allKeys = Object.getOwnPropertySymbols(target);
1566
- for (var i = 0; i < allKeys.length; i += 1) {
1567
- var key = allKeys[i];
1568
- if (Object.getOwnPropertyDescriptor(target, key).enumerable) {
1569
- keys.push(key);
1570
- }
1571
- }
1572
- return keys;
1573
- }
1574
- __name(getEnumerableSymbols, "getEnumerableSymbols");
1575
- function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
1576
- var length = keys.length;
1577
- if (length === 0) {
1578
- return true;
1579
- }
1580
- for (var i = 0; i < length; i += 1) {
1581
- if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
1582
- return false;
1583
- }
1584
- }
1585
- return true;
1586
- }
1587
- __name(keysEqual, "keysEqual");
1588
- function objectEqual(leftHandOperand, rightHandOperand, options) {
1589
- var leftHandKeys = getEnumerableKeys(leftHandOperand);
1590
- var rightHandKeys = getEnumerableKeys(rightHandOperand);
1591
- var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
1592
- var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
1593
- leftHandKeys = leftHandKeys.concat(leftHandSymbols);
1594
- rightHandKeys = rightHandKeys.concat(rightHandSymbols);
1595
- if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
1596
- if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) {
1597
- return false;
1598
- }
1599
- return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
1600
- }
1601
- var leftHandEntries = getIteratorEntries(leftHandOperand);
1602
- var rightHandEntries = getIteratorEntries(rightHandOperand);
1603
- if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
1604
- leftHandEntries.sort();
1605
- rightHandEntries.sort();
1606
- return iterableEqual(leftHandEntries, rightHandEntries, options);
1607
- }
1608
- if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) {
1609
- return true;
1610
- }
1611
- return false;
1612
- }
1613
- __name(objectEqual, "objectEqual");
1614
- function isPrimitive(value) {
1615
- return value === null || typeof value !== "object";
1616
- }
1617
- __name(isPrimitive, "isPrimitive");
1618
- function mapSymbols(arr) {
1619
- return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
1620
- if (typeof entry === "symbol") {
1621
- return entry.toString();
1622
- }
1623
- return entry;
1624
- }, "mapSymbol"));
1625
- }
1626
- __name(mapSymbols, "mapSymbols");
1627
- function hasProperty(obj, name) {
1628
- if (typeof obj === "undefined" || obj === null) {
1629
- return false;
1630
- }
1631
- return name in Object(obj);
1632
- }
1633
- __name(hasProperty, "hasProperty");
1634
- function parsePath(path) {
1635
- const str = path.replace(/([^\\])\[/g, "$1.[");
1636
- const parts = str.match(/(\\\.|[^.]+?)+/g);
1637
- return parts.map((value) => {
1638
- if (value === "constructor" || value === "__proto__" || value === "prototype") {
1639
- return {};
1640
- }
1641
- const regexp = /^\[(\d+)\]$/;
1642
- const mArr = regexp.exec(value);
1643
- let parsed = null;
1644
- if (mArr) {
1645
- parsed = { i: parseFloat(mArr[1]) };
1646
- } else {
1647
- parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
1648
- }
1649
- return parsed;
1650
- });
1651
- }
1652
- __name(parsePath, "parsePath");
1653
- function internalGetPathValue(obj, parsed, pathDepth) {
1654
- let temporaryValue = obj;
1655
- let res = null;
1656
- pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
1657
- for (let i = 0; i < pathDepth; i++) {
1658
- const part = parsed[i];
1659
- if (temporaryValue) {
1660
- if (typeof part.p === "undefined") {
1661
- temporaryValue = temporaryValue[part.i];
1662
- } else {
1663
- temporaryValue = temporaryValue[part.p];
1664
- }
1665
- if (i === pathDepth - 1) {
1666
- res = temporaryValue;
1667
- }
1668
- }
1669
- }
1670
- return res;
1671
- }
1672
- __name(internalGetPathValue, "internalGetPathValue");
1673
- function getPathInfo(obj, path) {
1674
- const parsed = parsePath(path);
1675
- const last = parsed[parsed.length - 1];
1676
- const info = {
1677
- parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
1678
- name: last.p || last.i,
1679
- value: internalGetPathValue(obj, parsed)
1680
- };
1681
- info.exists = hasProperty(info.parent, info.name);
1682
- return info;
1683
- }
1684
- __name(getPathInfo, "getPathInfo");
1685
- function Assertion(obj, msg, ssfi, lockSsfi) {
1686
- flag(this, "ssfi", ssfi || Assertion);
1687
- flag(this, "lockSsfi", lockSsfi);
1688
- flag(this, "object", obj);
1689
- flag(this, "message", msg);
1690
- flag(this, "eql", config.deepEqual || deep_eql_default);
1691
- return proxify(this);
1692
- }
1693
- __name(Assertion, "Assertion");
1694
- Object.defineProperty(Assertion, "includeStack", {
1695
- get: function() {
1696
- console.warn(
1697
- "Assertion.includeStack is deprecated, use chai.config.includeStack instead."
1698
- );
1699
- return config.includeStack;
1700
- },
1701
- set: function(value) {
1702
- console.warn(
1703
- "Assertion.includeStack is deprecated, use chai.config.includeStack instead."
1704
- );
1705
- config.includeStack = value;
1706
- }
1707
- });
1708
- Object.defineProperty(Assertion, "showDiff", {
1709
- get: function() {
1710
- console.warn(
1711
- "Assertion.showDiff is deprecated, use chai.config.showDiff instead."
1712
- );
1713
- return config.showDiff;
1714
- },
1715
- set: function(value) {
1716
- console.warn(
1717
- "Assertion.showDiff is deprecated, use chai.config.showDiff instead."
1718
- );
1719
- config.showDiff = value;
1720
- }
1721
- });
1722
- Assertion.addProperty = function(name, fn) {
1723
- addProperty(this.prototype, name, fn);
1724
- };
1725
- Assertion.addMethod = function(name, fn) {
1726
- addMethod(this.prototype, name, fn);
1727
- };
1728
- Assertion.addChainableMethod = function(name, fn, chainingBehavior) {
1729
- addChainableMethod(this.prototype, name, fn, chainingBehavior);
1730
- };
1731
- Assertion.overwriteProperty = function(name, fn) {
1732
- overwriteProperty(this.prototype, name, fn);
1733
- };
1734
- Assertion.overwriteMethod = function(name, fn) {
1735
- overwriteMethod(this.prototype, name, fn);
1736
- };
1737
- Assertion.overwriteChainableMethod = function(name, fn, chainingBehavior) {
1738
- overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
1739
- };
1740
- Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) {
1741
- var ok = test(this, arguments);
1742
- if (false !== showDiff)
1743
- showDiff = true;
1744
- if (void 0 === expected && void 0 === _actual)
1745
- showDiff = false;
1746
- if (true !== config.showDiff)
1747
- showDiff = false;
1748
- if (!ok) {
1749
- msg = getMessage2(this, arguments);
1750
- var actual = getActual(this, arguments);
1751
- var assertionErrorObjectProperties = {
1752
- actual,
1753
- expected,
1754
- showDiff
1755
- };
1756
- var operator = getOperator(this, arguments);
1757
- if (operator) {
1758
- assertionErrorObjectProperties.operator = operator;
1759
- }
1760
- throw new AssertionError(
1761
- msg,
1762
- assertionErrorObjectProperties,
1763
- config.includeStack ? this.assert : flag(this, "ssfi")
1764
- );
1765
- }
1766
- };
1767
- Object.defineProperty(Assertion.prototype, "_obj", {
1768
- get: function() {
1769
- return flag(this, "object");
1770
- },
1771
- set: function(val) {
1772
- flag(this, "object", val);
1773
- }
1774
- });
1775
- function isProxyEnabled() {
1776
- return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
1777
- }
1778
- __name(isProxyEnabled, "isProxyEnabled");
1779
- function addProperty(ctx, name, getter) {
1780
- getter = getter === void 0 ? function() {
1781
- } : getter;
1782
- Object.defineProperty(ctx, name, {
1783
- get: /* @__PURE__ */ __name(function propertyGetter() {
1784
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
1785
- flag(this, "ssfi", propertyGetter);
1786
- }
1787
- var result = getter.call(this);
1788
- if (result !== void 0)
1789
- return result;
1790
- var newAssertion = new Assertion();
1791
- transferFlags(this, newAssertion);
1792
- return newAssertion;
1793
- }, "propertyGetter"),
1794
- configurable: true
1795
- });
1796
- }
1797
- __name(addProperty, "addProperty");
1798
- var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {
1799
- }, "length");
1800
- function addLengthGuard(fn, assertionName, isChainable) {
1801
- if (!fnLengthDesc.configurable)
1802
- return fn;
1803
- Object.defineProperty(fn, "length", {
1804
- get: function() {
1805
- if (isChainable) {
1806
- throw Error(
1807
- "Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'
1808
- );
1809
- }
1810
- throw Error(
1811
- "Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'
1812
- );
1813
- }
1814
- });
1815
- return fn;
1816
- }
1817
- __name(addLengthGuard, "addLengthGuard");
1818
- function getProperties(object) {
1819
- var result = Object.getOwnPropertyNames(object);
1820
- function addProperty2(property) {
1821
- if (result.indexOf(property) === -1) {
1822
- result.push(property);
1823
- }
1824
- }
1825
- __name(addProperty2, "addProperty");
1826
- var proto = Object.getPrototypeOf(object);
1827
- while (proto !== null) {
1828
- Object.getOwnPropertyNames(proto).forEach(addProperty2);
1829
- proto = Object.getPrototypeOf(proto);
1830
- }
1831
- return result;
1832
- }
1833
- __name(getProperties, "getProperties");
1834
- var builtins = ["__flags", "__methods", "_obj", "assert"];
1835
- function proxify(obj, nonChainableMethodName) {
1836
- if (!isProxyEnabled())
1837
- return obj;
1838
- return new Proxy(obj, {
1839
- get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
1840
- if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
1841
- if (nonChainableMethodName) {
1842
- throw Error(
1843
- "Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".'
1844
- );
1845
- }
1846
- var suggestion = null;
1847
- var suggestionDistance = 4;
1848
- getProperties(target).forEach(function(prop) {
1849
- if (
1850
- // we actually mean to check `Object.prototype` here
1851
- // eslint-disable-next-line no-prototype-builtins
1852
- !Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1
1853
- ) {
1854
- var dist = stringDistanceCapped(property, prop, suggestionDistance);
1855
- if (dist < suggestionDistance) {
1856
- suggestion = prop;
1857
- suggestionDistance = dist;
1858
- }
1859
- }
1860
- });
1861
- if (suggestion !== null) {
1862
- throw Error(
1863
- "Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?'
1864
- );
1865
- } else {
1866
- throw Error("Invalid Chai property: " + property);
1867
- }
1868
- }
1869
- if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) {
1870
- flag(target, "ssfi", proxyGetter);
1871
- }
1872
- return Reflect.get(target, property);
1873
- }, "proxyGetter")
1874
- });
1875
- }
1876
- __name(proxify, "proxify");
1877
- function stringDistanceCapped(strA, strB, cap) {
1878
- if (Math.abs(strA.length - strB.length) >= cap) {
1879
- return cap;
1880
- }
1881
- var memo = [];
1882
- for (let i = 0; i <= strA.length; i++) {
1883
- memo[i] = Array(strB.length + 1).fill(0);
1884
- memo[i][0] = i;
1885
- }
1886
- for (let j = 0; j < strB.length; j++) {
1887
- memo[0][j] = j;
1888
- }
1889
- for (let i = 1; i <= strA.length; i++) {
1890
- var ch = strA.charCodeAt(i - 1);
1891
- for (let j = 1; j <= strB.length; j++) {
1892
- if (Math.abs(i - j) >= cap) {
1893
- memo[i][j] = cap;
1894
- continue;
1895
- }
1896
- memo[i][j] = Math.min(
1897
- memo[i - 1][j] + 1,
1898
- memo[i][j - 1] + 1,
1899
- memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1)
1900
- );
1901
- }
1902
- }
1903
- return memo[strA.length][strB.length];
1904
- }
1905
- __name(stringDistanceCapped, "stringDistanceCapped");
1906
- function addMethod(ctx, name, method) {
1907
- var methodWrapper = /* @__PURE__ */ __name(function() {
1908
- if (!flag(this, "lockSsfi")) {
1909
- flag(this, "ssfi", methodWrapper);
1910
- }
1911
- var result = method.apply(this, arguments);
1912
- if (result !== void 0)
1913
- return result;
1914
- var newAssertion = new Assertion();
1915
- transferFlags(this, newAssertion);
1916
- return newAssertion;
1917
- }, "methodWrapper");
1918
- addLengthGuard(methodWrapper, name, false);
1919
- ctx[name] = proxify(methodWrapper, name);
1920
- }
1921
- __name(addMethod, "addMethod");
1922
- function overwriteProperty(ctx, name, getter) {
1923
- var _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {
1924
- }, "_super");
1925
- if (_get && "function" === typeof _get.get)
1926
- _super = _get.get;
1927
- Object.defineProperty(ctx, name, {
1928
- get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
1929
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
1930
- flag(this, "ssfi", overwritingPropertyGetter);
1931
- }
1932
- var origLockSsfi = flag(this, "lockSsfi");
1933
- flag(this, "lockSsfi", true);
1934
- var result = getter(_super).call(this);
1935
- flag(this, "lockSsfi", origLockSsfi);
1936
- if (result !== void 0) {
1937
- return result;
1938
- }
1939
- var newAssertion = new Assertion();
1940
- transferFlags(this, newAssertion);
1941
- return newAssertion;
1942
- }, "overwritingPropertyGetter"),
1943
- configurable: true
1944
- });
1945
- }
1946
- __name(overwriteProperty, "overwriteProperty");
1947
- function overwriteMethod(ctx, name, method) {
1948
- var _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
1949
- throw new Error(name + " is not a function");
1950
- }, "_super");
1951
- if (_method && "function" === typeof _method)
1952
- _super = _method;
1953
- var overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
1954
- if (!flag(this, "lockSsfi")) {
1955
- flag(this, "ssfi", overwritingMethodWrapper);
1956
- }
1957
- var origLockSsfi = flag(this, "lockSsfi");
1958
- flag(this, "lockSsfi", true);
1959
- var result = method(_super).apply(this, arguments);
1960
- flag(this, "lockSsfi", origLockSsfi);
1961
- if (result !== void 0) {
1962
- return result;
1963
- }
1964
- var newAssertion = new Assertion();
1965
- transferFlags(this, newAssertion);
1966
- return newAssertion;
1967
- }, "overwritingMethodWrapper");
1968
- addLengthGuard(overwritingMethodWrapper, name, false);
1969
- ctx[name] = proxify(overwritingMethodWrapper, name);
1970
- }
1971
- __name(overwriteMethod, "overwriteMethod");
1972
- var canSetPrototype = typeof Object.setPrototypeOf === "function";
1973
- var testFn = /* @__PURE__ */ __name(function() {
1974
- }, "testFn");
1975
- var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
1976
- var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
1977
- if (typeof propDesc !== "object")
1978
- return true;
1979
- return !propDesc.configurable;
1980
- });
1981
- var call = Function.prototype.call;
1982
- var apply = Function.prototype.apply;
1983
- function addChainableMethod(ctx, name, method, chainingBehavior) {
1984
- if (typeof chainingBehavior !== "function") {
1985
- chainingBehavior = /* @__PURE__ */ __name(function() {
1986
- }, "chainingBehavior");
1987
- }
1988
- var chainableBehavior = {
1989
- method,
1990
- chainingBehavior
1991
- };
1992
- if (!ctx.__methods) {
1993
- ctx.__methods = {};
1994
- }
1995
- ctx.__methods[name] = chainableBehavior;
1996
- Object.defineProperty(ctx, name, {
1997
- get: /* @__PURE__ */ __name(function chainableMethodGetter() {
1998
- chainableBehavior.chainingBehavior.call(this);
1999
- var chainableMethodWrapper = /* @__PURE__ */ __name(function() {
2000
- if (!flag(this, "lockSsfi")) {
2001
- flag(this, "ssfi", chainableMethodWrapper);
2002
- }
2003
- var result = chainableBehavior.method.apply(this, arguments);
2004
- if (result !== void 0) {
2005
- return result;
2006
- }
2007
- var newAssertion = new Assertion();
2008
- transferFlags(this, newAssertion);
2009
- return newAssertion;
2010
- }, "chainableMethodWrapper");
2011
- addLengthGuard(chainableMethodWrapper, name, true);
2012
- if (canSetPrototype) {
2013
- var prototype = Object.create(this);
2014
- prototype.call = call;
2015
- prototype.apply = apply;
2016
- Object.setPrototypeOf(chainableMethodWrapper, prototype);
2017
- } else {
2018
- var asserterNames = Object.getOwnPropertyNames(ctx);
2019
- asserterNames.forEach(function(asserterName) {
2020
- if (excludeNames.indexOf(asserterName) !== -1) {
2021
- return;
2022
- }
2023
- var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
2024
- Object.defineProperty(chainableMethodWrapper, asserterName, pd);
2025
- });
2026
- }
2027
- transferFlags(this, chainableMethodWrapper);
2028
- return proxify(chainableMethodWrapper);
2029
- }, "chainableMethodGetter"),
2030
- configurable: true
2031
- });
2032
- }
2033
- __name(addChainableMethod, "addChainableMethod");
2034
- function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
2035
- var chainableBehavior = ctx.__methods[name];
2036
- var _chainingBehavior = chainableBehavior.chainingBehavior;
2037
- chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
2038
- var result = chainingBehavior(_chainingBehavior).call(this);
2039
- if (result !== void 0) {
2040
- return result;
2041
- }
2042
- var newAssertion = new Assertion();
2043
- transferFlags(this, newAssertion);
2044
- return newAssertion;
2045
- }, "overwritingChainableMethodGetter");
2046
- var _method = chainableBehavior.method;
2047
- chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
2048
- var result = method(_method).apply(this, arguments);
2049
- if (result !== void 0) {
2050
- return result;
2051
- }
2052
- var newAssertion = new Assertion();
2053
- transferFlags(this, newAssertion);
2054
- return newAssertion;
2055
- }, "overwritingChainableMethodWrapper");
2056
- }
2057
- __name(overwriteChainableMethod, "overwriteChainableMethod");
2058
- function compareByInspect(a, b) {
2059
- return inspect2(a) < inspect2(b) ? -1 : 1;
2060
- }
2061
- __name(compareByInspect, "compareByInspect");
2062
- function getOwnEnumerablePropertySymbols(obj) {
2063
- if (typeof Object.getOwnPropertySymbols !== "function")
2064
- return [];
2065
- return Object.getOwnPropertySymbols(obj).filter(function(sym) {
2066
- return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
2067
- });
2068
- }
2069
- __name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
2070
- function getOwnEnumerableProperties(obj) {
2071
- return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
2072
- }
2073
- __name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
2074
- var isNaN2 = Number.isNaN;
2075
- function isObjectType(obj) {
2076
- var objectType = type(obj);
2077
- var objectTypes = ["Array", "Object", "Function"];
2078
- return objectTypes.indexOf(objectType) !== -1;
2079
- }
2080
- __name(isObjectType, "isObjectType");
2081
- function getOperator(obj, args) {
2082
- var operator = flag(obj, "operator");
2083
- var negate = flag(obj, "negate");
2084
- var expected = args[3];
2085
- var msg = negate ? args[2] : args[1];
2086
- if (operator) {
2087
- return operator;
2088
- }
2089
- if (typeof msg === "function")
2090
- msg = msg();
2091
- msg = msg || "";
2092
- if (!msg) {
2093
- return void 0;
2094
- }
2095
- if (/\shave\s/.test(msg)) {
2096
- return void 0;
2097
- }
2098
- var isObject = isObjectType(expected);
2099
- if (/\snot\s/.test(msg)) {
2100
- return isObject ? "notDeepStrictEqual" : "notStrictEqual";
2101
- }
2102
- return isObject ? "deepStrictEqual" : "strictEqual";
2103
- }
2104
- __name(getOperator, "getOperator");
2105
- function getName(fn) {
2106
- return fn.name;
2107
- }
2108
- __name(getName, "getName");
2109
- function isRegExp2(obj) {
2110
- return Object.prototype.toString.call(obj) === "[object RegExp]";
2111
- }
2112
- __name(isRegExp2, "isRegExp");
2113
- function isNumeric(obj) {
2114
- return ["Number", "BigInt"].includes(type(obj));
2115
- }
2116
- __name(isNumeric, "isNumeric");
2117
- var { flag: flag2 } = utils_exports;
2118
- [
2119
- "to",
2120
- "be",
2121
- "been",
2122
- "is",
2123
- "and",
2124
- "has",
2125
- "have",
2126
- "with",
2127
- "that",
2128
- "which",
2129
- "at",
2130
- "of",
2131
- "same",
2132
- "but",
2133
- "does",
2134
- "still",
2135
- "also"
2136
- ].forEach(function(chain) {
2137
- Assertion.addProperty(chain);
2138
- });
2139
- Assertion.addProperty("not", function() {
2140
- flag2(this, "negate", true);
2141
- });
2142
- Assertion.addProperty("deep", function() {
2143
- flag2(this, "deep", true);
2144
- });
2145
- Assertion.addProperty("nested", function() {
2146
- flag2(this, "nested", true);
2147
- });
2148
- Assertion.addProperty("own", function() {
2149
- flag2(this, "own", true);
2150
- });
2151
- Assertion.addProperty("ordered", function() {
2152
- flag2(this, "ordered", true);
2153
- });
2154
- Assertion.addProperty("any", function() {
2155
- flag2(this, "any", true);
2156
- flag2(this, "all", false);
2157
- });
2158
- Assertion.addProperty("all", function() {
2159
- flag2(this, "all", true);
2160
- flag2(this, "any", false);
2161
- });
2162
- var functionTypes = {
2163
- function: [
2164
- "function",
2165
- "asyncfunction",
2166
- "generatorfunction",
2167
- "asyncgeneratorfunction"
2168
- ],
2169
- asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
2170
- generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
2171
- asyncgeneratorfunction: ["asyncgeneratorfunction"]
2172
- };
2173
- function an(type3, msg) {
2174
- if (msg)
2175
- flag2(this, "message", msg);
2176
- type3 = type3.toLowerCase();
2177
- var obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
2178
- const detectedType = type(obj).toLowerCase();
2179
- if (functionTypes["function"].includes(type3)) {
2180
- this.assert(
2181
- functionTypes[type3].includes(detectedType),
2182
- "expected #{this} to be " + article + type3,
2183
- "expected #{this} not to be " + article + type3
2184
- );
2185
- } else {
2186
- this.assert(
2187
- type3 === detectedType,
2188
- "expected #{this} to be " + article + type3,
2189
- "expected #{this} not to be " + article + type3
2190
- );
2191
- }
2192
- }
2193
- __name(an, "an");
2194
- Assertion.addChainableMethod("an", an);
2195
- Assertion.addChainableMethod("a", an);
2196
- function SameValueZero(a, b) {
2197
- return isNaN2(a) && isNaN2(b) || a === b;
2198
- }
2199
- __name(SameValueZero, "SameValueZero");
2200
- function includeChainingBehavior() {
2201
- flag2(this, "contains", true);
2202
- }
2203
- __name(includeChainingBehavior, "includeChainingBehavior");
2204
- function include(val, msg) {
2205
- if (msg)
2206
- flag2(this, "message", msg);
2207
- var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
2208
- flagMsg = flagMsg ? flagMsg + ": " : "";
2209
- var included = false;
2210
- switch (objType) {
2211
- case "string":
2212
- included = obj.indexOf(val) !== -1;
2213
- break;
2214
- case "weakset":
2215
- if (isDeep) {
2216
- throw new AssertionError(
2217
- flagMsg + "unable to use .deep.include with WeakSet",
2218
- void 0,
2219
- ssfi
2220
- );
2221
- }
2222
- included = obj.has(val);
2223
- break;
2224
- case "map":
2225
- obj.forEach(function(item) {
2226
- included = included || isEql(item, val);
2227
- });
2228
- break;
2229
- case "set":
2230
- if (isDeep) {
2231
- obj.forEach(function(item) {
2232
- included = included || isEql(item, val);
2233
- });
2234
- } else {
2235
- included = obj.has(val);
2236
- }
2237
- break;
2238
- case "array":
2239
- if (isDeep) {
2240
- included = obj.some(function(item) {
2241
- return isEql(item, val);
2242
- });
2243
- } else {
2244
- included = obj.indexOf(val) !== -1;
2245
- }
2246
- break;
2247
- default:
2248
- if (val !== Object(val)) {
2249
- throw new AssertionError(
2250
- flagMsg + "the given combination of arguments (" + objType + " and " + type(val).toLowerCase() + ") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a " + type(val).toLowerCase(),
2251
- void 0,
2252
- ssfi
2253
- );
2254
- }
2255
- var props = Object.keys(val), firstErr = null, numErrs = 0;
2256
- props.forEach(function(prop) {
2257
- var propAssertion = new Assertion(obj);
2258
- transferFlags(this, propAssertion, true);
2259
- flag2(propAssertion, "lockSsfi", true);
2260
- if (!negate || props.length === 1) {
2261
- propAssertion.property(prop, val[prop]);
2262
- return;
2263
- }
2264
- try {
2265
- propAssertion.property(prop, val[prop]);
2266
- } catch (err) {
2267
- if (!check_error_exports.compatibleConstructor(err, AssertionError)) {
2268
- throw err;
2269
- }
2270
- if (firstErr === null)
2271
- firstErr = err;
2272
- numErrs++;
2273
- }
2274
- }, this);
2275
- if (negate && props.length > 1 && numErrs === props.length) {
2276
- throw firstErr;
2277
- }
2278
- return;
2279
- }
2280
- this.assert(
2281
- included,
2282
- "expected #{this} to " + descriptor + "include " + inspect2(val),
2283
- "expected #{this} to not " + descriptor + "include " + inspect2(val)
2284
- );
2285
- }
2286
- __name(include, "include");
2287
- Assertion.addChainableMethod("include", include, includeChainingBehavior);
2288
- Assertion.addChainableMethod("contain", include, includeChainingBehavior);
2289
- Assertion.addChainableMethod("contains", include, includeChainingBehavior);
2290
- Assertion.addChainableMethod("includes", include, includeChainingBehavior);
2291
- Assertion.addProperty("ok", function() {
2292
- this.assert(
2293
- flag2(this, "object"),
2294
- "expected #{this} to be truthy",
2295
- "expected #{this} to be falsy"
2296
- );
2297
- });
2298
- Assertion.addProperty("true", function() {
2299
- this.assert(
2300
- true === flag2(this, "object"),
2301
- "expected #{this} to be true",
2302
- "expected #{this} to be false",
2303
- flag2(this, "negate") ? false : true
2304
- );
2305
- });
2306
- Assertion.addProperty("numeric", function() {
2307
- const object = flag2(this, "object");
2308
- this.assert(
2309
- ["Number", "BigInt"].includes(type(object)),
2310
- "expected #{this} to be numeric",
2311
- "expected #{this} to not be numeric",
2312
- flag2(this, "negate") ? false : true
2313
- );
2314
- });
2315
- Assertion.addProperty("callable", function() {
2316
- const val = flag2(this, "object");
2317
- const ssfi = flag2(this, "ssfi");
2318
- const message = flag2(this, "message");
2319
- const msg = message ? `${message}: ` : "";
2320
- const negate = flag2(this, "negate");
2321
- const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
2322
- const isCallable = [
2323
- "Function",
2324
- "AsyncFunction",
2325
- "GeneratorFunction",
2326
- "AsyncGeneratorFunction"
2327
- ].includes(type(val));
2328
- if (isCallable && negate || !isCallable && !negate) {
2329
- throw new AssertionError(assertionMessage, void 0, ssfi);
2330
- }
2331
- });
2332
- Assertion.addProperty("false", function() {
2333
- this.assert(
2334
- false === flag2(this, "object"),
2335
- "expected #{this} to be false",
2336
- "expected #{this} to be true",
2337
- flag2(this, "negate") ? true : false
2338
- );
2339
- });
2340
- Assertion.addProperty("null", function() {
2341
- this.assert(
2342
- null === flag2(this, "object"),
2343
- "expected #{this} to be null",
2344
- "expected #{this} not to be null"
2345
- );
2346
- });
2347
- Assertion.addProperty("undefined", function() {
2348
- this.assert(
2349
- void 0 === flag2(this, "object"),
2350
- "expected #{this} to be undefined",
2351
- "expected #{this} not to be undefined"
2352
- );
2353
- });
2354
- Assertion.addProperty("NaN", function() {
2355
- this.assert(
2356
- isNaN2(flag2(this, "object")),
2357
- "expected #{this} to be NaN",
2358
- "expected #{this} not to be NaN"
2359
- );
2360
- });
2361
- function assertExist() {
2362
- var val = flag2(this, "object");
2363
- this.assert(
2364
- val !== null && val !== void 0,
2365
- "expected #{this} to exist",
2366
- "expected #{this} to not exist"
2367
- );
2368
- }
2369
- __name(assertExist, "assertExist");
2370
- Assertion.addProperty("exist", assertExist);
2371
- Assertion.addProperty("exists", assertExist);
2372
- Assertion.addProperty("empty", function() {
2373
- var val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
2374
- flagMsg = flagMsg ? flagMsg + ": " : "";
2375
- switch (type(val).toLowerCase()) {
2376
- case "array":
2377
- case "string":
2378
- itemsCount = val.length;
2379
- break;
2380
- case "map":
2381
- case "set":
2382
- itemsCount = val.size;
2383
- break;
2384
- case "weakmap":
2385
- case "weakset":
2386
- throw new AssertionError(
2387
- flagMsg + ".empty was passed a weak collection",
2388
- void 0,
2389
- ssfi
2390
- );
2391
- case "function":
2392
- var msg = flagMsg + ".empty was passed a function " + getName(val);
2393
- throw new AssertionError(msg.trim(), void 0, ssfi);
2394
- default:
2395
- if (val !== Object(val)) {
2396
- throw new AssertionError(
2397
- flagMsg + ".empty was passed non-string primitive " + inspect2(val),
2398
- void 0,
2399
- ssfi
2400
- );
2401
- }
2402
- itemsCount = Object.keys(val).length;
2403
- }
2404
- this.assert(
2405
- 0 === itemsCount,
2406
- "expected #{this} to be empty",
2407
- "expected #{this} not to be empty"
2408
- );
2409
- });
2410
- function checkArguments() {
2411
- var obj = flag2(this, "object"), type3 = type(obj);
2412
- this.assert(
2413
- "Arguments" === type3,
2414
- "expected #{this} to be arguments but got " + type3,
2415
- "expected #{this} to not be arguments"
2416
- );
2417
- }
2418
- __name(checkArguments, "checkArguments");
2419
- Assertion.addProperty("arguments", checkArguments);
2420
- Assertion.addProperty("Arguments", checkArguments);
2421
- function assertEqual(val, msg) {
2422
- if (msg)
2423
- flag2(this, "message", msg);
2424
- var obj = flag2(this, "object");
2425
- if (flag2(this, "deep")) {
2426
- var prevLockSsfi = flag2(this, "lockSsfi");
2427
- flag2(this, "lockSsfi", true);
2428
- this.eql(val);
2429
- flag2(this, "lockSsfi", prevLockSsfi);
2430
- } else {
2431
- this.assert(
2432
- val === obj,
2433
- "expected #{this} to equal #{exp}",
2434
- "expected #{this} to not equal #{exp}",
2435
- val,
2436
- this._obj,
2437
- true
2438
- );
2439
- }
2440
- }
2441
- __name(assertEqual, "assertEqual");
2442
- Assertion.addMethod("equal", assertEqual);
2443
- Assertion.addMethod("equals", assertEqual);
2444
- Assertion.addMethod("eq", assertEqual);
2445
- function assertEql(obj, msg) {
2446
- if (msg)
2447
- flag2(this, "message", msg);
2448
- var eql = flag2(this, "eql");
2449
- this.assert(
2450
- eql(obj, flag2(this, "object")),
2451
- "expected #{this} to deeply equal #{exp}",
2452
- "expected #{this} to not deeply equal #{exp}",
2453
- obj,
2454
- this._obj,
2455
- true
2456
- );
2457
- }
2458
- __name(assertEql, "assertEql");
2459
- Assertion.addMethod("eql", assertEql);
2460
- Assertion.addMethod("eqls", assertEql);
2461
- function assertAbove(n, msg) {
2462
- if (msg)
2463
- flag2(this, "message", msg);
2464
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
2465
- if (doLength && objType !== "map" && objType !== "set") {
2466
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2467
- }
2468
- if (!doLength && objType === "date" && nType !== "date") {
2469
- throw new AssertionError(
2470
- msgPrefix + "the argument to above must be a date",
2471
- void 0,
2472
- ssfi
2473
- );
2474
- } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2475
- throw new AssertionError(
2476
- msgPrefix + "the argument to above must be a number",
2477
- void 0,
2478
- ssfi
2479
- );
2480
- } else if (!doLength && objType !== "date" && !isNumeric(obj)) {
2481
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
2482
- throw new AssertionError(
2483
- msgPrefix + "expected " + printObj + " to be a number or a date",
2484
- void 0,
2485
- ssfi
2486
- );
2487
- }
2488
- if (doLength) {
2489
- var descriptor = "length", itemsCount;
2490
- if (objType === "map" || objType === "set") {
2491
- descriptor = "size";
2492
- itemsCount = obj.size;
2493
- } else {
2494
- itemsCount = obj.length;
2495
- }
2496
- this.assert(
2497
- itemsCount > n,
2498
- "expected #{this} to have a " + descriptor + " above #{exp} but got #{act}",
2499
- "expected #{this} to not have a " + descriptor + " above #{exp}",
2500
- n,
2501
- itemsCount
2502
- );
2503
- } else {
2504
- this.assert(
2505
- obj > n,
2506
- "expected #{this} to be above #{exp}",
2507
- "expected #{this} to be at most #{exp}",
2508
- n
2509
- );
2510
- }
2511
- }
2512
- __name(assertAbove, "assertAbove");
2513
- Assertion.addMethod("above", assertAbove);
2514
- Assertion.addMethod("gt", assertAbove);
2515
- Assertion.addMethod("greaterThan", assertAbove);
2516
- function assertLeast(n, msg) {
2517
- if (msg)
2518
- flag2(this, "message", msg);
2519
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
2520
- if (doLength && objType !== "map" && objType !== "set") {
2521
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2522
- }
2523
- if (!doLength && objType === "date" && nType !== "date") {
2524
- errorMessage = msgPrefix + "the argument to least must be a date";
2525
- } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2526
- errorMessage = msgPrefix + "the argument to least must be a number";
2527
- } else if (!doLength && objType !== "date" && !isNumeric(obj)) {
2528
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
2529
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2530
- } else {
2531
- shouldThrow = false;
2532
- }
2533
- if (shouldThrow) {
2534
- throw new AssertionError(errorMessage, void 0, ssfi);
2535
- }
2536
- if (doLength) {
2537
- var descriptor = "length", itemsCount;
2538
- if (objType === "map" || objType === "set") {
2539
- descriptor = "size";
2540
- itemsCount = obj.size;
2541
- } else {
2542
- itemsCount = obj.length;
2543
- }
2544
- this.assert(
2545
- itemsCount >= n,
2546
- "expected #{this} to have a " + descriptor + " at least #{exp} but got #{act}",
2547
- "expected #{this} to have a " + descriptor + " below #{exp}",
2548
- n,
2549
- itemsCount
2550
- );
2551
- } else {
2552
- this.assert(
2553
- obj >= n,
2554
- "expected #{this} to be at least #{exp}",
2555
- "expected #{this} to be below #{exp}",
2556
- n
2557
- );
2558
- }
2559
- }
2560
- __name(assertLeast, "assertLeast");
2561
- Assertion.addMethod("least", assertLeast);
2562
- Assertion.addMethod("gte", assertLeast);
2563
- Assertion.addMethod("greaterThanOrEqual", assertLeast);
2564
- function assertBelow(n, msg) {
2565
- if (msg)
2566
- flag2(this, "message", msg);
2567
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
2568
- if (doLength && objType !== "map" && objType !== "set") {
2569
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2570
- }
2571
- if (!doLength && objType === "date" && nType !== "date") {
2572
- errorMessage = msgPrefix + "the argument to below must be a date";
2573
- } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2574
- errorMessage = msgPrefix + "the argument to below must be a number";
2575
- } else if (!doLength && objType !== "date" && !isNumeric(obj)) {
2576
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
2577
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2578
- } else {
2579
- shouldThrow = false;
2580
- }
2581
- if (shouldThrow) {
2582
- throw new AssertionError(errorMessage, void 0, ssfi);
2583
- }
2584
- if (doLength) {
2585
- var descriptor = "length", itemsCount;
2586
- if (objType === "map" || objType === "set") {
2587
- descriptor = "size";
2588
- itemsCount = obj.size;
2589
- } else {
2590
- itemsCount = obj.length;
2591
- }
2592
- this.assert(
2593
- itemsCount < n,
2594
- "expected #{this} to have a " + descriptor + " below #{exp} but got #{act}",
2595
- "expected #{this} to not have a " + descriptor + " below #{exp}",
2596
- n,
2597
- itemsCount
2598
- );
2599
- } else {
2600
- this.assert(
2601
- obj < n,
2602
- "expected #{this} to be below #{exp}",
2603
- "expected #{this} to be at least #{exp}",
2604
- n
2605
- );
2606
- }
2607
- }
2608
- __name(assertBelow, "assertBelow");
2609
- Assertion.addMethod("below", assertBelow);
2610
- Assertion.addMethod("lt", assertBelow);
2611
- Assertion.addMethod("lessThan", assertBelow);
2612
- function assertMost(n, msg) {
2613
- if (msg)
2614
- flag2(this, "message", msg);
2615
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
2616
- if (doLength && objType !== "map" && objType !== "set") {
2617
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2618
- }
2619
- if (!doLength && objType === "date" && nType !== "date") {
2620
- errorMessage = msgPrefix + "the argument to most must be a date";
2621
- } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2622
- errorMessage = msgPrefix + "the argument to most must be a number";
2623
- } else if (!doLength && objType !== "date" && !isNumeric(obj)) {
2624
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
2625
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2626
- } else {
2627
- shouldThrow = false;
2628
- }
2629
- if (shouldThrow) {
2630
- throw new AssertionError(errorMessage, void 0, ssfi);
2631
- }
2632
- if (doLength) {
2633
- var descriptor = "length", itemsCount;
2634
- if (objType === "map" || objType === "set") {
2635
- descriptor = "size";
2636
- itemsCount = obj.size;
2637
- } else {
2638
- itemsCount = obj.length;
2639
- }
2640
- this.assert(
2641
- itemsCount <= n,
2642
- "expected #{this} to have a " + descriptor + " at most #{exp} but got #{act}",
2643
- "expected #{this} to have a " + descriptor + " above #{exp}",
2644
- n,
2645
- itemsCount
2646
- );
2647
- } else {
2648
- this.assert(
2649
- obj <= n,
2650
- "expected #{this} to be at most #{exp}",
2651
- "expected #{this} to be above #{exp}",
2652
- n
2653
- );
2654
- }
2655
- }
2656
- __name(assertMost, "assertMost");
2657
- Assertion.addMethod("most", assertMost);
2658
- Assertion.addMethod("lte", assertMost);
2659
- Assertion.addMethod("lessThanOrEqual", assertMost);
2660
- Assertion.addMethod("within", function(start, finish, msg) {
2661
- if (msg)
2662
- flag2(this, "message", msg);
2663
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
2664
- if (doLength && objType !== "map" && objType !== "set") {
2665
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2666
- }
2667
- if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) {
2668
- errorMessage = msgPrefix + "the arguments to within must be dates";
2669
- } else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
2670
- errorMessage = msgPrefix + "the arguments to within must be numbers";
2671
- } else if (!doLength && objType !== "date" && !isNumeric(obj)) {
2672
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
2673
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2674
- } else {
2675
- shouldThrow = false;
2676
- }
2677
- if (shouldThrow) {
2678
- throw new AssertionError(errorMessage, void 0, ssfi);
2679
- }
2680
- if (doLength) {
2681
- var descriptor = "length", itemsCount;
2682
- if (objType === "map" || objType === "set") {
2683
- descriptor = "size";
2684
- itemsCount = obj.size;
2685
- } else {
2686
- itemsCount = obj.length;
2687
- }
2688
- this.assert(
2689
- itemsCount >= start && itemsCount <= finish,
2690
- "expected #{this} to have a " + descriptor + " within " + range,
2691
- "expected #{this} to not have a " + descriptor + " within " + range
2692
- );
2693
- } else {
2694
- this.assert(
2695
- obj >= start && obj <= finish,
2696
- "expected #{this} to be within " + range,
2697
- "expected #{this} to not be within " + range
2698
- );
2699
- }
2700
- });
2701
- function assertInstanceOf(constructor, msg) {
2702
- if (msg)
2703
- flag2(this, "message", msg);
2704
- var target = flag2(this, "object");
2705
- var ssfi = flag2(this, "ssfi");
2706
- var flagMsg = flag2(this, "message");
2707
- try {
2708
- var isInstanceOf = target instanceof constructor;
2709
- } catch (err) {
2710
- if (err instanceof TypeError) {
2711
- flagMsg = flagMsg ? flagMsg + ": " : "";
2712
- throw new AssertionError(
2713
- flagMsg + "The instanceof assertion needs a constructor but " + type(constructor) + " was given.",
2714
- void 0,
2715
- ssfi
2716
- );
2717
- }
2718
- throw err;
2719
- }
2720
- var name = getName(constructor);
2721
- if (name == null) {
2722
- name = "an unnamed constructor";
2723
- }
2724
- this.assert(
2725
- isInstanceOf,
2726
- "expected #{this} to be an instance of " + name,
2727
- "expected #{this} to not be an instance of " + name
2728
- );
2729
- }
2730
- __name(assertInstanceOf, "assertInstanceOf");
2731
- Assertion.addMethod("instanceof", assertInstanceOf);
2732
- Assertion.addMethod("instanceOf", assertInstanceOf);
2733
- function assertProperty(name, val, msg) {
2734
- if (msg)
2735
- flag2(this, "message", msg);
2736
- var isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
2737
- flagMsg = flagMsg ? flagMsg + ": " : "";
2738
- if (isNested) {
2739
- if (nameType !== "string") {
2740
- throw new AssertionError(
2741
- flagMsg + "the argument to property must be a string when using nested syntax",
2742
- void 0,
2743
- ssfi
2744
- );
2745
- }
2746
- } else {
2747
- if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") {
2748
- throw new AssertionError(
2749
- flagMsg + "the argument to property must be a string, number, or symbol",
2750
- void 0,
2751
- ssfi
2752
- );
2753
- }
2754
- }
2755
- if (isNested && isOwn) {
2756
- throw new AssertionError(
2757
- flagMsg + 'The "nested" and "own" flags cannot be combined.',
2758
- void 0,
2759
- ssfi
2760
- );
2761
- }
2762
- if (obj === null || obj === void 0) {
2763
- throw new AssertionError(
2764
- flagMsg + "Target cannot be null or undefined.",
2765
- void 0,
2766
- ssfi
2767
- );
2768
- }
2769
- var isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name], isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
2770
- var descriptor = "";
2771
- if (isDeep)
2772
- descriptor += "deep ";
2773
- if (isOwn)
2774
- descriptor += "own ";
2775
- if (isNested)
2776
- descriptor += "nested ";
2777
- descriptor += "property ";
2778
- var hasProperty2;
2779
- if (isOwn)
2780
- hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
2781
- else if (isNested)
2782
- hasProperty2 = pathInfo.exists;
2783
- else
2784
- hasProperty2 = hasProperty(obj, name);
2785
- if (!negate || arguments.length === 1) {
2786
- this.assert(
2787
- hasProperty2,
2788
- "expected #{this} to have " + descriptor + inspect2(name),
2789
- "expected #{this} to not have " + descriptor + inspect2(name)
2790
- );
2791
- }
2792
- if (arguments.length > 1) {
2793
- this.assert(
2794
- hasProperty2 && isEql(val, value),
2795
- "expected #{this} to have " + descriptor + inspect2(name) + " of #{exp}, but got #{act}",
2796
- "expected #{this} to not have " + descriptor + inspect2(name) + " of #{act}",
2797
- val,
2798
- value
2799
- );
2800
- }
2801
- flag2(this, "object", value);
2802
- }
2803
- __name(assertProperty, "assertProperty");
2804
- Assertion.addMethod("property", assertProperty);
2805
- function assertOwnProperty(_name, _value, _msg) {
2806
- flag2(this, "own", true);
2807
- assertProperty.apply(this, arguments);
2808
- }
2809
- __name(assertOwnProperty, "assertOwnProperty");
2810
- Assertion.addMethod("ownProperty", assertOwnProperty);
2811
- Assertion.addMethod("haveOwnProperty", assertOwnProperty);
2812
- function assertOwnPropertyDescriptor(name, descriptor, msg) {
2813
- if (typeof descriptor === "string") {
2814
- msg = descriptor;
2815
- descriptor = null;
2816
- }
2817
- if (msg)
2818
- flag2(this, "message", msg);
2819
- var obj = flag2(this, "object");
2820
- var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
2821
- var eql = flag2(this, "eql");
2822
- if (actualDescriptor && descriptor) {
2823
- this.assert(
2824
- eql(descriptor, actualDescriptor),
2825
- "expected the own property descriptor for " + inspect2(name) + " on #{this} to match " + inspect2(descriptor) + ", got " + inspect2(actualDescriptor),
2826
- "expected the own property descriptor for " + inspect2(name) + " on #{this} to not match " + inspect2(descriptor),
2827
- descriptor,
2828
- actualDescriptor,
2829
- true
2830
- );
2831
- } else {
2832
- this.assert(
2833
- actualDescriptor,
2834
- "expected #{this} to have an own property descriptor for " + inspect2(name),
2835
- "expected #{this} to not have an own property descriptor for " + inspect2(name)
2836
- );
2837
- }
2838
- flag2(this, "object", actualDescriptor);
2839
- }
2840
- __name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
2841
- Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
2842
- Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
2843
- function assertLengthChain() {
2844
- flag2(this, "doLength", true);
2845
- }
2846
- __name(assertLengthChain, "assertLengthChain");
2847
- function assertLength(n, msg) {
2848
- if (msg)
2849
- flag2(this, "message", msg);
2850
- var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
2851
- switch (objType) {
2852
- case "map":
2853
- case "set":
2854
- descriptor = "size";
2855
- itemsCount = obj.size;
2856
- break;
2857
- default:
2858
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2859
- itemsCount = obj.length;
2860
- }
2861
- this.assert(
2862
- itemsCount == n,
2863
- "expected #{this} to have a " + descriptor + " of #{exp} but got #{act}",
2864
- "expected #{this} to not have a " + descriptor + " of #{act}",
2865
- n,
2866
- itemsCount
2867
- );
2868
- }
2869
- __name(assertLength, "assertLength");
2870
- Assertion.addChainableMethod("length", assertLength, assertLengthChain);
2871
- Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
2872
- function assertMatch(re, msg) {
2873
- if (msg)
2874
- flag2(this, "message", msg);
2875
- var obj = flag2(this, "object");
2876
- this.assert(
2877
- re.exec(obj),
2878
- "expected #{this} to match " + re,
2879
- "expected #{this} not to match " + re
2880
- );
2881
- }
2882
- __name(assertMatch, "assertMatch");
2883
- Assertion.addMethod("match", assertMatch);
2884
- Assertion.addMethod("matches", assertMatch);
2885
- Assertion.addMethod("string", function(str, msg) {
2886
- if (msg)
2887
- flag2(this, "message", msg);
2888
- var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2889
- new Assertion(obj, flagMsg, ssfi, true).is.a("string");
2890
- this.assert(
2891
- ~obj.indexOf(str),
2892
- "expected #{this} to contain " + inspect2(str),
2893
- "expected #{this} to not contain " + inspect2(str)
2894
- );
2895
- });
2896
- function assertKeys(keys) {
2897
- var obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
2898
- flagMsg = flagMsg ? flagMsg + ": " : "";
2899
- var mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
2900
- if (objType === "Map" || objType === "Set") {
2901
- deepStr = isDeep ? "deeply " : "";
2902
- actual = [];
2903
- obj.forEach(function(val, key) {
2904
- actual.push(key);
2905
- });
2906
- if (keysType !== "Array") {
2907
- keys = Array.prototype.slice.call(arguments);
2908
- }
2909
- } else {
2910
- actual = getOwnEnumerableProperties(obj);
2911
- switch (keysType) {
2912
- case "Array":
2913
- if (arguments.length > 1) {
2914
- throw new AssertionError(mixedArgsMsg, void 0, ssfi);
2915
- }
2916
- break;
2917
- case "Object":
2918
- if (arguments.length > 1) {
2919
- throw new AssertionError(mixedArgsMsg, void 0, ssfi);
2920
- }
2921
- keys = Object.keys(keys);
2922
- break;
2923
- default:
2924
- keys = Array.prototype.slice.call(arguments);
2925
- }
2926
- keys = keys.map(function(val) {
2927
- return typeof val === "symbol" ? val : String(val);
2928
- });
2929
- }
2930
- if (!keys.length) {
2931
- throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
2932
- }
2933
- var len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
2934
- if (!any && !all) {
2935
- all = true;
2936
- }
2937
- if (any) {
2938
- ok = expected.some(function(expectedKey) {
2939
- return actual.some(function(actualKey) {
2940
- return isEql(expectedKey, actualKey);
2941
- });
2942
- });
2943
- }
2944
- if (all) {
2945
- ok = expected.every(function(expectedKey) {
2946
- return actual.some(function(actualKey) {
2947
- return isEql(expectedKey, actualKey);
2948
- });
2949
- });
2950
- if (!flag2(this, "contains")) {
2951
- ok = ok && keys.length == actual.length;
2952
- }
2953
- }
2954
- if (len > 1) {
2955
- keys = keys.map(function(key) {
2956
- return inspect2(key);
2957
- });
2958
- var last = keys.pop();
2959
- if (all) {
2960
- str = keys.join(", ") + ", and " + last;
2961
- }
2962
- if (any) {
2963
- str = keys.join(", ") + ", or " + last;
2964
- }
2965
- } else {
2966
- str = inspect2(keys[0]);
2967
- }
2968
- str = (len > 1 ? "keys " : "key ") + str;
2969
- str = (flag2(this, "contains") ? "contain " : "have ") + str;
2970
- this.assert(
2971
- ok,
2972
- "expected #{this} to " + deepStr + str,
2973
- "expected #{this} to not " + deepStr + str,
2974
- expected.slice(0).sort(compareByInspect),
2975
- actual.sort(compareByInspect),
2976
- true
2977
- );
2978
- }
2979
- __name(assertKeys, "assertKeys");
2980
- Assertion.addMethod("keys", assertKeys);
2981
- Assertion.addMethod("key", assertKeys);
2982
- function assertThrows(errorLike, errMsgMatcher, msg) {
2983
- if (msg)
2984
- flag2(this, "message", msg);
2985
- var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
2986
- new Assertion(obj, flagMsg, ssfi, true).is.a("function");
2987
- if (isRegExp2(errorLike) || typeof errorLike === "string") {
2988
- errMsgMatcher = errorLike;
2989
- errorLike = null;
2990
- }
2991
- let caughtErr;
2992
- let errorWasThrown = false;
2993
- try {
2994
- obj();
2995
- } catch (err) {
2996
- errorWasThrown = true;
2997
- caughtErr = err;
2998
- }
2999
- var everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
3000
- var everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
3001
- var errorLikeFail = false;
3002
- var errMsgMatcherFail = false;
3003
- if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
3004
- var errorLikeString = "an error";
3005
- if (errorLike instanceof Error) {
3006
- errorLikeString = "#{exp}";
3007
- } else if (errorLike) {
3008
- errorLikeString = check_error_exports.getConstructorName(errorLike);
3009
- }
3010
- let actual = caughtErr;
3011
- if (caughtErr instanceof Error) {
3012
- actual = caughtErr.toString();
3013
- } else if (typeof caughtErr === "string") {
3014
- actual = caughtErr;
3015
- } else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) {
3016
- try {
3017
- actual = check_error_exports.getConstructorName(caughtErr);
3018
- } catch (_err) {
3019
- }
3020
- }
3021
- this.assert(
3022
- errorWasThrown,
3023
- "expected #{this} to throw " + errorLikeString,
3024
- "expected #{this} to not throw an error but #{act} was thrown",
3025
- errorLike && errorLike.toString(),
3026
- actual
3027
- );
3028
- }
3029
- if (errorLike && caughtErr) {
3030
- if (errorLike instanceof Error) {
3031
- var isCompatibleInstance = check_error_exports.compatibleInstance(
3032
- caughtErr,
3033
- errorLike
3034
- );
3035
- if (isCompatibleInstance === negate) {
3036
- if (everyArgIsDefined && negate) {
3037
- errorLikeFail = true;
3038
- } else {
3039
- this.assert(
3040
- negate,
3041
- "expected #{this} to throw #{exp} but #{act} was thrown",
3042
- "expected #{this} to not throw #{exp}" + (caughtErr && !negate ? " but #{act} was thrown" : ""),
3043
- errorLike.toString(),
3044
- caughtErr.toString()
3045
- );
3046
- }
3047
- }
3048
- }
3049
- var isCompatibleConstructor = check_error_exports.compatibleConstructor(
3050
- caughtErr,
3051
- errorLike
3052
- );
3053
- if (isCompatibleConstructor === negate) {
3054
- if (everyArgIsDefined && negate) {
3055
- errorLikeFail = true;
3056
- } else {
3057
- this.assert(
3058
- negate,
3059
- "expected #{this} to throw #{exp} but #{act} was thrown",
3060
- "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
3061
- errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike),
3062
- caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr)
3063
- );
3064
- }
3065
- }
3066
- }
3067
- if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
3068
- var placeholder = "including";
3069
- if (isRegExp2(errMsgMatcher)) {
3070
- placeholder = "matching";
3071
- }
3072
- var isCompatibleMessage = check_error_exports.compatibleMessage(
3073
- caughtErr,
3074
- errMsgMatcher
3075
- );
3076
- if (isCompatibleMessage === negate) {
3077
- if (everyArgIsDefined && negate) {
3078
- errMsgMatcherFail = true;
3079
- } else {
3080
- this.assert(
3081
- negate,
3082
- "expected #{this} to throw error " + placeholder + " #{exp} but got #{act}",
3083
- "expected #{this} to throw error not " + placeholder + " #{exp}",
3084
- errMsgMatcher,
3085
- check_error_exports.getMessage(caughtErr)
3086
- );
3087
- }
3088
- }
3089
- }
3090
- if (errorLikeFail && errMsgMatcherFail) {
3091
- this.assert(
3092
- negate,
3093
- "expected #{this} to throw #{exp} but #{act} was thrown",
3094
- "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
3095
- errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike),
3096
- caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr)
3097
- );
3098
- }
3099
- flag2(this, "object", caughtErr);
3100
- }
3101
- __name(assertThrows, "assertThrows");
3102
- Assertion.addMethod("throw", assertThrows);
3103
- Assertion.addMethod("throws", assertThrows);
3104
- Assertion.addMethod("Throw", assertThrows);
3105
- function respondTo(method, msg) {
3106
- if (msg)
3107
- flag2(this, "message", msg);
3108
- var obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
3109
- this.assert(
3110
- "function" === typeof context,
3111
- "expected #{this} to respond to " + inspect2(method),
3112
- "expected #{this} to not respond to " + inspect2(method)
3113
- );
3114
- }
3115
- __name(respondTo, "respondTo");
3116
- Assertion.addMethod("respondTo", respondTo);
3117
- Assertion.addMethod("respondsTo", respondTo);
3118
- Assertion.addProperty("itself", function() {
3119
- flag2(this, "itself", true);
3120
- });
3121
- function satisfy(matcher, msg) {
3122
- if (msg)
3123
- flag2(this, "message", msg);
3124
- var obj = flag2(this, "object");
3125
- var result = matcher(obj);
3126
- this.assert(
3127
- result,
3128
- "expected #{this} to satisfy " + objDisplay(matcher),
3129
- "expected #{this} to not satisfy" + objDisplay(matcher),
3130
- flag2(this, "negate") ? false : true,
3131
- result
3132
- );
3133
- }
3134
- __name(satisfy, "satisfy");
3135
- Assertion.addMethod("satisfy", satisfy);
3136
- Assertion.addMethod("satisfies", satisfy);
3137
- function closeTo(expected, delta, msg) {
3138
- if (msg)
3139
- flag2(this, "message", msg);
3140
- var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
3141
- new Assertion(obj, flagMsg, ssfi, true).is.numeric;
3142
- let message = "A `delta` value is required for `closeTo`";
3143
- if (delta == void 0)
3144
- throw new AssertionError(
3145
- flagMsg ? `${flagMsg}: ${message}` : message,
3146
- void 0,
3147
- ssfi
3148
- );
3149
- new Assertion(delta, flagMsg, ssfi, true).is.numeric;
3150
- message = "A `expected` value is required for `closeTo`";
3151
- if (expected == void 0)
3152
- throw new AssertionError(
3153
- flagMsg ? `${flagMsg}: ${message}` : message,
3154
- void 0,
3155
- ssfi
3156
- );
3157
- new Assertion(expected, flagMsg, ssfi, true).is.numeric;
3158
- const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
3159
- const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
3160
- this.assert(
3161
- strip(abs(obj - expected)) <= delta,
3162
- "expected #{this} to be close to " + expected + " +/- " + delta,
3163
- "expected #{this} not to be close to " + expected + " +/- " + delta
3164
- );
3165
- }
3166
- __name(closeTo, "closeTo");
3167
- Assertion.addMethod("closeTo", closeTo);
3168
- Assertion.addMethod("approximately", closeTo);
3169
- function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
3170
- let superset = Array.from(_superset);
3171
- let subset = Array.from(_subset);
3172
- if (!contains) {
3173
- if (subset.length !== superset.length)
3174
- return false;
3175
- superset = superset.slice();
3176
- }
3177
- return subset.every(function(elem, idx) {
3178
- if (ordered)
3179
- return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
3180
- if (!cmp) {
3181
- var matchIdx = superset.indexOf(elem);
3182
- if (matchIdx === -1)
3183
- return false;
3184
- if (!contains)
3185
- superset.splice(matchIdx, 1);
3186
- return true;
3187
- }
3188
- return superset.some(function(elem2, matchIdx2) {
3189
- if (!cmp(elem, elem2))
3190
- return false;
3191
- if (!contains)
3192
- superset.splice(matchIdx2, 1);
3193
- return true;
3194
- });
3195
- });
3196
- }
3197
- __name(isSubsetOf, "isSubsetOf");
3198
- Assertion.addMethod("members", function(subset, msg) {
3199
- if (msg)
3200
- flag2(this, "message", msg);
3201
- var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
3202
- new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
3203
- new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
3204
- var contains = flag2(this, "contains");
3205
- var ordered = flag2(this, "ordered");
3206
- var subject, failMsg, failNegateMsg;
3207
- if (contains) {
3208
- subject = ordered ? "an ordered superset" : "a superset";
3209
- failMsg = "expected #{this} to be " + subject + " of #{exp}";
3210
- failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
3211
- } else {
3212
- subject = ordered ? "ordered members" : "members";
3213
- failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
3214
- failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
3215
- }
3216
- var cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
3217
- this.assert(
3218
- isSubsetOf(subset, obj, cmp, contains, ordered),
3219
- failMsg,
3220
- failNegateMsg,
3221
- subset,
3222
- obj,
3223
- true
3224
- );
3225
- });
3226
- Assertion.addProperty("iterable", function(msg) {
3227
- if (msg)
3228
- flag2(this, "message", msg);
3229
- var obj = flag2(this, "object");
3230
- this.assert(
3231
- obj != void 0 && obj[Symbol.iterator],
3232
- "expected #{this} to be an iterable",
3233
- "expected #{this} to not be an iterable",
3234
- obj
3235
- );
3236
- });
3237
- function oneOf(list, msg) {
3238
- if (msg)
3239
- flag2(this, "message", msg);
3240
- var expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
3241
- new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
3242
- if (contains) {
3243
- this.assert(
3244
- list.some(function(possibility) {
3245
- return expected.indexOf(possibility) > -1;
3246
- }),
3247
- "expected #{this} to contain one of #{exp}",
3248
- "expected #{this} to not contain one of #{exp}",
3249
- list,
3250
- expected
3251
- );
3252
- } else {
3253
- if (isDeep) {
3254
- this.assert(
3255
- list.some(function(possibility) {
3256
- return eql(expected, possibility);
3257
- }),
3258
- "expected #{this} to deeply equal one of #{exp}",
3259
- "expected #{this} to deeply equal one of #{exp}",
3260
- list,
3261
- expected
3262
- );
3263
- } else {
3264
- this.assert(
3265
- list.indexOf(expected) > -1,
3266
- "expected #{this} to be one of #{exp}",
3267
- "expected #{this} to not be one of #{exp}",
3268
- list,
3269
- expected
3270
- );
3271
- }
3272
- }
3273
- }
3274
- __name(oneOf, "oneOf");
3275
- Assertion.addMethod("oneOf", oneOf);
3276
- function assertChanges(subject, prop, msg) {
3277
- if (msg)
3278
- flag2(this, "message", msg);
3279
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
3280
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
3281
- var initial;
3282
- if (!prop) {
3283
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
3284
- initial = subject();
3285
- } else {
3286
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
3287
- initial = subject[prop];
3288
- }
3289
- fn();
3290
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
3291
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
3292
- flag2(this, "deltaMsgObj", msgObj);
3293
- flag2(this, "initialDeltaValue", initial);
3294
- flag2(this, "finalDeltaValue", final);
3295
- flag2(this, "deltaBehavior", "change");
3296
- flag2(this, "realDelta", final !== initial);
3297
- this.assert(
3298
- initial !== final,
3299
- "expected " + msgObj + " to change",
3300
- "expected " + msgObj + " to not change"
3301
- );
3302
- }
3303
- __name(assertChanges, "assertChanges");
3304
- Assertion.addMethod("change", assertChanges);
3305
- Assertion.addMethod("changes", assertChanges);
3306
- function assertIncreases(subject, prop, msg) {
3307
- if (msg)
3308
- flag2(this, "message", msg);
3309
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
3310
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
3311
- var initial;
3312
- if (!prop) {
3313
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
3314
- initial = subject();
3315
- } else {
3316
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
3317
- initial = subject[prop];
3318
- }
3319
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
3320
- fn();
3321
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
3322
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
3323
- flag2(this, "deltaMsgObj", msgObj);
3324
- flag2(this, "initialDeltaValue", initial);
3325
- flag2(this, "finalDeltaValue", final);
3326
- flag2(this, "deltaBehavior", "increase");
3327
- flag2(this, "realDelta", final - initial);
3328
- this.assert(
3329
- final - initial > 0,
3330
- "expected " + msgObj + " to increase",
3331
- "expected " + msgObj + " to not increase"
3332
- );
3333
- }
3334
- __name(assertIncreases, "assertIncreases");
3335
- Assertion.addMethod("increase", assertIncreases);
3336
- Assertion.addMethod("increases", assertIncreases);
3337
- function assertDecreases(subject, prop, msg) {
3338
- if (msg)
3339
- flag2(this, "message", msg);
3340
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
3341
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
3342
- var initial;
3343
- if (!prop) {
3344
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
3345
- initial = subject();
3346
- } else {
3347
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
3348
- initial = subject[prop];
3349
- }
3350
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
3351
- fn();
3352
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
3353
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
3354
- flag2(this, "deltaMsgObj", msgObj);
3355
- flag2(this, "initialDeltaValue", initial);
3356
- flag2(this, "finalDeltaValue", final);
3357
- flag2(this, "deltaBehavior", "decrease");
3358
- flag2(this, "realDelta", initial - final);
3359
- this.assert(
3360
- final - initial < 0,
3361
- "expected " + msgObj + " to decrease",
3362
- "expected " + msgObj + " to not decrease"
3363
- );
3364
- }
3365
- __name(assertDecreases, "assertDecreases");
3366
- Assertion.addMethod("decrease", assertDecreases);
3367
- Assertion.addMethod("decreases", assertDecreases);
3368
- function assertDelta(delta, msg) {
3369
- if (msg)
3370
- flag2(this, "message", msg);
3371
- var msgObj = flag2(this, "deltaMsgObj");
3372
- var initial = flag2(this, "initialDeltaValue");
3373
- var final = flag2(this, "finalDeltaValue");
3374
- var behavior = flag2(this, "deltaBehavior");
3375
- var realDelta = flag2(this, "realDelta");
3376
- var expression;
3377
- if (behavior === "change") {
3378
- expression = Math.abs(final - initial) === Math.abs(delta);
3379
- } else {
3380
- expression = realDelta === Math.abs(delta);
3381
- }
3382
- this.assert(
3383
- expression,
3384
- "expected " + msgObj + " to " + behavior + " by " + delta,
3385
- "expected " + msgObj + " to not " + behavior + " by " + delta
3386
- );
3387
- }
3388
- __name(assertDelta, "assertDelta");
3389
- Assertion.addMethod("by", assertDelta);
3390
- Assertion.addProperty("extensible", function() {
3391
- var obj = flag2(this, "object");
3392
- var isExtensible = obj === Object(obj) && Object.isExtensible(obj);
3393
- this.assert(
3394
- isExtensible,
3395
- "expected #{this} to be extensible",
3396
- "expected #{this} to not be extensible"
3397
- );
3398
- });
3399
- Assertion.addProperty("sealed", function() {
3400
- var obj = flag2(this, "object");
3401
- var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
3402
- this.assert(
3403
- isSealed,
3404
- "expected #{this} to be sealed",
3405
- "expected #{this} to not be sealed"
3406
- );
3407
- });
3408
- Assertion.addProperty("frozen", function() {
3409
- var obj = flag2(this, "object");
3410
- var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
3411
- this.assert(
3412
- isFrozen,
3413
- "expected #{this} to be frozen",
3414
- "expected #{this} to not be frozen"
3415
- );
3416
- });
3417
- Assertion.addProperty("finite", function(_msg) {
3418
- var obj = flag2(this, "object");
3419
- this.assert(
3420
- typeof obj === "number" && isFinite(obj),
3421
- "expected #{this} to be a finite number",
3422
- "expected #{this} to not be a finite number"
3423
- );
3424
- });
3425
- function compareSubset(expected, actual) {
3426
- if (expected === actual) {
3427
- return true;
3428
- }
3429
- if (typeof actual !== typeof expected) {
3430
- return false;
3431
- }
3432
- if (typeof expected !== "object" || expected === null) {
3433
- return expected === actual;
3434
- }
3435
- if (!actual) {
3436
- return false;
3437
- }
3438
- if (Array.isArray(expected)) {
3439
- if (!Array.isArray(actual)) {
3440
- return false;
3441
- }
3442
- return expected.every(function(exp) {
3443
- return actual.some(function(act) {
3444
- return compareSubset(exp, act);
3445
- });
3446
- });
3447
- }
3448
- if (expected instanceof Date) {
3449
- if (actual instanceof Date) {
3450
- return expected.getTime() === actual.getTime();
3451
- } else {
3452
- return false;
3453
- }
3454
- }
3455
- return Object.keys(expected).every(function(key) {
3456
- var expectedValue = expected[key];
3457
- var actualValue = actual[key];
3458
- if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
3459
- return compareSubset(expectedValue, actualValue);
3460
- }
3461
- if (typeof expectedValue === "function") {
3462
- return expectedValue(actualValue);
3463
- }
3464
- return actualValue === expectedValue;
3465
- });
3466
- }
3467
- __name(compareSubset, "compareSubset");
3468
- Assertion.addMethod("containSubset", function(expected) {
3469
- const actual = flag(this, "object");
3470
- const showDiff = config.showDiff;
3471
- this.assert(
3472
- compareSubset(expected, actual),
3473
- "expected #{act} to contain subset #{exp}",
3474
- "expected #{act} to not contain subset #{exp}",
3475
- expected,
3476
- actual,
3477
- showDiff
3478
- );
3479
- });
3480
- function expect(val, message) {
3481
- return new Assertion(val, message);
3482
- }
3483
- __name(expect, "expect");
3484
- expect.fail = function(actual, expected, message, operator) {
3485
- if (arguments.length < 2) {
3486
- message = actual;
3487
- actual = void 0;
3488
- }
3489
- message = message || "expect.fail()";
3490
- throw new AssertionError(
3491
- message,
3492
- {
3493
- actual,
3494
- expected,
3495
- operator
3496
- },
3497
- expect.fail
3498
- );
3499
- };
3500
- var should_exports = {};
3501
- __export(should_exports, {
3502
- Should: () => Should,
3503
- should: () => should
3504
- });
3505
- function loadShould() {
3506
- function shouldGetter() {
3507
- if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) {
3508
- return new Assertion(this.valueOf(), null, shouldGetter);
3509
- }
3510
- return new Assertion(this, null, shouldGetter);
3511
- }
3512
- __name(shouldGetter, "shouldGetter");
3513
- function shouldSetter(value) {
3514
- Object.defineProperty(this, "should", {
3515
- value,
3516
- enumerable: true,
3517
- configurable: true,
3518
- writable: true
3519
- });
3520
- }
3521
- __name(shouldSetter, "shouldSetter");
3522
- Object.defineProperty(Object.prototype, "should", {
3523
- set: shouldSetter,
3524
- get: shouldGetter,
3525
- configurable: true
3526
- });
3527
- var should2 = {};
3528
- should2.fail = function(actual, expected, message, operator) {
3529
- if (arguments.length < 2) {
3530
- message = actual;
3531
- actual = void 0;
3532
- }
3533
- message = message || "should.fail()";
3534
- throw new AssertionError(
3535
- message,
3536
- {
3537
- actual,
3538
- expected,
3539
- operator
3540
- },
3541
- should2.fail
3542
- );
3543
- };
3544
- should2.equal = function(actual, expected, message) {
3545
- new Assertion(actual, message).to.equal(expected);
3546
- };
3547
- should2.Throw = function(fn, errt, errs, msg) {
3548
- new Assertion(fn, msg).to.Throw(errt, errs);
3549
- };
3550
- should2.exist = function(val, msg) {
3551
- new Assertion(val, msg).to.exist;
3552
- };
3553
- should2.not = {};
3554
- should2.not.equal = function(actual, expected, msg) {
3555
- new Assertion(actual, msg).to.not.equal(expected);
3556
- };
3557
- should2.not.Throw = function(fn, errt, errs, msg) {
3558
- new Assertion(fn, msg).to.not.Throw(errt, errs);
3559
- };
3560
- should2.not.exist = function(val, msg) {
3561
- new Assertion(val, msg).to.not.exist;
3562
- };
3563
- should2["throw"] = should2["Throw"];
3564
- should2.not["throw"] = should2.not["Throw"];
3565
- return should2;
3566
- }
3567
- __name(loadShould, "loadShould");
3568
- var should = loadShould;
3569
- var Should = loadShould;
3570
- function assert(express, errmsg) {
3571
- var test2 = new Assertion(null, null, assert, true);
3572
- test2.assert(express, errmsg, "[ negation message unavailable ]");
3573
- }
3574
- __name(assert, "assert");
3575
- assert.fail = function(actual, expected, message, operator) {
3576
- if (arguments.length < 2) {
3577
- message = actual;
3578
- actual = void 0;
3579
- }
3580
- message = message || "assert.fail()";
3581
- throw new AssertionError(
3582
- message,
3583
- {
3584
- actual,
3585
- expected,
3586
- operator
3587
- },
3588
- assert.fail
3589
- );
3590
- };
3591
- assert.isOk = function(val, msg) {
3592
- new Assertion(val, msg, assert.isOk, true).is.ok;
3593
- };
3594
- assert.isNotOk = function(val, msg) {
3595
- new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
3596
- };
3597
- assert.equal = function(act, exp, msg) {
3598
- var test2 = new Assertion(act, msg, assert.equal, true);
3599
- test2.assert(
3600
- exp == flag(test2, "object"),
3601
- "expected #{this} to equal #{exp}",
3602
- "expected #{this} to not equal #{act}",
3603
- exp,
3604
- act,
3605
- true
3606
- );
3607
- };
3608
- assert.notEqual = function(act, exp, msg) {
3609
- var test2 = new Assertion(act, msg, assert.notEqual, true);
3610
- test2.assert(
3611
- exp != flag(test2, "object"),
3612
- "expected #{this} to not equal #{exp}",
3613
- "expected #{this} to equal #{act}",
3614
- exp,
3615
- act,
3616
- true
3617
- );
3618
- };
3619
- assert.strictEqual = function(act, exp, msg) {
3620
- new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
3621
- };
3622
- assert.notStrictEqual = function(act, exp, msg) {
3623
- new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
3624
- };
3625
- assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
3626
- new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
3627
- };
3628
- assert.notDeepEqual = function(act, exp, msg) {
3629
- new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
3630
- };
3631
- assert.isAbove = function(val, abv, msg) {
3632
- new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
3633
- };
3634
- assert.isAtLeast = function(val, atlst, msg) {
3635
- new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
3636
- };
3637
- assert.isBelow = function(val, blw, msg) {
3638
- new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
3639
- };
3640
- assert.isAtMost = function(val, atmst, msg) {
3641
- new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
3642
- };
3643
- assert.isTrue = function(val, msg) {
3644
- new Assertion(val, msg, assert.isTrue, true).is["true"];
3645
- };
3646
- assert.isNotTrue = function(val, msg) {
3647
- new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
3648
- };
3649
- assert.isFalse = function(val, msg) {
3650
- new Assertion(val, msg, assert.isFalse, true).is["false"];
3651
- };
3652
- assert.isNotFalse = function(val, msg) {
3653
- new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
3654
- };
3655
- assert.isNull = function(val, msg) {
3656
- new Assertion(val, msg, assert.isNull, true).to.equal(null);
3657
- };
3658
- assert.isNotNull = function(val, msg) {
3659
- new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
3660
- };
3661
- assert.isNaN = function(val, msg) {
3662
- new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
3663
- };
3664
- assert.isNotNaN = function(value, message) {
3665
- new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
3666
- };
3667
- assert.exists = function(val, msg) {
3668
- new Assertion(val, msg, assert.exists, true).to.exist;
3669
- };
3670
- assert.notExists = function(val, msg) {
3671
- new Assertion(val, msg, assert.notExists, true).to.not.exist;
3672
- };
3673
- assert.isUndefined = function(val, msg) {
3674
- new Assertion(val, msg, assert.isUndefined, true).to.equal(void 0);
3675
- };
3676
- assert.isDefined = function(val, msg) {
3677
- new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
3678
- };
3679
- assert.isCallable = function(value, message) {
3680
- new Assertion(value, message, assert.isCallable, true).is.callable;
3681
- };
3682
- assert.isNotCallable = function(value, message) {
3683
- new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
3684
- };
3685
- assert.isObject = function(val, msg) {
3686
- new Assertion(val, msg, assert.isObject, true).to.be.a("object");
3687
- };
3688
- assert.isNotObject = function(val, msg) {
3689
- new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
3690
- };
3691
- assert.isArray = function(val, msg) {
3692
- new Assertion(val, msg, assert.isArray, true).to.be.an("array");
3693
- };
3694
- assert.isNotArray = function(val, msg) {
3695
- new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
3696
- };
3697
- assert.isString = function(val, msg) {
3698
- new Assertion(val, msg, assert.isString, true).to.be.a("string");
3699
- };
3700
- assert.isNotString = function(val, msg) {
3701
- new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
3702
- };
3703
- assert.isNumber = function(val, msg) {
3704
- new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
3705
- };
3706
- assert.isNotNumber = function(val, msg) {
3707
- new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
3708
- };
3709
- assert.isNumeric = function(val, msg) {
3710
- new Assertion(val, msg, assert.isNumeric, true).is.numeric;
3711
- };
3712
- assert.isNotNumeric = function(val, msg) {
3713
- new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
3714
- };
3715
- assert.isFinite = function(val, msg) {
3716
- new Assertion(val, msg, assert.isFinite, true).to.be.finite;
3717
- };
3718
- assert.isBoolean = function(val, msg) {
3719
- new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
3720
- };
3721
- assert.isNotBoolean = function(val, msg) {
3722
- new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
3723
- };
3724
- assert.typeOf = function(val, type3, msg) {
3725
- new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
3726
- };
3727
- assert.notTypeOf = function(value, type3, message) {
3728
- new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
3729
- };
3730
- assert.instanceOf = function(val, type3, msg) {
3731
- new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
3732
- };
3733
- assert.notInstanceOf = function(val, type3, msg) {
3734
- new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
3735
- type3
3736
- );
3737
- };
3738
- assert.include = function(exp, inc, msg) {
3739
- new Assertion(exp, msg, assert.include, true).include(inc);
3740
- };
3741
- assert.notInclude = function(exp, inc, msg) {
3742
- new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
3743
- };
3744
- assert.deepInclude = function(exp, inc, msg) {
3745
- new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
3746
- };
3747
- assert.notDeepInclude = function(exp, inc, msg) {
3748
- new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
3749
- };
3750
- assert.nestedInclude = function(exp, inc, msg) {
3751
- new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
3752
- };
3753
- assert.notNestedInclude = function(exp, inc, msg) {
3754
- new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
3755
- inc
3756
- );
3757
- };
3758
- assert.deepNestedInclude = function(exp, inc, msg) {
3759
- new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
3760
- inc
3761
- );
3762
- };
3763
- assert.notDeepNestedInclude = function(exp, inc, msg) {
3764
- new Assertion(
3765
- exp,
3766
- msg,
3767
- assert.notDeepNestedInclude,
3768
- true
3769
- ).not.deep.nested.include(inc);
3770
- };
3771
- assert.ownInclude = function(exp, inc, msg) {
3772
- new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
3773
- };
3774
- assert.notOwnInclude = function(exp, inc, msg) {
3775
- new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
3776
- };
3777
- assert.deepOwnInclude = function(exp, inc, msg) {
3778
- new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
3779
- };
3780
- assert.notDeepOwnInclude = function(exp, inc, msg) {
3781
- new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
3782
- inc
3783
- );
3784
- };
3785
- assert.match = function(exp, re, msg) {
3786
- new Assertion(exp, msg, assert.match, true).to.match(re);
3787
- };
3788
- assert.notMatch = function(exp, re, msg) {
3789
- new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
3790
- };
3791
- assert.property = function(obj, prop, msg) {
3792
- new Assertion(obj, msg, assert.property, true).to.have.property(prop);
3793
- };
3794
- assert.notProperty = function(obj, prop, msg) {
3795
- new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
3796
- };
3797
- assert.propertyVal = function(obj, prop, val, msg) {
3798
- new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
3799
- };
3800
- assert.notPropertyVal = function(obj, prop, val, msg) {
3801
- new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
3802
- prop,
3803
- val
3804
- );
3805
- };
3806
- assert.deepPropertyVal = function(obj, prop, val, msg) {
3807
- new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
3808
- prop,
3809
- val
3810
- );
3811
- };
3812
- assert.notDeepPropertyVal = function(obj, prop, val, msg) {
3813
- new Assertion(
3814
- obj,
3815
- msg,
3816
- assert.notDeepPropertyVal,
3817
- true
3818
- ).to.not.have.deep.property(prop, val);
3819
- };
3820
- assert.ownProperty = function(obj, prop, msg) {
3821
- new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
3822
- };
3823
- assert.notOwnProperty = function(obj, prop, msg) {
3824
- new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
3825
- prop
3826
- );
3827
- };
3828
- assert.ownPropertyVal = function(obj, prop, value, msg) {
3829
- new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
3830
- prop,
3831
- value
3832
- );
3833
- };
3834
- assert.notOwnPropertyVal = function(obj, prop, value, msg) {
3835
- new Assertion(
3836
- obj,
3837
- msg,
3838
- assert.notOwnPropertyVal,
3839
- true
3840
- ).to.not.have.own.property(prop, value);
3841
- };
3842
- assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
3843
- new Assertion(
3844
- obj,
3845
- msg,
3846
- assert.deepOwnPropertyVal,
3847
- true
3848
- ).to.have.deep.own.property(prop, value);
3849
- };
3850
- assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
3851
- new Assertion(
3852
- obj,
3853
- msg,
3854
- assert.notDeepOwnPropertyVal,
3855
- true
3856
- ).to.not.have.deep.own.property(prop, value);
3857
- };
3858
- assert.nestedProperty = function(obj, prop, msg) {
3859
- new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
3860
- prop
3861
- );
3862
- };
3863
- assert.notNestedProperty = function(obj, prop, msg) {
3864
- new Assertion(
3865
- obj,
3866
- msg,
3867
- assert.notNestedProperty,
3868
- true
3869
- ).to.not.have.nested.property(prop);
3870
- };
3871
- assert.nestedPropertyVal = function(obj, prop, val, msg) {
3872
- new Assertion(
3873
- obj,
3874
- msg,
3875
- assert.nestedPropertyVal,
3876
- true
3877
- ).to.have.nested.property(prop, val);
3878
- };
3879
- assert.notNestedPropertyVal = function(obj, prop, val, msg) {
3880
- new Assertion(
3881
- obj,
3882
- msg,
3883
- assert.notNestedPropertyVal,
3884
- true
3885
- ).to.not.have.nested.property(prop, val);
3886
- };
3887
- assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
3888
- new Assertion(
3889
- obj,
3890
- msg,
3891
- assert.deepNestedPropertyVal,
3892
- true
3893
- ).to.have.deep.nested.property(prop, val);
3894
- };
3895
- assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
3896
- new Assertion(
3897
- obj,
3898
- msg,
3899
- assert.notDeepNestedPropertyVal,
3900
- true
3901
- ).to.not.have.deep.nested.property(prop, val);
3902
- };
3903
- assert.lengthOf = function(exp, len, msg) {
3904
- new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
3905
- };
3906
- assert.hasAnyKeys = function(obj, keys, msg) {
3907
- new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
3908
- };
3909
- assert.hasAllKeys = function(obj, keys, msg) {
3910
- new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
3911
- };
3912
- assert.containsAllKeys = function(obj, keys, msg) {
3913
- new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
3914
- keys
3915
- );
3916
- };
3917
- assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
3918
- new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
3919
- keys
3920
- );
3921
- };
3922
- assert.doesNotHaveAllKeys = function(obj, keys, msg) {
3923
- new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
3924
- keys
3925
- );
3926
- };
3927
- assert.hasAnyDeepKeys = function(obj, keys, msg) {
3928
- new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
3929
- keys
3930
- );
3931
- };
3932
- assert.hasAllDeepKeys = function(obj, keys, msg) {
3933
- new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
3934
- keys
3935
- );
3936
- };
3937
- assert.containsAllDeepKeys = function(obj, keys, msg) {
3938
- new Assertion(
3939
- obj,
3940
- msg,
3941
- assert.containsAllDeepKeys,
3942
- true
3943
- ).to.contain.all.deep.keys(keys);
3944
- };
3945
- assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
3946
- new Assertion(
3947
- obj,
3948
- msg,
3949
- assert.doesNotHaveAnyDeepKeys,
3950
- true
3951
- ).to.not.have.any.deep.keys(keys);
3952
- };
3953
- assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
3954
- new Assertion(
3955
- obj,
3956
- msg,
3957
- assert.doesNotHaveAllDeepKeys,
3958
- true
3959
- ).to.not.have.all.deep.keys(keys);
3960
- };
3961
- assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
3962
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
3963
- errMsgMatcher = errorLike;
3964
- errorLike = null;
3965
- }
3966
- var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
3967
- errorLike,
3968
- errMsgMatcher
3969
- );
3970
- return flag(assertErr, "object");
3971
- };
3972
- assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
3973
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
3974
- errMsgMatcher = errorLike;
3975
- errorLike = null;
3976
- }
3977
- new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
3978
- errorLike,
3979
- errMsgMatcher
3980
- );
3981
- };
3982
- assert.operator = function(val, operator, val2, msg) {
3983
- var ok;
3984
- switch (operator) {
3985
- case "==":
3986
- ok = val == val2;
3987
- break;
3988
- case "===":
3989
- ok = val === val2;
3990
- break;
3991
- case ">":
3992
- ok = val > val2;
3993
- break;
3994
- case ">=":
3995
- ok = val >= val2;
3996
- break;
3997
- case "<":
3998
- ok = val < val2;
3999
- break;
4000
- case "<=":
4001
- ok = val <= val2;
4002
- break;
4003
- case "!=":
4004
- ok = val != val2;
4005
- break;
4006
- case "!==":
4007
- ok = val !== val2;
4008
- break;
4009
- default:
4010
- msg = msg ? msg + ": " : msg;
4011
- throw new AssertionError(
4012
- msg + 'Invalid operator "' + operator + '"',
4013
- void 0,
4014
- assert.operator
4015
- );
4016
- }
4017
- var test2 = new Assertion(ok, msg, assert.operator, true);
4018
- test2.assert(
4019
- true === flag(test2, "object"),
4020
- "expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2),
4021
- "expected " + inspect2(val) + " to not be " + operator + " " + inspect2(val2)
4022
- );
4023
- };
4024
- assert.closeTo = function(act, exp, delta, msg) {
4025
- new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
4026
- };
4027
- assert.approximately = function(act, exp, delta, msg) {
4028
- new Assertion(act, msg, assert.approximately, true).to.be.approximately(
4029
- exp,
4030
- delta
4031
- );
4032
- };
4033
- assert.sameMembers = function(set1, set2, msg) {
4034
- new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
4035
- };
4036
- assert.notSameMembers = function(set1, set2, msg) {
4037
- new Assertion(
4038
- set1,
4039
- msg,
4040
- assert.notSameMembers,
4041
- true
4042
- ).to.not.have.same.members(set2);
4043
- };
4044
- assert.sameDeepMembers = function(set1, set2, msg) {
4045
- new Assertion(
4046
- set1,
4047
- msg,
4048
- assert.sameDeepMembers,
4049
- true
4050
- ).to.have.same.deep.members(set2);
4051
- };
4052
- assert.notSameDeepMembers = function(set1, set2, msg) {
4053
- new Assertion(
4054
- set1,
4055
- msg,
4056
- assert.notSameDeepMembers,
4057
- true
4058
- ).to.not.have.same.deep.members(set2);
4059
- };
4060
- assert.sameOrderedMembers = function(set1, set2, msg) {
4061
- new Assertion(
4062
- set1,
4063
- msg,
4064
- assert.sameOrderedMembers,
4065
- true
4066
- ).to.have.same.ordered.members(set2);
4067
- };
4068
- assert.notSameOrderedMembers = function(set1, set2, msg) {
4069
- new Assertion(
4070
- set1,
4071
- msg,
4072
- assert.notSameOrderedMembers,
4073
- true
4074
- ).to.not.have.same.ordered.members(set2);
4075
- };
4076
- assert.sameDeepOrderedMembers = function(set1, set2, msg) {
4077
- new Assertion(
4078
- set1,
4079
- msg,
4080
- assert.sameDeepOrderedMembers,
4081
- true
4082
- ).to.have.same.deep.ordered.members(set2);
4083
- };
4084
- assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
4085
- new Assertion(
4086
- set1,
4087
- msg,
4088
- assert.notSameDeepOrderedMembers,
4089
- true
4090
- ).to.not.have.same.deep.ordered.members(set2);
4091
- };
4092
- assert.includeMembers = function(superset, subset, msg) {
4093
- new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
4094
- subset
4095
- );
4096
- };
4097
- assert.notIncludeMembers = function(superset, subset, msg) {
4098
- new Assertion(
4099
- superset,
4100
- msg,
4101
- assert.notIncludeMembers,
4102
- true
4103
- ).to.not.include.members(subset);
4104
- };
4105
- assert.includeDeepMembers = function(superset, subset, msg) {
4106
- new Assertion(
4107
- superset,
4108
- msg,
4109
- assert.includeDeepMembers,
4110
- true
4111
- ).to.include.deep.members(subset);
4112
- };
4113
- assert.notIncludeDeepMembers = function(superset, subset, msg) {
4114
- new Assertion(
4115
- superset,
4116
- msg,
4117
- assert.notIncludeDeepMembers,
4118
- true
4119
- ).to.not.include.deep.members(subset);
4120
- };
4121
- assert.includeOrderedMembers = function(superset, subset, msg) {
4122
- new Assertion(
4123
- superset,
4124
- msg,
4125
- assert.includeOrderedMembers,
4126
- true
4127
- ).to.include.ordered.members(subset);
4128
- };
4129
- assert.notIncludeOrderedMembers = function(superset, subset, msg) {
4130
- new Assertion(
4131
- superset,
4132
- msg,
4133
- assert.notIncludeOrderedMembers,
4134
- true
4135
- ).to.not.include.ordered.members(subset);
4136
- };
4137
- assert.includeDeepOrderedMembers = function(superset, subset, msg) {
4138
- new Assertion(
4139
- superset,
4140
- msg,
4141
- assert.includeDeepOrderedMembers,
4142
- true
4143
- ).to.include.deep.ordered.members(subset);
4144
- };
4145
- assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
4146
- new Assertion(
4147
- superset,
4148
- msg,
4149
- assert.notIncludeDeepOrderedMembers,
4150
- true
4151
- ).to.not.include.deep.ordered.members(subset);
4152
- };
4153
- assert.oneOf = function(inList, list, msg) {
4154
- new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
4155
- };
4156
- assert.isIterable = function(obj, msg) {
4157
- if (obj == void 0 || !obj[Symbol.iterator]) {
4158
- msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
4159
- throw new AssertionError(msg, void 0, assert.isIterable);
4160
- }
4161
- };
4162
- assert.changes = function(fn, obj, prop, msg) {
4163
- if (arguments.length === 3 && typeof obj === "function") {
4164
- msg = prop;
4165
- prop = null;
4166
- }
4167
- new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
4168
- };
4169
- assert.changesBy = function(fn, obj, prop, delta, msg) {
4170
- if (arguments.length === 4 && typeof obj === "function") {
4171
- var tmpMsg = delta;
4172
- delta = prop;
4173
- msg = tmpMsg;
4174
- } else if (arguments.length === 3) {
4175
- delta = prop;
4176
- prop = null;
4177
- }
4178
- new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
4179
- };
4180
- assert.doesNotChange = function(fn, obj, prop, msg) {
4181
- if (arguments.length === 3 && typeof obj === "function") {
4182
- msg = prop;
4183
- prop = null;
4184
- }
4185
- return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
4186
- obj,
4187
- prop
4188
- );
4189
- };
4190
- assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
4191
- if (arguments.length === 4 && typeof obj === "function") {
4192
- var tmpMsg = delta;
4193
- delta = prop;
4194
- msg = tmpMsg;
4195
- } else if (arguments.length === 3) {
4196
- delta = prop;
4197
- prop = null;
4198
- }
4199
- new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
4200
- };
4201
- assert.increases = function(fn, obj, prop, msg) {
4202
- if (arguments.length === 3 && typeof obj === "function") {
4203
- msg = prop;
4204
- prop = null;
4205
- }
4206
- return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
4207
- };
4208
- assert.increasesBy = function(fn, obj, prop, delta, msg) {
4209
- if (arguments.length === 4 && typeof obj === "function") {
4210
- var tmpMsg = delta;
4211
- delta = prop;
4212
- msg = tmpMsg;
4213
- } else if (arguments.length === 3) {
4214
- delta = prop;
4215
- prop = null;
4216
- }
4217
- new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
4218
- };
4219
- assert.doesNotIncrease = function(fn, obj, prop, msg) {
4220
- if (arguments.length === 3 && typeof obj === "function") {
4221
- msg = prop;
4222
- prop = null;
4223
- }
4224
- return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
4225
- obj,
4226
- prop
4227
- );
4228
- };
4229
- assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
4230
- if (arguments.length === 4 && typeof obj === "function") {
4231
- var tmpMsg = delta;
4232
- delta = prop;
4233
- msg = tmpMsg;
4234
- } else if (arguments.length === 3) {
4235
- delta = prop;
4236
- prop = null;
4237
- }
4238
- new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
4239
- };
4240
- assert.decreases = function(fn, obj, prop, msg) {
4241
- if (arguments.length === 3 && typeof obj === "function") {
4242
- msg = prop;
4243
- prop = null;
4244
- }
4245
- return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
4246
- };
4247
- assert.decreasesBy = function(fn, obj, prop, delta, msg) {
4248
- if (arguments.length === 4 && typeof obj === "function") {
4249
- var tmpMsg = delta;
4250
- delta = prop;
4251
- msg = tmpMsg;
4252
- } else if (arguments.length === 3) {
4253
- delta = prop;
4254
- prop = null;
4255
- }
4256
- new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
4257
- };
4258
- assert.doesNotDecrease = function(fn, obj, prop, msg) {
4259
- if (arguments.length === 3 && typeof obj === "function") {
4260
- msg = prop;
4261
- prop = null;
4262
- }
4263
- return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
4264
- obj,
4265
- prop
4266
- );
4267
- };
4268
- assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
4269
- if (arguments.length === 4 && typeof obj === "function") {
4270
- var tmpMsg = delta;
4271
- delta = prop;
4272
- msg = tmpMsg;
4273
- } else if (arguments.length === 3) {
4274
- delta = prop;
4275
- prop = null;
4276
- }
4277
- return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
4278
- };
4279
- assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
4280
- if (arguments.length === 4 && typeof obj === "function") {
4281
- var tmpMsg = delta;
4282
- delta = prop;
4283
- msg = tmpMsg;
4284
- } else if (arguments.length === 3) {
4285
- delta = prop;
4286
- prop = null;
4287
- }
4288
- new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
4289
- };
4290
- assert.ifError = function(val) {
4291
- if (val) {
4292
- throw val;
4293
- }
4294
- };
4295
- assert.isExtensible = function(obj, msg) {
4296
- new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
4297
- };
4298
- assert.isNotExtensible = function(obj, msg) {
4299
- new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
4300
- };
4301
- assert.isSealed = function(obj, msg) {
4302
- new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
4303
- };
4304
- assert.isNotSealed = function(obj, msg) {
4305
- new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
4306
- };
4307
- assert.isFrozen = function(obj, msg) {
4308
- new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
4309
- };
4310
- assert.isNotFrozen = function(obj, msg) {
4311
- new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
4312
- };
4313
- assert.isEmpty = function(val, msg) {
4314
- new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
4315
- };
4316
- assert.isNotEmpty = function(val, msg) {
4317
- new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
4318
- };
4319
- assert.containsSubset = function(val, exp, msg) {
4320
- new Assertion(val, msg).to.containSubset(exp);
4321
- };
4322
- assert.doesNotContainSubset = function(val, exp, msg) {
4323
- new Assertion(val, msg).to.not.containSubset(exp);
4324
- };
4325
- var aliases = [
4326
- ["isOk", "ok"],
4327
- ["isNotOk", "notOk"],
4328
- ["throws", "throw"],
4329
- ["throws", "Throw"],
4330
- ["isExtensible", "extensible"],
4331
- ["isNotExtensible", "notExtensible"],
4332
- ["isSealed", "sealed"],
4333
- ["isNotSealed", "notSealed"],
4334
- ["isFrozen", "frozen"],
4335
- ["isNotFrozen", "notFrozen"],
4336
- ["isEmpty", "empty"],
4337
- ["isNotEmpty", "notEmpty"],
4338
- ["isCallable", "isFunction"],
4339
- ["isNotCallable", "isNotFunction"],
4340
- ["containsSubset", "containSubset"]
4341
- ];
4342
- for (const [name, as] of aliases) {
4343
- assert[as] = assert[name];
4344
- }
4345
- var used = [];
4346
- function use(fn) {
4347
- const exports = {
4348
- use,
4349
- AssertionError,
4350
- util: utils_exports,
4351
- config,
4352
- expect,
4353
- assert,
4354
- Assertion,
4355
- ...should_exports
4356
- };
4357
- if (!~used.indexOf(fn)) {
4358
- fn(exports, utils_exports);
4359
- used.push(fn);
4360
- }
4361
- return exports;
4362
- }
4363
- __name(use, "use");
4364
-
4365
- // src/lib/pmProxy.test/adapter.ts
4366
- var testAdapter = {
4367
- beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
4368
- return subject;
4369
- },
4370
- andWhen: async (store, whenCB, testResource, pm) => {
4371
- const proxiedPM = andWhenProxy(pm, "some/path");
4372
- return whenCB(store, proxiedPM);
4373
- },
4374
- butThen: async (store, thenCB, testResource, pm) => {
4375
- const proxiedPM = butThenProxy(pm, "some/path");
4376
- return thenCB(store, proxiedPM);
4377
- },
4378
- afterEach: async (store, key, pm) => store,
4379
- afterAll: async (store, pm) => {
4380
- },
4381
- beforeAll: async (input, testResource, pm, theGivenString) => {
4382
- return {
4383
- beforeEachProxy: input.butThenProxy(
4384
- new MockPMBase(),
4385
- theGivenString
4386
- )
4387
- };
4388
- },
4389
- assertThis: (returnedFilePath, expectation) => {
4390
- assert.equal(returnedFilePath, expectation);
4391
- }
4392
- };
4393
-
4394
- // src/lib/pmProxy.test/index.ts
4395
- var pmProxy_default = Node_default(
4396
- // because of the nature of testeranto, we must add all the testable items here
4397
- {
4398
- butThenProxy
4399
- },
4400
- specification,
4401
- implementation,
4402
- testAdapter
4403
- );
4404
- export {
4405
- pmProxy_default as default
4406
- };
4407
- /*! Bundled license information:
4408
-
4409
- chai/chai.js:
4410
- (*!
4411
- * Chai - flag utility
4412
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4413
- * MIT Licensed
4414
- *)
4415
- (*!
4416
- * Chai - test utility
4417
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4418
- * MIT Licensed
4419
- *)
4420
- (*!
4421
- * Chai - expectTypes utility
4422
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4423
- * MIT Licensed
4424
- *)
4425
- (*!
4426
- * Chai - getActual utility
4427
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4428
- * MIT Licensed
4429
- *)
4430
- (*!
4431
- * Chai - message composition utility
4432
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4433
- * MIT Licensed
4434
- *)
4435
- (*!
4436
- * Chai - transferFlags utility
4437
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4438
- * MIT Licensed
4439
- *)
4440
- (*!
4441
- * chai
4442
- * http://chaijs.com
4443
- * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
4444
- * MIT Licensed
4445
- *)
4446
- (*!
4447
- * Chai - isProxyEnabled helper
4448
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4449
- * MIT Licensed
4450
- *)
4451
- (*!
4452
- * Chai - addProperty utility
4453
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4454
- * MIT Licensed
4455
- *)
4456
- (*!
4457
- * Chai - addLengthGuard utility
4458
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4459
- * MIT Licensed
4460
- *)
4461
- (*!
4462
- * Chai - getProperties utility
4463
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4464
- * MIT Licensed
4465
- *)
4466
- (*!
4467
- * Chai - proxify utility
4468
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4469
- * MIT Licensed
4470
- *)
4471
- (*!
4472
- * Chai - addMethod utility
4473
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4474
- * MIT Licensed
4475
- *)
4476
- (*!
4477
- * Chai - overwriteProperty utility
4478
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4479
- * MIT Licensed
4480
- *)
4481
- (*!
4482
- * Chai - overwriteMethod utility
4483
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4484
- * MIT Licensed
4485
- *)
4486
- (*!
4487
- * Chai - addChainingMethod utility
4488
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4489
- * MIT Licensed
4490
- *)
4491
- (*!
4492
- * Chai - overwriteChainableMethod utility
4493
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
4494
- * MIT Licensed
4495
- *)
4496
- (*!
4497
- * Chai - compareByInspect utility
4498
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
4499
- * MIT Licensed
4500
- *)
4501
- (*!
4502
- * Chai - getOwnEnumerablePropertySymbols utility
4503
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
4504
- * MIT Licensed
4505
- *)
4506
- (*!
4507
- * Chai - getOwnEnumerableProperties utility
4508
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
4509
- * MIT Licensed
4510
- *)
4511
- (*!
4512
- * Chai - isNaN utility
4513
- * Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
4514
- * MIT Licensed
4515
- *)
4516
- (*!
4517
- * chai
4518
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
4519
- * MIT Licensed
4520
- *)
4521
- (*!
4522
- * chai
4523
- * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
4524
- * MIT Licensed
4525
- *)
4526
- (*! Bundled license information:
4527
-
4528
- deep-eql/index.js:
4529
- (*!
4530
- * deep-eql
4531
- * Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
4532
- * MIT Licensed
4533
- *)
4534
- (*!
4535
- * Check to see if the MemoizeMap has recorded a result of the two operands
4536
- *
4537
- * @param {Mixed} leftHandOperand
4538
- * @param {Mixed} rightHandOperand
4539
- * @param {MemoizeMap} memoizeMap
4540
- * @returns {Boolean|null} result
4541
- *)
4542
- (*!
4543
- * Set the result of the equality into the MemoizeMap
4544
- *
4545
- * @param {Mixed} leftHandOperand
4546
- * @param {Mixed} rightHandOperand
4547
- * @param {MemoizeMap} memoizeMap
4548
- * @param {Boolean} result
4549
- *)
4550
- (*!
4551
- * Primary Export
4552
- *)
4553
- (*!
4554
- * The main logic of the `deepEqual` function.
4555
- *
4556
- * @param {Mixed} leftHandOperand
4557
- * @param {Mixed} rightHandOperand
4558
- * @param {Object} [options] (optional) Additional options
4559
- * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
4560
- * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
4561
- complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
4562
- references to blow the stack.
4563
- * @return {Boolean} equal match
4564
- *)
4565
- (*!
4566
- * Compare two Regular Expressions for equality.
4567
- *
4568
- * @param {RegExp} leftHandOperand
4569
- * @param {RegExp} rightHandOperand
4570
- * @return {Boolean} result
4571
- *)
4572
- (*!
4573
- * Compare two Sets/Maps for equality. Faster than other equality functions.
4574
- *
4575
- * @param {Set} leftHandOperand
4576
- * @param {Set} rightHandOperand
4577
- * @param {Object} [options] (Optional)
4578
- * @return {Boolean} result
4579
- *)
4580
- (*!
4581
- * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
4582
- *
4583
- * @param {Iterable} leftHandOperand
4584
- * @param {Iterable} rightHandOperand
4585
- * @param {Object} [options] (Optional)
4586
- * @return {Boolean} result
4587
- *)
4588
- (*!
4589
- * Simple equality for generator objects such as those returned by generator functions.
4590
- *
4591
- * @param {Iterable} leftHandOperand
4592
- * @param {Iterable} rightHandOperand
4593
- * @param {Object} [options] (Optional)
4594
- * @return {Boolean} result
4595
- *)
4596
- (*!
4597
- * Determine if the given object has an @@iterator function.
4598
- *
4599
- * @param {Object} target
4600
- * @return {Boolean} `true` if the object has an @@iterator function.
4601
- *)
4602
- (*!
4603
- * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
4604
- * This will consume the iterator - which could have side effects depending on the @@iterator implementation.
4605
- *
4606
- * @param {Object} target
4607
- * @returns {Array} an array of entries from the @@iterator function
4608
- *)
4609
- (*!
4610
- * Gets all entries from a Generator. This will consume the generator - which could have side effects.
4611
- *
4612
- * @param {Generator} target
4613
- * @returns {Array} an array of entries from the Generator.
4614
- *)
4615
- (*!
4616
- * Gets all own and inherited enumerable keys from a target.
4617
- *
4618
- * @param {Object} target
4619
- * @returns {Array} an array of own and inherited enumerable keys from the target.
4620
- *)
4621
- (*!
4622
- * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
4623
- * each key. If any value of the given key is not equal, the function will return false (early).
4624
- *
4625
- * @param {Mixed} leftHandOperand
4626
- * @param {Mixed} rightHandOperand
4627
- * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
4628
- * @param {Object} [options] (Optional)
4629
- * @return {Boolean} result
4630
- *)
4631
- (*!
4632
- * Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
4633
- * for each enumerable key in the object.
4634
- *
4635
- * @param {Mixed} leftHandOperand
4636
- * @param {Mixed} rightHandOperand
4637
- * @param {Object} [options] (Optional)
4638
- * @return {Boolean} result
4639
- *)
4640
- (*!
4641
- * Returns true if the argument is a primitive.
4642
- *
4643
- * This intentionally returns true for all objects that can be compared by reference,
4644
- * including functions and symbols.
4645
- *
4646
- * @param {Mixed} value
4647
- * @return {Boolean} result
4648
- *)
4649
- *)
4650
- */