@sprucelabs/spruce-cli 24.0.0 → 24.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js +2 -2
  3. package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js.map +1 -1
  4. package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js +1 -1
  5. package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js.map +1 -1
  6. package/build/__tests__/behavioral/conversations/TestingAConversation.test.js +5 -5
  7. package/build/__tests__/behavioral/conversations/TestingAConversation.test.js.map +1 -1
  8. package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js.map +1 -1
  9. package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.d.ts +11 -0
  10. package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js +49 -0
  11. package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js.map +1 -0
  12. package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.d.ts +5 -0
  13. package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js +34 -0
  14. package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js.map +1 -0
  15. package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.d.ts +12 -0
  16. package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js +88 -0
  17. package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js.map +1 -0
  18. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.d.ts +13 -0
  19. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js +109 -0
  20. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js.map +1 -0
  21. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.d.ts +4 -0
  22. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js +29 -0
  23. package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js.map +1 -0
  24. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.d.ts +26 -0
  25. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js +259 -0
  26. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js.map +1 -0
  27. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.d.ts +26 -0
  28. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js +202 -0
  29. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js.map +1 -0
  30. package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
  31. package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
  32. package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
  33. package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
  34. package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
  35. package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
  36. package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
  37. package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
  38. package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.d.ts +2 -0
  39. package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js +51 -0
  40. package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js.map +1 -0
  41. package/build/__tests__/behavioral/versions/ResolvingVersions.test.js +0 -3
  42. package/build/__tests__/behavioral/versions/ResolvingVersions.test.js.map +1 -1
  43. package/build/__tests__/implementation/OrganizationStore.test.js +2 -2
  44. package/build/__tests__/implementation/OrganizationStore.test.js.map +1 -1
  45. package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
  46. package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
  47. package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
  48. package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
  49. package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
  50. package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
  51. package/build/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
  52. package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
  53. package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
  54. package/build/features/test/actions/CreateAction.d.ts +1 -0
  55. package/build/features/test/actions/CreateAction.js +13 -0
  56. package/build/features/test/actions/CreateAction.js.map +1 -1
  57. package/build/features/test/actions/MigrateAction.d.ts +17 -0
  58. package/build/features/test/actions/MigrateAction.js +39 -0
  59. package/build/features/test/actions/MigrateAction.js.map +1 -0
  60. package/build/tests/staticToInstanceMigration/StaticTestFinder.d.ts +8 -0
  61. package/build/tests/staticToInstanceMigration/StaticTestFinder.js +23 -0
  62. package/build/tests/staticToInstanceMigration/StaticTestFinder.js.map +1 -0
  63. package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.d.ts +58 -0
  64. package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js +48 -0
  65. package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js.map +1 -0
  66. package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.d.ts +12 -0
  67. package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js +138 -0
  68. package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js.map +1 -0
  69. package/package.json +27 -27
  70. package/src/__tests__/behavioral/conversations/CreatingAConversationTopic.test.ts +2 -2
  71. package/src/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.ts +1 -1
  72. package/src/__tests__/behavioral/conversations/TestingAConversation.test.ts +5 -5
  73. package/src/__tests__/behavioral/organization/CreatingAnOrg.test.ts +0 -1
  74. package/src/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.ts +77 -0
  75. package/src/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.ts +19 -0
  76. package/src/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.ts +99 -0
  77. package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.ts +72 -0
  78. package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.ts +31 -0
  79. package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts +252 -0
  80. package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.ts +193 -0
  81. package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
  82. package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
  83. package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
  84. package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
  85. package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
  86. package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
  87. package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
  88. package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
  89. package/src/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.ts +50 -0
  90. package/src/__tests__/behavioral/versions/ResolvingVersions.test.ts +1 -3
  91. package/src/__tests__/implementation/OrganizationStore.test.ts +6 -2
  92. package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
  93. package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
  94. package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
  95. package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
  96. package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
  97. package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
  98. package/src/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
  99. package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
  100. package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
  101. package/src/features/test/actions/CreateAction.ts +17 -0
  102. package/src/features/test/actions/MigrateAction.ts +41 -0
  103. package/src/tests/staticToInstanceMigration/StaticTestFinder.ts +25 -0
  104. package/src/tests/staticToInstanceMigration/StaticToInstanceMigrator.ts +73 -0
  105. package/src/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.ts +197 -0
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ const test_utils_1 = __importStar(require("@sprucelabs/test-utils"));
46
+ const StaticTestFinder_1 = __importDefault(require("../../../../tests/staticToInstanceMigration/StaticTestFinder"));
47
+ const StaticToInstanceMigrator_1 = __importDefault(require("../../../../tests/staticToInstanceMigration/StaticToInstanceMigrator"));
48
+ const StaticToInstanceTestFileMigrator_1 = __importDefault(require("../../../../tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator"));
49
+ let StaticToInstanceMigratorTest = class StaticToInstanceMigratorTest extends test_utils_1.default {
50
+ testFinder;
51
+ testFileMigrator;
52
+ migrator;
53
+ readFiles = [];
54
+ fakedFileContents = {};
55
+ lastWrittenFile;
56
+ constructor() {
57
+ super();
58
+ StaticTestFinder_1.default.Class = FakeStaticTestFinder;
59
+ StaticToInstanceTestFileMigrator_1.default.Class = FakeFileMigrator;
60
+ StaticToInstanceMigrator_1.default.diskUtil.readFile = (source) => {
61
+ this.readFiles.push(source);
62
+ return this.fakedFileContents[source] ?? (0, test_utils_1.generateId)();
63
+ };
64
+ StaticToInstanceMigrator_1.default.diskUtil.writeFile = (destination, contents) => {
65
+ this.lastWrittenFile = {
66
+ destination,
67
+ contents,
68
+ };
69
+ };
70
+ this.testFinder = StaticTestFinder_1.default.Finder();
71
+ this.testFileMigrator =
72
+ StaticToInstanceTestFileMigrator_1.default.Migrator();
73
+ this.migrator = StaticToInstanceMigrator_1.default.Migrator({
74
+ testFinder: this.testFinder,
75
+ testFileMigrator: this.testFileMigrator,
76
+ });
77
+ }
78
+ throwsWithMissing() {
79
+ const err = test_utils_1.assert.doesThrow(() =>
80
+ //@ts-ignore
81
+ StaticToInstanceMigrator_1.default.Migrator());
82
+ test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
83
+ parameters: ['testFinder', 'testFileMigrator'],
84
+ });
85
+ }
86
+ async runThrowsWithMissing() {
87
+ //@ts-ignore
88
+ const err = await test_utils_1.assert.doesThrowAsync(() => this.migrator.run());
89
+ test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
90
+ parameters: ['lookupDir'],
91
+ });
92
+ }
93
+ async passesLookupDirToTestFinder() {
94
+ const path = (0, test_utils_1.generateId)();
95
+ await this.run(path);
96
+ test_utils_1.assert.isEqual(this.testFinder.lastLookupDir, path);
97
+ }
98
+ async returnsStatsBasedOnTestsFound(results) {
99
+ this.setFakedFinderResults(results);
100
+ const stats = await this.run();
101
+ test_utils_1.assert.isEqualDeep(stats, {
102
+ totalTestsUpdated: this.testFinder.fakedResults.length,
103
+ totalTestsSkipped: 0,
104
+ });
105
+ }
106
+ async passesOneFilesContentsToMigrator(filename) {
107
+ this.setFakedFinderResults([filename]);
108
+ await this.run();
109
+ test_utils_1.assert.isEqualDeep(this.readFiles, [filename]);
110
+ }
111
+ async passesResultsOfFileToMigrator() {
112
+ this.setFakedFinderResults(['a']);
113
+ this.setFakedFileContents({
114
+ a: (0, test_utils_1.generateId)(),
115
+ });
116
+ await this.run();
117
+ this.assertContentsPassedToFileMigratorEquals([
118
+ this.fakedFileContents['a'],
119
+ ]);
120
+ }
121
+ async passesResultsOfMultipleFilesToMigrator() {
122
+ const contents1 = (0, test_utils_1.generateId)();
123
+ const contents2 = (0, test_utils_1.generateId)();
124
+ this.setFakedFinderResults(['what', 'the']);
125
+ this.setFakedFileContents({
126
+ what: contents1,
127
+ the: contents2,
128
+ });
129
+ await this.run();
130
+ this.assertContentsPassedToFileMigratorEquals([contents1, contents2]);
131
+ }
132
+ async writesResponseOfMigrate() {
133
+ const filename = (0, test_utils_1.generateId)();
134
+ this.setFakedFinderResults([filename]);
135
+ this.setFakedFileContents({
136
+ [filename]: (0, test_utils_1.generateId)(),
137
+ });
138
+ await this.run();
139
+ test_utils_1.assert.isEqualDeep(this.lastWrittenFile, {
140
+ destination: filename,
141
+ contents: this.testFileMigrator.fakedMigrateResponse,
142
+ });
143
+ }
144
+ async returnsSkippedIfMigratedIsTheSame() {
145
+ this.setFakedFinderResults(['a']);
146
+ const contents = (0, test_utils_1.generateId)();
147
+ this.setFakedFileContents({
148
+ a: contents,
149
+ });
150
+ this.setMigrateFileResponse(contents);
151
+ const stats = await this.run();
152
+ test_utils_1.assert.isEqualDeep(stats, {
153
+ totalTestsUpdated: 0,
154
+ totalTestsSkipped: 1,
155
+ });
156
+ }
157
+ async countsSkippedAndMatched() {
158
+ const contents1 = (0, test_utils_1.generateId)();
159
+ const contents2 = (0, test_utils_1.generateId)();
160
+ this.setFakedFinderResults(['what', 'the', 'heck']);
161
+ this.setFakedFileContents({
162
+ what: contents1,
163
+ the: contents2,
164
+ heck: (0, test_utils_1.generateId)(),
165
+ });
166
+ this.testFileMigrator.fakedMigrateResponsesByContents = {
167
+ [contents1]: contents1,
168
+ [contents2]: contents2,
169
+ };
170
+ const stats = await this.run();
171
+ test_utils_1.assert.isEqualDeep(stats, {
172
+ totalTestsUpdated: 1,
173
+ totalTestsSkipped: 2,
174
+ });
175
+ }
176
+ async doesNotWriteFileThatDidNotChange() {
177
+ this.setFakedFinderResults(['a']);
178
+ const contents = (0, test_utils_1.generateId)();
179
+ this.setFakedFileContents({
180
+ a: contents,
181
+ });
182
+ this.setMigrateFileResponse(contents);
183
+ await this.run();
184
+ test_utils_1.assert.isUndefined(this.lastWrittenFile);
185
+ }
186
+ setMigrateFileResponse(contents) {
187
+ this.testFileMigrator.fakedMigrateResponse = contents;
188
+ }
189
+ assertContentsPassedToFileMigratorEquals(expected) {
190
+ test_utils_1.assert.isEqualDeep(this.testFileMigrator.contentsPassedToMigrate, expected);
191
+ }
192
+ setFakedFileContents(contents) {
193
+ this.fakedFileContents = contents;
194
+ }
195
+ setFakedFinderResults(results) {
196
+ this.testFinder.fakedResults = results;
197
+ }
198
+ async run(path) {
199
+ return await this.migrator.run(path ?? (0, test_utils_1.generateId)());
200
+ }
201
+ };
202
+ __decorate([
203
+ (0, test_utils_1.test)()
204
+ ], StaticToInstanceMigratorTest.prototype, "throwsWithMissing", null);
205
+ __decorate([
206
+ (0, test_utils_1.test)()
207
+ ], StaticToInstanceMigratorTest.prototype, "runThrowsWithMissing", null);
208
+ __decorate([
209
+ (0, test_utils_1.test)()
210
+ ], StaticToInstanceMigratorTest.prototype, "passesLookupDirToTestFinder", null);
211
+ __decorate([
212
+ (0, test_utils_1.test)('returns stats based on 3 tests found', ['a', 'b', 'c']),
213
+ (0, test_utils_1.test)('returns stats based on 0 tests found', [])
214
+ ], StaticToInstanceMigratorTest.prototype, "returnsStatsBasedOnTestsFound", null);
215
+ __decorate([
216
+ (0, test_utils_1.test)('passes one files contents to migrator', 'a'),
217
+ (0, test_utils_1.test)('passes another files contents to migrator', 'b')
218
+ ], StaticToInstanceMigratorTest.prototype, "passesOneFilesContentsToMigrator", null);
219
+ __decorate([
220
+ (0, test_utils_1.test)()
221
+ ], StaticToInstanceMigratorTest.prototype, "passesResultsOfFileToMigrator", null);
222
+ __decorate([
223
+ (0, test_utils_1.test)()
224
+ ], StaticToInstanceMigratorTest.prototype, "passesResultsOfMultipleFilesToMigrator", null);
225
+ __decorate([
226
+ (0, test_utils_1.test)()
227
+ ], StaticToInstanceMigratorTest.prototype, "writesResponseOfMigrate", null);
228
+ __decorate([
229
+ (0, test_utils_1.test)()
230
+ ], StaticToInstanceMigratorTest.prototype, "returnsSkippedIfMigratedIsTheSame", null);
231
+ __decorate([
232
+ (0, test_utils_1.test)()
233
+ ], StaticToInstanceMigratorTest.prototype, "countsSkippedAndMatched", null);
234
+ __decorate([
235
+ (0, test_utils_1.test)()
236
+ ], StaticToInstanceMigratorTest.prototype, "doesNotWriteFileThatDidNotChange", null);
237
+ StaticToInstanceMigratorTest = __decorate([
238
+ (0, test_utils_1.suite)()
239
+ ], StaticToInstanceMigratorTest);
240
+ exports.default = StaticToInstanceMigratorTest;
241
+ class FakeStaticTestFinder {
242
+ lastLookupDir;
243
+ fakedResults = [];
244
+ async find(lookupDir) {
245
+ this.lastLookupDir = lookupDir;
246
+ return this.fakedResults;
247
+ }
248
+ }
249
+ class FakeFileMigrator {
250
+ contentsPassedToMigrate = [];
251
+ fakedMigrateResponse = (0, test_utils_1.generateId)();
252
+ fakedMigrateResponsesByContents = {};
253
+ migrate(contents) {
254
+ this.contentsPassedToMigrate.push(contents);
255
+ return (this.fakedMigrateResponsesByContents[contents] ??
256
+ this.fakedMigrateResponse);
257
+ }
258
+ }
259
+ //# sourceMappingURL=StaticToInstanceMigrator.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticToInstanceMigrator.test.js","sourceRoot":"","sources":["../../../../../src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAM+B;AAC/B,oHAEqE;AACrE,oIAE6E;AAC7E,oJAEqF;AAGtE,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,oBAAkB;IAChE,UAAU,CAAsB;IAChC,gBAAgB,CAAkB;IAClC,QAAQ,CAA0B;IAClC,SAAS,GAAa,EAAE,CAAA;IACxB,iBAAiB,GAA2B,EAAE,CAAA;IAC9C,eAAe,CAA4C;IAEnE;QACI,KAAK,EAAE,CAAA;QAEP,0BAAoB,CAAC,KAAK,GAAG,oBAAoB,CAAA;QACjD,0CAAoC,CAAC,KAAK,GAAG,gBAAgB,CAAA;QAE7D,kCAA4B,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE;YACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC3B,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,IAAA,uBAAU,GAAE,CAAA;QACzD,CAAC,CAAA;QAED,kCAA4B,CAAC,QAAQ,CAAC,SAAS,GAAG,CAC9C,WAAmB,EACnB,QAAgB,EAClB,EAAE;YACA,IAAI,CAAC,eAAe,GAAG;gBACnB,WAAW;gBACX,QAAQ;aACX,CAAA;QACL,CAAC,CAAA;QAED,IAAI,CAAC,UAAU,GAAG,0BAAoB,CAAC,MAAM,EAA0B,CAAA;QACvE,IAAI,CAAC,gBAAgB;YACjB,0CAAoC,CAAC,QAAQ,EAAsB,CAAA;QAEvE,IAAI,CAAC,QAAQ,GAAG,kCAA4B,CAAC,QAAQ,CAAC;YAClD,UAAU,EAAE,IAAI,C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AE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7D,IAAA,iBAAI,EAAC,sCAAsC,EAAE,EAAE,CAAC;iFAQhD;AAIe;IAFf,IAAA,iBAAI,EAAC,uCAAuC,EAAE,GAAG,CAAC;IAClD,IAAA,iBAAI,EAAC,2CAA2C,EAAE,GAAG,CAAC;oFAKtD;AAGe;IADf,IAAA,iBAAI,GAAE;iFAWN;AAGe;IADf,IAAA,iBAAI,GAAE;0FAeN;AAGe;IADf,IAAA,iBAAI,GAAE;2EAeN;AAGe;IADf,IAAA,iBAAI,GAAE;qFAeN;AAGe;IADf,IAAA,iBAAI,GAAE;2EAsBN;AAGe;IADf,IAAA,iBAAI,GAAE;oFAYN;AAzLgB,4BAA4B;IADhD,IAAA,kBAAK,GAAE;GACa,4BAA4B,CAiNhD;kBAjNoB,4BAA4B;AAmNjD,MAAM,oBAAoB;IACf,aAAa,CAAS;IACtB,YAAY,GAAa,EAAE,CAAA;IAE3B,KAAK,CAAC,IAAI,CAAC,SAAiB;QAC/B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAA;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAA;IAC5B,CAAC;CACJ;AAED,MAAM,gBAAgB;IACX,uBAAuB,GAAa,EAAE,CAAA;IACtC,oBAAoB,GAAG,IAAA,uBAAU,GAAE,CAAA;IACnC,+BAA+B,GAA2B,EAAE,CAAA;IAE5D,OAAO,CAAC,QAAgB;QAC3B,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC3C,OAAO,CACH,IAAI,CAAC,+BAA+B,CAAC,QAAQ,CAAC;YAC9C,IAAI,CAAC,oBAAoB,CAC5B,CAAA;IACL,CAAC;CACJ"}
@@ -0,0 +1,26 @@
1
+ import AbstractSpruceTest from '@sprucelabs/test-utils';
2
+ export default class StaticToInstanceTestFileMigratorTest extends AbstractSpruceTest {
3
+ private migrator;
4
+ protected throwsWithMissing(): void;
5
+ protected returnsEmptyString(): void;
6
+ protected fixesStaticFunction(): void;
7
+ protected fixesStaticAsyncFunctions(): void;
8
+ protected doesNotMessWithStaticInVariableName(): void;
9
+ protected addsSuiteDecoratorToClassIfNotThere(): void;
10
+ protected doesNotAddSuitIfAnotherClassExported(): void;
11
+ protected doesNotAddSuiteIfAlreadyThere(): void;
12
+ protected addsImportIfNotThere(): void;
13
+ protected doesNotMessWithAnythingWithTestInName(): void;
14
+ protected doesNoIncludeSuiteTwice(): void;
15
+ protected includesSuiteEvenIfSuiteIsInAMethodName(): void;
16
+ protected includesSuiteWithMultipleImports(): void;
17
+ protected canMigrateWholeTest(): void;
18
+ protected properlyMigrationsAbstractTests(): void;
19
+ protected canMigrateMoreComplexTest(): void;
20
+ protected canMigrateAnotherComplexTest(): void;
21
+ private readTestFile;
22
+ private resolveTestClassPath;
23
+ private assertMigratedEquals;
24
+ private cleanString;
25
+ private migrate;
26
+ }
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
46
+ const test_utils_1 = __importStar(require("@sprucelabs/test-utils"));
47
+ const StaticToInstanceTestFileMigrator_1 = __importDefault(require("../../../../tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator"));
48
+ let StaticToInstanceTestFileMigratorTest = class StaticToInstanceTestFileMigratorTest extends test_utils_1.default {
49
+ migrator = StaticToInstanceTestFileMigrator_1.default.Migrator();
50
+ throwsWithMissing() {
51
+ //@ts-ignore
52
+ const err = test_utils_1.assert.doesThrow(() => this.migrate());
53
+ test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
54
+ parameters: ['contents'],
55
+ });
56
+ }
57
+ returnsEmptyString() {
58
+ this.assertMigratedEquals('', '');
59
+ }
60
+ fixesStaticFunction() {
61
+ this.assertMigratedEquals(`@test()
62
+ protected static myTest() {}`, `@test()
63
+ protected myTest() {}`);
64
+ }
65
+ fixesStaticAsyncFunctions() {
66
+ this.assertMigratedEquals(`@test()
67
+ protected static async myTest() {}`, `@test()
68
+ protected async myTest() {}`);
69
+ }
70
+ doesNotMessWithStaticInVariableName() {
71
+ this.assertMigratedEquals(`protected staticInName() {}`, `protected staticInName() {}`);
72
+ }
73
+ addsSuiteDecoratorToClassIfNotThere() {
74
+ this.assertMigratedEquals(`export default class Test {}`, `@suite()\nexport default class Test {}`);
75
+ }
76
+ doesNotAddSuitIfAnotherClassExported() {
77
+ this.assertMigratedEquals(`export class Test {}`, `export class Test {}`);
78
+ }
79
+ doesNotAddSuiteIfAlreadyThere() {
80
+ this.assertMigratedEquals(`@suite()\nexport default class Test {}`, `@suite()\nexport default class Test {}`);
81
+ }
82
+ addsImportIfNotThere() {
83
+ this.assertMigratedEquals(`import { test } from '@sprucelabs/test-utils'`, `import { test, suite } from '@sprucelabs/test-utils'`);
84
+ }
85
+ doesNotMessWithAnythingWithTestInName() {
86
+ this.assertMigratedEquals(`protected testing() {}`, `protected testing() {}`);
87
+ }
88
+ doesNoIncludeSuiteTwice() {
89
+ this.assertMigratedEquals(`import { test, suite } from '@sprucelabs/test-utils'`, `import { test, suite } from '@sprucelabs/test-utils'`);
90
+ }
91
+ includesSuiteEvenIfSuiteIsInAMethodName() {
92
+ this.assertMigratedEquals(`import { test } from '@sprucelabs/test-utils
93
+ protected suiteMethod() {}`, `import { test, suite } from '@sprucelabs/test-utils
94
+ protected suiteMethod() {}`);
95
+ }
96
+ includesSuiteWithMultipleImports() {
97
+ this.assertMigratedEquals(`import AbstractSpruceTest, {
98
+ test,
99
+ assert,
100
+ errorAssert,
101
+ } from '@sprucelabs/test-utils'`, `import AbstractSpruceTest, {
102
+ test,
103
+ suite,
104
+ assert,
105
+ errorAssert,
106
+ } from '@sprucelabs/test-utils'`);
107
+ }
108
+ canMigrateWholeTest() {
109
+ const before = this.readTestFile('StaticTest.txt');
110
+ const expected = this.readTestFile('InstanceTest.txt');
111
+ this.assertMigratedEquals(before, expected);
112
+ }
113
+ properlyMigrationsAbstractTests() {
114
+ const before = this.readTestFile('AbstractStaticTest.txt');
115
+ const expected = this.readTestFile('AbstractInstanceTest.txt');
116
+ this.assertMigratedEquals(before, expected);
117
+ }
118
+ canMigrateMoreComplexTest() {
119
+ const before = this.readTestFile('StaticTest2.txt');
120
+ const expected = this.readTestFile('InstanceTest2.txt');
121
+ this.assertMigratedEquals(before, expected);
122
+ }
123
+ canMigrateAnotherComplexTest() {
124
+ const before = this.readTestFile('StaticTest3.txt');
125
+ const expected = this.readTestFile('InstanceTest3.txt');
126
+ this.assertMigratedEquals(before, expected);
127
+ }
128
+ readTestFile(name) {
129
+ return spruce_skill_utils_1.diskUtil.readFile(this.resolveTestClassPath(name));
130
+ }
131
+ resolveTestClassPath(name) {
132
+ return this.resolvePath(__dirname, 'support', name);
133
+ }
134
+ assertMigratedEquals(contents, expected) {
135
+ const actual = this.migrate(contents);
136
+ const cleanedActual = this.cleanString(actual);
137
+ const cleanedExpected = this.cleanString(expected);
138
+ test_utils_1.assert.isTrue(cleanedActual == cleanedExpected, `${actual}\n\ndoes not equal\n\n${expected}`);
139
+ }
140
+ cleanString(contents) {
141
+ return contents.replace(/\s{2,}/g, ' ').trim();
142
+ }
143
+ migrate(contents) {
144
+ return this.migrator.migrate(contents);
145
+ }
146
+ };
147
+ __decorate([
148
+ (0, test_utils_1.test)()
149
+ ], StaticToInstanceTestFileMigratorTest.prototype, "throwsWithMissing", null);
150
+ __decorate([
151
+ (0, test_utils_1.test)()
152
+ ], StaticToInstanceTestFileMigratorTest.prototype, "returnsEmptyString", null);
153
+ __decorate([
154
+ (0, test_utils_1.test)()
155
+ ], StaticToInstanceTestFileMigratorTest.prototype, "fixesStaticFunction", null);
156
+ __decorate([
157
+ (0, test_utils_1.test)()
158
+ ], StaticToInstanceTestFileMigratorTest.prototype, "fixesStaticAsyncFunctions", null);
159
+ __decorate([
160
+ (0, test_utils_1.test)()
161
+ ], StaticToInstanceTestFileMigratorTest.prototype, "doesNotMessWithStaticInVariableName", null);
162
+ __decorate([
163
+ (0, test_utils_1.test)()
164
+ ], StaticToInstanceTestFileMigratorTest.prototype, "addsSuiteDecoratorToClassIfNotThere", null);
165
+ __decorate([
166
+ (0, test_utils_1.test)()
167
+ ], StaticToInstanceTestFileMigratorTest.prototype, "doesNotAddSuitIfAnotherClassExported", null);
168
+ __decorate([
169
+ (0, test_utils_1.test)()
170
+ ], StaticToInstanceTestFileMigratorTest.prototype, "doesNotAddSuiteIfAlreadyThere", null);
171
+ __decorate([
172
+ (0, test_utils_1.test)()
173
+ ], StaticToInstanceTestFileMigratorTest.prototype, "addsImportIfNotThere", null);
174
+ __decorate([
175
+ (0, test_utils_1.test)()
176
+ ], StaticToInstanceTestFileMigratorTest.prototype, "doesNotMessWithAnythingWithTestInName", null);
177
+ __decorate([
178
+ (0, test_utils_1.test)()
179
+ ], StaticToInstanceTestFileMigratorTest.prototype, "doesNoIncludeSuiteTwice", null);
180
+ __decorate([
181
+ (0, test_utils_1.test)()
182
+ ], StaticToInstanceTestFileMigratorTest.prototype, "includesSuiteEvenIfSuiteIsInAMethodName", null);
183
+ __decorate([
184
+ (0, test_utils_1.test)()
185
+ ], StaticToInstanceTestFileMigratorTest.prototype, "includesSuiteWithMultipleImports", null);
186
+ __decorate([
187
+ (0, test_utils_1.test)()
188
+ ], StaticToInstanceTestFileMigratorTest.prototype, "canMigrateWholeTest", null);
189
+ __decorate([
190
+ (0, test_utils_1.test)()
191
+ ], StaticToInstanceTestFileMigratorTest.prototype, "properlyMigrationsAbstractTests", null);
192
+ __decorate([
193
+ (0, test_utils_1.test)()
194
+ ], StaticToInstanceTestFileMigratorTest.prototype, "canMigrateMoreComplexTest", null);
195
+ __decorate([
196
+ (0, test_utils_1.test)()
197
+ ], StaticToInstanceTestFileMigratorTest.prototype, "canMigrateAnotherComplexTest", null);
198
+ StaticToInstanceTestFileMigratorTest = __decorate([
199
+ (0, test_utils_1.suite)()
200
+ ], StaticToInstanceTestFileMigratorTest);
201
+ exports.default = StaticToInstanceTestFileMigratorTest;
202
+ //# sourceMappingURL=StaticToInstanceTestFileMigrator.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticToInstanceTestFileMigrator.test.js","sourceRoot":"","sources":["../../../../../src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAyD;AACzD,qEAK+B;AAC/B,oJAEqF;AAGtE,IAAM,oCAAoC,GAA1C,MAAM,oCAAqC,SAAQ,oBAAkB;IACxE,QAAQ,GACZ,0CAAoC,CAAC,QAAQ,EAAE,CAAA;IAGzC,iBAAiB;QACvB,YAAY;QACZ,MAAM,GAAG,GAAG,mBAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QAClD,wBAAW,CAAC,WAAW,CAAC,GAAG,EAAE,oBAAoB,EAAE;YAC/C,UAAU,EAAE,CAAC,UAAU,CAAC;SAC3B,CAAC,CAAA;IACN,CAAC;IAGS,kBAAkB;QACxB,IAAI,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAGS,mBAAmB;QACzB,IAAI,CAAC,oBAAoB,CACrB;6BACiB,EACjB;sBACU,CACb,CAAA;IACL,CAAC;IAGS,yBAAyB;QAC/B,IAAI,CAAC,oBAAoB,CACrB;mCACuB,EACvB;4BACgB,CACnB,CAAA;IACL,CAAC;IAGS,mCAAmC;QACzC,IAAI,CAAC,oBAAoB,CACrB,6BAA6B,EAC7B,6BAA6B,CAChC,CAAA;IACL,CAAC;IAGS,mCAAmC;QACzC,IAAI,CAAC,oBAAoB,CACrB,8BAA8B,EAC9B,wCAAwC,CAC3C,CAAA;IACL,CAAC;IAGS,oCAAoC;QAC1C,IAAI,CAAC,oBAAoB,CACrB,sBAAsB,EACtB,sBAAsB,CACzB,CAAA;IACL,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ADT,IAAA,iBAAI,GAAE;qFAQN;AAGS;IADT,IAAA,iBAAI,GAAE;+FAMN;AAGS;IADT,IAAA,iBAAI,GAAE;+FAMN;AAGS;IADT,IAAA,iBAAI,GAAE;gGAMN;AAGS;IADT,IAAA,iBAAI,GAAE;yFAMN;AAGS;IADT,IAAA,iBAAI,GAAE;gFAMN;AAGS;IADT,IAAA,iBAAI,GAAE;iGAMN;AAGS;IADT,IAAA,iBAAI,GAAE;mFAMN;AAGS;IADT,IAAA,iBAAI,GAAE;mGAQN;AAGS;IADT,IAAA,iBAAI,GAAE;4FAeN;AAGS;IADT,IAAA,iBAAI,GAAE;+EAMN;AAGS;IADT,IAAA,iBAAI,GAAE;2FAMN;AAGS;IADT,IAAA,iBAAI,GAAE;qFAMN;AAGS;IADT,IAAA,iBAAI,GAAE;wFAMN;AAvJgB,oCAAoC;IADxD,IAAA,kBAAK,GAAE;GACa,oCAAoC,CAoLxD;kBApLoB,oCAAoC"}
@@ -0,0 +1,24 @@
1
+ import { AbstractSpruceFixtureTest } from '@sprucelabs/spruce-test-fixtures'
2
+ import { assert } from '@sprucelabs/test-utils'
3
+ import HomeIntegrationsStore from '../../stores/HomeIntegrations.store'
4
+ import EventFaker from './EventFaker'
5
+
6
+ export default abstract class AbstractGoogleTest extends AbstractSpruceFixtureTest {
7
+ protected eventFaker!: EventFaker
8
+ private homeIntegrations!: HomeIntegrationsStore
9
+
10
+ protected async beforeEach(): Promise<void> {
11
+ await super.beforeEach()
12
+ this.eventFaker = new EventFaker()
13
+ this.homeIntegrations = await this.stores.getStore('homeIntegrations')
14
+ }
15
+
16
+ protected async getFirstHomeIntegration() {
17
+ const match = await this.homeIntegrations.findOne(
18
+ {},
19
+ { shouldIncludePrivateFields: true }
20
+ )
21
+ assert.isTruthy(match, 'No home integration found')
22
+ return match
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ import { AbstractSpruceFixtureTest } from '@sprucelabs/spruce-test-fixtures'
2
+ import { assert } from '@sprucelabs/test-utils'
3
+ import HomeIntegrationsStore from '../../stores/HomeIntegrations.store'
4
+ import EventFaker from './EventFaker'
5
+
6
+ export default abstract class AbstractGoogleTest extends AbstractSpruceFixtureTest {
7
+ protected static eventFaker: EventFaker
8
+ private static homeIntegrations: HomeIntegrationsStore
9
+
10
+ protected static async beforeEach(): Promise<void> {
11
+ await super.beforeEach()
12
+ this.eventFaker = new EventFaker()
13
+ this.homeIntegrations = await this.stores.getStore('homeIntegrations')
14
+ }
15
+
16
+ protected static async getFirstHomeIntegration() {
17
+ const match = await this.homeIntegrations.findOne(
18
+ {},
19
+ { shouldIncludePrivateFields: true }
20
+ )
21
+ assert.isTruthy(match, 'No home integration found')
22
+ return match
23
+ }
24
+ }
@@ -0,0 +1,36 @@
1
+ import { assertOptions } from '@sprucelabs/schema'
2
+ import { fake } from '@sprucelabs/spruce-test-fixtures'
3
+ import AbstractSpruceTest, {
4
+ test,
5
+ suite,
6
+ assert,
7
+ errorAssert,
8
+ } from '@sprucelabs/test-utils'
9
+
10
+ @fake.login()
11
+ @suite()
12
+ export default class StaticTestFinderTest extends AbstractSpruceTest {
13
+ @test()
14
+ protected async throwsWithMissing() {
15
+ const finder = StaticTestFinder.Finder()
16
+ const err = await assert.doesThrowAsync(() => finder.find())
17
+ errorAssert.assertError(err, 'MISSING_PARAMETERS', {
18
+ parameters: ['lookupDir'],
19
+ })
20
+ }
21
+
22
+ @test()
23
+ protected async yourNextTest() {
24
+ assert.isTrue(false)
25
+ }
26
+ }
27
+
28
+ class StaticTestFinder {
29
+ public static Finder() {
30
+ return new this()
31
+ }
32
+
33
+ public async find() {
34
+ assertOptions({}, ['lookupDir'])
35
+ }
36
+ }
@@ -0,0 +1,63 @@
1
+ import { fake, seed } from '@sprucelabs/spruce-test-fixtures'
2
+ import { assert, test, suite } from '@sprucelabs/test-utils'
3
+ import { HomeIntegration, PublicHomeIntegration } from '../../../google.types'
4
+ import AbstractGoogleTest from '../../support/AbstractGoogleTest'
5
+
6
+ @fake.login()
7
+ @suite()
8
+ export default class ListHomeIntegrationsLIstenerTest extends AbstractGoogleTest {
9
+ protected async beforeEach(): Promise<void> {
10
+ await super.beforeEach()
11
+ await this.bootSkill()
12
+ }
13
+
14
+ protected async afterEach(): Promise<void> {
15
+ }
16
+
17
+ @test()
18
+ protected async skillIsListening() {
19
+ await this.emit()
20
+ }
21
+
22
+ @test()
23
+ @seed('homeIntegrations', 1)
24
+ protected async canReturnFirstHomeIntegration() {
25
+ const expected = await this.getFirstHomeIntegration()
26
+ const integrations = await this.emit()
27
+ assert.isLength(integrations, 1)
28
+ const first = integrations[0]
29
+ this.assertIntegrationEqualsExpected(first, expected)
30
+ }
31
+
32
+ @test()
33
+ @seed('homeIntegrations', 2)
34
+ protected async canReturnMultipleHomeIntegrations() {
35
+ const expected = await this.homeIntegrations.find(
36
+ {},
37
+ {},
38
+ { shouldIncludePrivateFields: true }
39
+ )
40
+ const integrations = await this.emit()
41
+ assert.isLength(integrations, 2)
42
+ this.assertIntegrationEqualsExpected(integrations[0], expected[0])
43
+ this.assertIntegrationEqualsExpected(integrations[1], expected[1])
44
+ }
45
+
46
+ private assertIntegrationEqualsExpected(
47
+ first: PublicHomeIntegration,
48
+ expected: HomeIntegration
49
+ ) {
50
+ assert.isEqual(first.id, expected.id)
51
+ assert.isEqual(first.name, expected.name)
52
+ assert.isEqual(first.description, expected.description)
53
+ }
54
+
55
+ private async emit() {
56
+ const [{ integrations }] =
57
+ await this.fakedClient.emitAndFlattenResponses(
58
+ 'google.list-home-integrations::v2025_02_08'
59
+ )
60
+
61
+ return integrations
62
+ }
63
+ }