@sprucelabs/spruce-test-fixtures 62.6.19 → 62.6.21
Sign up to get free protection for your applications and to get access to all the features.
- package/build/esm/tests/decorators/seed.js +1 -1
- package/build/esm/tests/fixtures/StoreFixture.d.ts +5 -3
- package/build/esm/tests/fixtures/StoreFixture.js +9 -1
- package/build/tests/decorators/seed.js +1 -1
- package/build/tests/fixtures/StoreFixture.d.ts +5 -3
- package/build/tests/fixtures/StoreFixture.js +8 -0
- package/package.json +4 -4
@@ -130,7 +130,7 @@ function attachSeeder(storeName, TestClass, totalToSeed, params) {
|
|
130
130
|
return __awaiter(this, void 0, void 0, function* () {
|
131
131
|
let fixture = TestClass.Fixture(fixtureName);
|
132
132
|
if (fixtureName === 'store') {
|
133
|
-
fixture = yield fixture.
|
133
|
+
fixture = yield fixture.getStore(storeName);
|
134
134
|
options.TestClass = TestClass;
|
135
135
|
}
|
136
136
|
else {
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import { DatabaseFixture,
|
1
|
+
import { DatabaseFixture, MockStoreFactory, StoreMap, StoreName, StoreOptions } from '@sprucelabs/data-stores';
|
2
2
|
export default class StoreFixture {
|
3
|
-
private storeFactory?;
|
3
|
+
private static storeFactory?;
|
4
4
|
private loader?;
|
5
5
|
private static storeMap;
|
6
6
|
private static shouldAutomaticallyResetDatabase;
|
7
7
|
static setStore(name: StoreName, Class: any): void;
|
8
8
|
getStore<N extends StoreName>(name: N): Promise<StoreMap[N]>;
|
9
9
|
Store<N extends StoreName, O extends StoreOptions<N>>(name: N, options?: O): Promise<StoreMap[N]>;
|
10
|
-
|
10
|
+
private get storeFactory();
|
11
|
+
private set storeFactory(value);
|
12
|
+
getStoreFactory(): Promise<MockStoreFactory>;
|
11
13
|
static setShouldAutomaticallyResetDatabase(shouldReset: boolean): void;
|
12
14
|
static beforeAll(): Promise<void>;
|
13
15
|
static beforeEach(): Promise<void>;
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
8
|
});
|
9
9
|
};
|
10
|
-
import { CursorPagerFaker, DatabaseFixture, StoreFactory, StoreLoader, } from '@sprucelabs/data-stores';
|
10
|
+
import { CursorPagerFaker, DatabaseFixture, MockStoreFactory, StoreFactory, StoreLoader, } from '@sprucelabs/data-stores';
|
11
11
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils';
|
12
12
|
class StoreFixture {
|
13
13
|
static setStore(name, Class) {
|
@@ -25,6 +25,12 @@ class StoreFixture {
|
|
25
25
|
return factory.Store(name, options);
|
26
26
|
});
|
27
27
|
}
|
28
|
+
get storeFactory() {
|
29
|
+
return StoreFixture.storeFactory;
|
30
|
+
}
|
31
|
+
set storeFactory(factory) {
|
32
|
+
StoreFixture.storeFactory = factory;
|
33
|
+
}
|
28
34
|
getStoreFactory() {
|
29
35
|
return __awaiter(this, void 0, void 0, function* () {
|
30
36
|
if (!this.storeFactory) {
|
@@ -48,6 +54,7 @@ class StoreFixture {
|
|
48
54
|
static beforeAll() {
|
49
55
|
return __awaiter(this, void 0, void 0, function* () {
|
50
56
|
const cwd = diskUtil.resolvePath(process.cwd(), 'build');
|
57
|
+
StoreFactory.Class = MockStoreFactory;
|
51
58
|
StoreLoader.setStoreDir(cwd);
|
52
59
|
DatabaseFixture.beforeAll();
|
53
60
|
yield this.setup();
|
@@ -63,6 +70,7 @@ class StoreFixture {
|
|
63
70
|
}
|
64
71
|
static reset() {
|
65
72
|
return __awaiter(this, void 0, void 0, function* () {
|
73
|
+
this.storeFactory = undefined;
|
66
74
|
this.resetDbConnectionSettings();
|
67
75
|
yield DatabaseFixture.beforeEach();
|
68
76
|
StoreFactory.reset();
|
@@ -118,7 +118,7 @@ function attachSeeder(storeName, TestClass, totalToSeed, params) {
|
|
118
118
|
return async function () {
|
119
119
|
let fixture = TestClass.Fixture(fixtureName);
|
120
120
|
if (fixtureName === 'store') {
|
121
|
-
fixture = await fixture.
|
121
|
+
fixture = await fixture.getStore(storeName);
|
122
122
|
options.TestClass = TestClass;
|
123
123
|
}
|
124
124
|
else {
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import { DatabaseFixture,
|
1
|
+
import { DatabaseFixture, MockStoreFactory, StoreMap, StoreName, StoreOptions } from '@sprucelabs/data-stores';
|
2
2
|
export default class StoreFixture {
|
3
|
-
private storeFactory?;
|
3
|
+
private static storeFactory?;
|
4
4
|
private loader?;
|
5
5
|
private static storeMap;
|
6
6
|
private static shouldAutomaticallyResetDatabase;
|
7
7
|
static setStore(name: StoreName, Class: any): void;
|
8
8
|
getStore<N extends StoreName>(name: N): Promise<StoreMap[N]>;
|
9
9
|
Store<N extends StoreName, O extends StoreOptions<N>>(name: N, options?: O): Promise<StoreMap[N]>;
|
10
|
-
|
10
|
+
private get storeFactory();
|
11
|
+
private set storeFactory(value);
|
12
|
+
getStoreFactory(): Promise<MockStoreFactory>;
|
11
13
|
static setShouldAutomaticallyResetDatabase(shouldReset: boolean): void;
|
12
14
|
static beforeAll(): Promise<void>;
|
13
15
|
static beforeEach(): Promise<void>;
|
@@ -14,6 +14,12 @@ class StoreFixture {
|
|
14
14
|
const factory = await this.getStoreFactory();
|
15
15
|
return factory.Store(name, options);
|
16
16
|
}
|
17
|
+
get storeFactory() {
|
18
|
+
return StoreFixture.storeFactory;
|
19
|
+
}
|
20
|
+
set storeFactory(factory) {
|
21
|
+
StoreFixture.storeFactory = factory;
|
22
|
+
}
|
17
23
|
async getStoreFactory() {
|
18
24
|
if (!this.storeFactory) {
|
19
25
|
if (!this.loader) {
|
@@ -34,6 +40,7 @@ class StoreFixture {
|
|
34
40
|
}
|
35
41
|
static async beforeAll() {
|
36
42
|
const cwd = spruce_skill_utils_1.diskUtil.resolvePath(process.cwd(), 'build');
|
43
|
+
data_stores_1.StoreFactory.Class = data_stores_1.MockStoreFactory;
|
37
44
|
data_stores_1.StoreLoader.setStoreDir(cwd);
|
38
45
|
data_stores_1.DatabaseFixture.beforeAll();
|
39
46
|
await this.setup();
|
@@ -45,6 +52,7 @@ class StoreFixture {
|
|
45
52
|
await data_stores_1.CursorPagerFaker.beforeEach();
|
46
53
|
}
|
47
54
|
static async reset() {
|
55
|
+
this.storeFactory = undefined;
|
48
56
|
this.resetDbConnectionSettings();
|
49
57
|
await data_stores_1.DatabaseFixture.beforeEach();
|
50
58
|
data_stores_1.StoreFactory.reset();
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
14
14
|
]
|
15
15
|
},
|
16
|
-
"version": "62.6.
|
16
|
+
"version": "62.6.21",
|
17
17
|
"files": [
|
18
18
|
"build/**/*",
|
19
19
|
"!build/__tests__",
|
@@ -61,7 +61,7 @@
|
|
61
61
|
"lint.tsc": "tsc -p . --noEmit"
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
|
-
"@sprucelabs/data-stores": "^28.5.
|
64
|
+
"@sprucelabs/data-stores": "^28.5.1",
|
65
65
|
"@sprucelabs/error": "^6.0.556",
|
66
66
|
"@sprucelabs/heartwood-view-controllers": "^113.0.6",
|
67
67
|
"@sprucelabs/mercury-client": "^42.0.660",
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"@sprucelabs/spruce-core-schemas": "^40.1.586",
|
72
72
|
"@sprucelabs/spruce-event-utils": "^40.1.370",
|
73
73
|
"@sprucelabs/spruce-permission-utils": "^8.1.100",
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^62.6.
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^62.6.21",
|
75
75
|
"@sprucelabs/spruce-skill-utils": "^31.1.9",
|
76
76
|
"@sprucelabs/test-utils": "^5.1.529",
|
77
77
|
"dotenv": "^16.4.7",
|
@@ -114,5 +114,5 @@
|
|
114
114
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
115
115
|
}
|
116
116
|
},
|
117
|
-
"gitHead": "
|
117
|
+
"gitHead": "38520a025f455a84269071e8cbdfd1c88e8504d4"
|
118
118
|
}
|