express-generator-typescript 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/project-files/src/repos/MockOrm.ts +8 -0
- package/lib/project-files/src/repos/database.test.json +22 -1
- package/lib/project-files/tests/common/types/index.ts +0 -17
- package/lib/project-files/tests/support/setup.ts +2 -4
- package/lib/project-files/tests/users.test.ts +1 -0
- package/package.json +1 -1
|
@@ -43,6 +43,13 @@ function saveDb(db: IDb): Promise<void> {
|
|
|
43
43
|
return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), db);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Empty the database
|
|
48
|
+
*/
|
|
49
|
+
function cleanDb(): Promise<void> {
|
|
50
|
+
return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), {});
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
|
|
47
54
|
/******************************************************************************
|
|
48
55
|
Export default
|
|
@@ -51,4 +58,5 @@ function saveDb(db: IDb): Promise<void> {
|
|
|
51
58
|
export default {
|
|
52
59
|
openDb,
|
|
53
60
|
saveDb,
|
|
61
|
+
cleanDb,
|
|
54
62
|
} as const;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"users": [
|
|
3
|
+
{
|
|
4
|
+
"id": 752712205078,
|
|
5
|
+
"name": "Bill",
|
|
6
|
+
"created": "2025-04-30T18:42:44.406Z",
|
|
7
|
+
"email": "sean.maxwell@gmail.com"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": 874707860804,
|
|
11
|
+
"name": "John Smith",
|
|
12
|
+
"created": "2025-04-30T18:42:44.406Z",
|
|
13
|
+
"email": "john.smith@gmail.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": 299903074095,
|
|
17
|
+
"name": "Gordan Freeman",
|
|
18
|
+
"created": "2025-04-30T18:42:44.406Z",
|
|
19
|
+
"email": "gordan.freeman@gmail.com"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Response } from 'supertest';
|
|
2
|
-
import UserRepo from '@src/repos/UserRepo';
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
/******************************************************************************
|
|
@@ -15,19 +14,3 @@ interface IErrObj {
|
|
|
15
14
|
message: string;
|
|
16
15
|
[key: string]: unknown;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/******************************************************************************
|
|
21
|
-
Functions
|
|
22
|
-
******************************************************************************/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Delete all records for unit testing.
|
|
26
|
-
*/
|
|
27
|
-
export async function cleanDatabase(): Promise<void> {
|
|
28
|
-
await Promise.all([
|
|
29
|
-
UserRepo.deleteAllUsers(),
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
@@ -4,7 +4,7 @@ import supertest, { Test } from 'supertest';
|
|
|
4
4
|
import TestAgent from 'supertest/lib/agent';
|
|
5
5
|
|
|
6
6
|
import app from '@src/server';
|
|
7
|
-
import
|
|
7
|
+
import MockOrm from '@src/repos/MockOrm';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/******************************************************************************
|
|
@@ -15,9 +15,7 @@ let agent: TestAgent<Test>;
|
|
|
15
15
|
|
|
16
16
|
beforeAll(async () => {
|
|
17
17
|
agent = supertest.agent(app);
|
|
18
|
-
await
|
|
19
|
-
UserRepo.deleteAllUsers(),
|
|
20
|
-
]);
|
|
18
|
+
await MockOrm.cleanDb();
|
|
21
19
|
});
|
|
22
20
|
|
|
23
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Generate new Express applications similar to express-generate which but sets it up to use TypeScript instead",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"express-generator-typescript": "node bin/cli.js",
|