remult 0.22.3 → 0.22.4
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/esm/angular/interfaces/index.d.ts +1 -0
- package/esm/angular/interfaces/index.js +1 -0
- package/esm/angular/interfaces/src/column-collection.d.ts +70 -0
- package/esm/angular/interfaces/src/column-collection.js +341 -0
- package/esm/angular/interfaces/src/data-area-settings.d.ts +15 -0
- package/esm/angular/interfaces/src/data-area-settings.js +35 -0
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +36 -0
- package/esm/angular/interfaces/src/data-control-interfaces.js +57 -0
- package/esm/angular/interfaces/src/dataList.d.ts +13 -0
- package/esm/angular/interfaces/src/dataList.js +42 -0
- package/esm/angular/interfaces/src/filter-helper.d.ts +13 -0
- package/esm/angular/interfaces/src/filter-helper.js +59 -0
- package/esm/angular/interfaces/src/grid-settings.d.ts +145 -0
- package/esm/angular/interfaces/src/grid-settings.js +387 -0
- package/esm/angular/interfaces/src/public_api.d.ts +4 -0
- package/esm/angular/interfaces/src/public_api.js +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.js +3 -0
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +49 -0
- package/esm/angular/src/angular/data-control/data-control2.component.js +138 -0
- package/esm/core/SseSubscriptionServer.d.ts +33 -0
- package/esm/core/SseSubscriptionServer.js +107 -0
- package/esm/core/assign.d.ts +1 -0
- package/esm/core/assign.js +5 -0
- package/esm/core/classType.d.ts +3 -0
- package/esm/core/classType.js +1 -0
- package/esm/core/index.d.ts +27 -0
- package/esm/core/index.js +25 -0
- package/esm/core/inputTypes.d.ts +9 -0
- package/esm/core/inputTypes.js +9 -0
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +22 -0
- package/esm/core/live-query/data-provider-live-query-storage.js +71 -0
- package/esm/core/postgres/index.d.ts +2 -0
- package/esm/core/postgres/index.js +2 -0
- package/esm/core/postgres/postgres-data-provider.d.ts +36 -0
- package/esm/core/postgres/postgres-data-provider.js +120 -0
- package/esm/core/postgres/schema-builder.d.ts +17 -0
- package/esm/core/postgres/schema-builder.js +153 -0
- package/esm/core/remult-fresh.d.ts +17 -0
- package/esm/core/remult-fresh.js +29 -0
- package/esm/core/remult-knex/index.d.ts +30 -0
- package/esm/core/remult-knex/index.js +446 -0
- package/esm/core/remult-mongo.d.ts +24 -0
- package/esm/core/remult-mongo.js +254 -0
- package/esm/core/server/JsonEntityFileStorage.d.ts +10 -0
- package/esm/core/server/JsonEntityFileStorage.js +25 -0
- package/esm/core/server/core.d.ts +4 -0
- package/esm/core/server/core.js +4 -0
- package/esm/core/server/expressBridge.d.ts +182 -0
- package/esm/core/server/expressBridge.js +938 -0
- package/esm/core/server/index.d.ts +6 -0
- package/esm/core/server/index.js +9 -0
- package/esm/core/server/initAsyncHooks.d.ts +1 -0
- package/esm/core/server/initAsyncHooks.js +9 -0
- package/esm/core/server/initDataProvider.d.ts +2 -0
- package/esm/core/server/initDataProvider.js +14 -0
- package/esm/core/src/__EntityValueProvider.d.ts +11 -0
- package/esm/core/src/__EntityValueProvider.js +1 -0
- package/esm/core/src/__RowsOfDataForTesting.d.ts +3 -0
- package/esm/core/src/__RowsOfDataForTesting.js +1 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +147 -0
- package/{src → esm/core/src}/backend-tests/my-test.backend-spec.d.ts +1 -1
- package/esm/core/src/backend-tests/my-test.backend-spec.js +197 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +1 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +167 -0
- package/esm/core/src/buildRestDataProvider.d.ts +31 -0
- package/esm/core/src/buildRestDataProvider.js +113 -0
- package/esm/core/src/column-interfaces.d.ts +154 -0
- package/esm/core/src/column-interfaces.js +7 -0
- package/esm/core/src/column.d.ts +58 -0
- package/esm/core/src/column.js +174 -0
- package/esm/core/src/context.d.ts +134 -0
- package/esm/core/src/context.js +286 -0
- package/esm/core/src/data-api.d.ts +39 -0
- package/esm/core/src/data-api.js +279 -0
- package/esm/core/src/data-interfaces.d.ts +41 -0
- package/esm/core/src/data-interfaces.js +12 -0
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +22 -0
- package/esm/core/src/data-providers/array-entity-data-provider.js +252 -0
- package/esm/core/src/data-providers/in-memory-database.d.ts +9 -0
- package/esm/core/src/data-providers/in-memory-database.js +14 -0
- package/esm/core/src/data-providers/json-data-provider.d.ts +12 -0
- package/esm/core/src/data-providers/json-data-provider.js +55 -0
- package/esm/core/src/data-providers/rest-data-provider.d.ts +49 -0
- package/esm/core/src/data-providers/rest-data-provider.js +256 -0
- package/esm/core/src/data-providers/sql-database.d.ts +33 -0
- package/esm/core/src/data-providers/sql-database.js +384 -0
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +24 -0
- package/esm/core/src/data-providers/web-sql-data-provider.js +143 -0
- package/esm/core/src/entity.d.ts +91 -0
- package/esm/core/src/entity.js +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +150 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +1 -0
- package/esm/core/src/filter/filter-interfaces.d.ts +85 -0
- package/esm/core/src/filter/filter-interfaces.js +477 -0
- package/esm/core/src/live-query/LiveQueryClient.d.ts +20 -0
- package/esm/core/src/live-query/LiveQueryClient.js +188 -0
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +5 -0
- package/esm/core/src/live-query/SseSubscriptionClient.js +86 -0
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +72 -0
- package/esm/core/src/live-query/SubscriptionChannel.js +123 -0
- package/esm/core/src/live-query/SubscriptionServer.d.ts +53 -0
- package/esm/core/src/live-query/SubscriptionServer.js +111 -0
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +6 -0
- package/esm/core/src/live-query/live-query-tests.spec.js +952 -0
- package/esm/core/src/remult-proxy.d.ts +35 -0
- package/esm/core/src/remult-proxy.js +113 -0
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/esm/core/src/remult3/DecoratorReplacer.js +20 -0
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +355 -0
- package/esm/core/src/remult3/RepositoryImplementation.js +2109 -0
- package/esm/core/src/remult3/index.d.ts +2 -0
- package/esm/core/src/remult3/index.js +2 -0
- package/esm/core/src/remult3/remult3.d.ts +395 -0
- package/esm/core/src/remult3/remult3.js +2 -0
- package/esm/core/src/server-action.d.ts +81 -0
- package/esm/core/src/server-action.js +394 -0
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +32 -0
- package/esm/core/src/shared-tests/db-tests-setup.js +78 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +25 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.js +810 -0
- package/esm/core/src/shared-tests/deleteAll.d.ts +2 -0
- package/esm/core/src/shared-tests/deleteAll.js +4 -0
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/esm/core/src/shared-tests/entityWithValidations.js +43 -0
- package/esm/core/src/shared-tests/index.d.ts +4 -0
- package/esm/core/src/shared-tests/index.js +4 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +67 -0
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/esm/core/src/shared-tests/test-special-value.spec.js +73 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +31 -0
- package/esm/core/src/sort.d.ts +16 -0
- package/esm/core/src/sort.js +103 -0
- package/esm/core/src/sql-command.d.ts +19 -0
- package/esm/core/src/sql-command.js +1 -0
- package/esm/core/src/test.d.ts +3 -0
- package/esm/core/src/test.js +12 -0
- package/esm/core/src/tests/Done.d.ts +5 -0
- package/esm/core/src/tests/Done.js +9 -0
- package/esm/core/src/tests/RowProvider.spec.d.ts +16 -0
- package/esm/core/src/tests/RowProvider.spec.js +631 -0
- package/esm/core/src/tests/TestDataApiResponse.d.ts +10 -0
- package/esm/core/src/tests/TestDataApiResponse.js +22 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +8 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.js +2103 -0
- package/esm/core/src/tests/c.d.ts +8 -0
- package/esm/core/src/tests/c.js +13 -0
- package/esm/core/src/tests/createData.d.ts +7 -0
- package/esm/core/src/tests/createData.js +22 -0
- package/esm/core/src/tests/d.d.ts +6 -0
- package/esm/core/src/tests/d.js +11 -0
- package/esm/core/src/tests/dWithPrefilter.d.ts +7 -0
- package/esm/core/src/tests/dWithPrefilter.js +18 -0
- package/esm/core/src/tests/entityForCustomFilter.d.ts +16 -0
- package/esm/core/src/tests/entityForCustomFilter.js +33 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +13 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +4 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +37 -0
- package/esm/core/src/tests/h.d.ts +6 -0
- package/esm/core/src/tests/h.js +24 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +1 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +236 -0
- package/esm/core/src/tests/remult-3-entities.d.ts +23 -0
- package/esm/core/src/tests/remult-3-entities.js +39 -0
- package/esm/core/src/tests/tasks.d.ts +6 -0
- package/esm/core/src/tests/tasks.js +10 -0
- package/esm/core/src/tests/test-context-as-storage.spec.d.ts +0 -0
- package/esm/core/src/tests/test-context-as-storage.spec.js +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +389 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +5 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +152 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +1 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.js +38 -0
- package/esm/core/src/tests/test-default-value.spec.d.ts +1 -0
- package/esm/core/src/tests/test-default-value.spec.js +33 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +14 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.js +82 -0
- package/esm/core/src/tests/test-exceptions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-exceptions.spec.js +375 -0
- package/esm/core/src/tests/test-json.spec.d.ts +1 -0
- package/esm/core/src/tests/test-json.spec.js +115 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +9 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +809 -0
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +1 -0
- package/esm/core/src/tests/test-non-active-record.spec.js +66 -0
- package/esm/core/src/tests/test-object-column.spec.d.ts +1 -0
- package/esm/core/src/tests/test-object-column.spec.js +189 -0
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +1 -0
- package/esm/core/src/tests/test-paged-foreach.spec.js +328 -0
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +1 -0
- package/esm/core/src/tests/test-remult-angular.spec.js +23 -0
- package/esm/core/src/tests/test-server-controller.spec.d.ts +7 -0
- package/esm/core/src/tests/test-server-controller.spec.js +489 -0
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-expressions.spec.js +178 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +306 -0
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +5 -0
- package/esm/core/src/tests/test-sql-expression.spec.js +205 -0
- package/esm/core/src/tests/test-sql.spec.d.ts +1 -0
- package/esm/core/src/tests/test-sql.spec.js +170 -0
- package/esm/core/src/tests/test-subscribe.spec.d.ts +1 -0
- package/esm/core/src/tests/test-subscribe.spec.js +135 -0
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +1 -0
- package/esm/core/src/tests/test-type-recovery.spec.js +49 -0
- package/esm/core/src/tests/test-where-api.spec.d.ts +1 -0
- package/esm/core/src/tests/test-where-api.spec.js +434 -0
- package/esm/core/src/tests/testHelper.spec.d.ts +36 -0
- package/esm/core/src/tests/testHelper.spec.js +226 -0
- package/esm/core/src/tests/testModel/models.d.ts +16 -0
- package/esm/core/src/tests/testModel/models.js +25 -0
- package/esm/core/src/validators.d.ts +14 -0
- package/esm/core/src/validators.js +33 -0
- package/{valueConverters.d.ts → esm/core/src/valueConverters.d.ts} +13 -12
- package/esm/core/src/valueConverters.js +197 -0
- package/esm/core/urlBuilder.d.ts +6 -0
- package/esm/core/urlBuilder.js +20 -0
- package/esm/graphql.js +27 -27
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/esm/src/remult3/RepositoryImplementation.js +27 -4
- package/esm/src/shared-tests/db-tests.db-tests.js +57 -0
- package/esm/test-servers/shared/Task.d.ts +9 -0
- package/esm/test-servers/shared/Task.js +32 -0
- package/esm/test.d.ts +5 -0
- package/esm/test.js +6 -0
- package/package.json +1 -1
- package/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/src/remult3/RepositoryImplementation.js +88 -63
- package/src/shared-tests/db-tests.db-tests.js +97 -0
- package/esm/src/id-entity.d.ts +0 -4
- package/esm/src/id-entity.js +0 -8
- package/postgres/postgresColumnSyntax.d.ts +0 -2
- package/postgres/postgresColumnSyntax.js +0 -34
- package/remult-middleware.d.ts +0 -2
- package/remult-middleware.js +0 -70
- package/server/register-actions-on-server.d.ts +0 -3
- package/server/register-actions-on-server.js +0 -50
- package/server/register-entities-on-server.d.ts +0 -3
- package/server/register-entities-on-server.js +0 -19
- package/src/backend-tests/my-test.backend-spec.js +0 -217
- package/src/backend-tests/test-http-server.backend-spec.d.ts +0 -6
- package/src/backend-tests/test-http-server.backend-spec.js +0 -342
- package/src/id-entity.d.ts +0 -4
- package/src/id-entity.js +0 -17
- package/valueConverters.js +0 -168
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { InMemoryDataProvider } from "../..";
|
|
2
|
+
import { Remult } from "../context";
|
|
3
|
+
import { Entity, EntityBase, Fields } from "../remult3";
|
|
4
|
+
@Entity("parent", {
|
|
5
|
+
saving: async (self) => {
|
|
6
|
+
await new Promise((r) => setTimeout(() => {
|
|
7
|
+
r({});
|
|
8
|
+
}, 10));
|
|
9
|
+
self.myField += ",parent";
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class parent extends EntityBase {
|
|
13
|
+
@Fields.integer()
|
|
14
|
+
id = 0;
|
|
15
|
+
@Fields.string()
|
|
16
|
+
myField = '';
|
|
17
|
+
@Fields.string({ saving: self => self.autoSavedField = "auto" })
|
|
18
|
+
autoSavedField = '';
|
|
19
|
+
}
|
|
20
|
+
@Entity("child", {
|
|
21
|
+
saving: async (self) => {
|
|
22
|
+
await new Promise((r) => setTimeout(() => {
|
|
23
|
+
r({});
|
|
24
|
+
}, 10));
|
|
25
|
+
self.myField += "child";
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
export class child extends parent {
|
|
29
|
+
}
|
|
30
|
+
@Entity("child2", {})
|
|
31
|
+
export class child2 extends parent {
|
|
32
|
+
}
|
|
33
|
+
it("saving works well ", async () => {
|
|
34
|
+
let remult = new Remult(new InMemoryDataProvider());
|
|
35
|
+
let x = await remult.repo(child).create().save();
|
|
36
|
+
expect(x.myField).toBe("child,parent");
|
|
37
|
+
expect(x.autoSavedField).toBe("auto");
|
|
38
|
+
});
|
|
39
|
+
it("saving works well when child doesnt have saving", async () => {
|
|
40
|
+
let remult = new Remult(new InMemoryDataProvider());
|
|
41
|
+
let x = await remult.repo(child2).create().save();
|
|
42
|
+
expect(x.myField).toBe(",parent");
|
|
43
|
+
expect(x.autoSavedField).toBe("auto");
|
|
44
|
+
});
|
|
45
|
+
it("test saving of delete", async () => {
|
|
46
|
+
let remult = new Remult(new InMemoryDataProvider());
|
|
47
|
+
let x = await remult.repo(child).create().save();
|
|
48
|
+
await x.delete();
|
|
49
|
+
let done = false;
|
|
50
|
+
try {
|
|
51
|
+
await x.save();
|
|
52
|
+
done = true;
|
|
53
|
+
}
|
|
54
|
+
catch (err) { }
|
|
55
|
+
expect(done).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
@Entity("error", {
|
|
58
|
+
saving: async (self) => {
|
|
59
|
+
if (!self.isNew() && self.name == '2') {
|
|
60
|
+
self.name = '3';
|
|
61
|
+
await self.save();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
export class anError extends EntityBase {
|
|
66
|
+
@Fields.integer()
|
|
67
|
+
id = 0;
|
|
68
|
+
@Fields.string()
|
|
69
|
+
name = '';
|
|
70
|
+
}
|
|
71
|
+
it("test error on save within saving", async () => {
|
|
72
|
+
let remult = new Remult(new InMemoryDataProvider());
|
|
73
|
+
let x = await remult.repo(anError).create({ id: 1, name: '1' }).save();
|
|
74
|
+
x.name = '2';
|
|
75
|
+
let done = false;
|
|
76
|
+
try {
|
|
77
|
+
await x.save();
|
|
78
|
+
done = true;
|
|
79
|
+
}
|
|
80
|
+
catch (err) { }
|
|
81
|
+
expect(done).toBe(false);
|
|
82
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { Done } from "./Done";
|
|
2
|
+
import { Remult } from '../context';
|
|
3
|
+
import { InMemoryDataProvider } from '../data-providers/in-memory-database';
|
|
4
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
5
|
+
import { processHttpException, toPromise } from "../buildRestDataProvider";
|
|
6
|
+
describe("test exception", () => {
|
|
7
|
+
it("test save exception", async () => {
|
|
8
|
+
var mem = new InMemoryDataProvider();
|
|
9
|
+
var c = new Remult();
|
|
10
|
+
c.dataProvider = ({
|
|
11
|
+
getEntityDataProvider: e => {
|
|
12
|
+
let r = mem.getEntityDataProvider(e);
|
|
13
|
+
return {
|
|
14
|
+
count: undefined, delete: undefined, find: undefined, insert: async (x) => {
|
|
15
|
+
return toPromise(new Promise((res, err) => {
|
|
16
|
+
err({
|
|
17
|
+
error: {
|
|
18
|
+
message: 'error',
|
|
19
|
+
modelState: {
|
|
20
|
+
id: 'error for id'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}));
|
|
25
|
+
}, update: undefined
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
transaction: undefined
|
|
29
|
+
});
|
|
30
|
+
var ok = new Done();
|
|
31
|
+
let type = class extends EntityBase {
|
|
32
|
+
id;
|
|
33
|
+
};
|
|
34
|
+
Entity('test')(type);
|
|
35
|
+
Fields.string()(type.prototype, "id");
|
|
36
|
+
var x = c.repo(type).create();
|
|
37
|
+
try {
|
|
38
|
+
await x._.save();
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
expect(x._.fields.id.error).toBe('error for id');
|
|
42
|
+
expect(err.message).toBe("error");
|
|
43
|
+
expect(err.modelState.id).toBe('error for id');
|
|
44
|
+
ok.ok();
|
|
45
|
+
}
|
|
46
|
+
ok.test();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
function log(what) {
|
|
50
|
+
return what;
|
|
51
|
+
}
|
|
52
|
+
describe("angular http client exception ", () => {
|
|
53
|
+
it("waiting for proxy to restart", async () => {
|
|
54
|
+
let err = await processHttpException({
|
|
55
|
+
"headers": {
|
|
56
|
+
"normalizedNames": {},
|
|
57
|
+
"lazyUpdate": null
|
|
58
|
+
},
|
|
59
|
+
"status": 504,
|
|
60
|
+
"statusText": "Gateway Timeout",
|
|
61
|
+
"url": "http://localhost:4201/api/stam",
|
|
62
|
+
"ok": false,
|
|
63
|
+
"name": "HttpErrorResponse",
|
|
64
|
+
"message": "Http failure response for http://localhost:4201/api/stam: 504 Gateway Timeout",
|
|
65
|
+
"error": "Error occured while trying to proxy to: localhost:4201/api/stam"
|
|
66
|
+
});
|
|
67
|
+
expect(err).toEqual({
|
|
68
|
+
"message": "Error occured while trying to proxy to: localhost:4201/api/stam",
|
|
69
|
+
"httpStatusCode": 504
|
|
70
|
+
});
|
|
71
|
+
;
|
|
72
|
+
});
|
|
73
|
+
it("network disconnect", async () => {
|
|
74
|
+
let err = await processHttpException({
|
|
75
|
+
"headers": {
|
|
76
|
+
"normalizedNames": {},
|
|
77
|
+
"lazyUpdate": null,
|
|
78
|
+
"headers": {}
|
|
79
|
+
},
|
|
80
|
+
"status": 0,
|
|
81
|
+
"statusText": "Unknown Error",
|
|
82
|
+
"url": "api/stam",
|
|
83
|
+
"ok": false,
|
|
84
|
+
"name": "HttpErrorResponse",
|
|
85
|
+
"message": "Http failure response for api/stam: 0 Unknown Error",
|
|
86
|
+
"error": {
|
|
87
|
+
"isTrusted": true
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
expect(err).toEqual({
|
|
91
|
+
message: "Network Error",
|
|
92
|
+
"httpStatusCode": 0
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
it("Forbidden", async () => {
|
|
96
|
+
let err = await processHttpException({
|
|
97
|
+
"headers": {
|
|
98
|
+
"normalizedNames": {},
|
|
99
|
+
"lazyUpdate": null
|
|
100
|
+
},
|
|
101
|
+
"status": 403,
|
|
102
|
+
"statusText": "Forbidden",
|
|
103
|
+
"url": "http://localhost:4201/api/stam",
|
|
104
|
+
"ok": false,
|
|
105
|
+
"name": "HttpErrorResponse",
|
|
106
|
+
"message": "Http failure response for http://localhost:4201/api/stam: 403 Forbidden",
|
|
107
|
+
"error": "Forbidden"
|
|
108
|
+
});
|
|
109
|
+
expect(err).toEqual({
|
|
110
|
+
"message": "Forbidden",
|
|
111
|
+
"httpStatusCode": 403
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
it("syntax error", async () => {
|
|
115
|
+
let err = await processHttpException({
|
|
116
|
+
"headers": {
|
|
117
|
+
"normalizedNames": {},
|
|
118
|
+
"lazyUpdate": null
|
|
119
|
+
},
|
|
120
|
+
"status": 400,
|
|
121
|
+
"statusText": "Bad Request",
|
|
122
|
+
"url": "http://localhost:4201/api/stam",
|
|
123
|
+
"ok": false,
|
|
124
|
+
"name": "HttpErrorResponse",
|
|
125
|
+
"message": "Http failure response for http://localhost:4201/api/stam: 400 Bad Request",
|
|
126
|
+
"error": {
|
|
127
|
+
"message": "Cannot read property 'toString' of undefined",
|
|
128
|
+
"stack": "TypeError: Cannot read property 'toString' of undefined\n at Object.saving (C:\\repos\\radweb\\dist\\test-angular\\test-angular\\src\\app\\products-test\\products.component.js:50:19)\n at rowHelperImplementation.<anonymous> (C:\\repos\\radweb\\dist\\test-angular\\core\\src\\remult3\\RepositoryImplementation.js:648:44)\n at Generator.next (<anonymous>)\n at fulfilled (C:\\repos\\radweb\\node_modules\\tslib\\tslib.js:114:62)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)"
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
expect(err.message).toBe("Cannot read property 'toString' of undefined");
|
|
132
|
+
expect(err.stack).toContain("toString");
|
|
133
|
+
});
|
|
134
|
+
it("validation error", async () => {
|
|
135
|
+
let err = await processHttpException({
|
|
136
|
+
"headers": {
|
|
137
|
+
"normalizedNames": {},
|
|
138
|
+
"lazyUpdate": null
|
|
139
|
+
},
|
|
140
|
+
"status": 400,
|
|
141
|
+
"statusText": "Bad Request",
|
|
142
|
+
"url": "http://localhost:4201/api/stam",
|
|
143
|
+
"ok": false,
|
|
144
|
+
"name": "HttpErrorResponse",
|
|
145
|
+
"message": "Http failure response for http://localhost:4201/api/stam: 400 Bad Request",
|
|
146
|
+
"error": {
|
|
147
|
+
"modelState": {
|
|
148
|
+
"name": "name error"
|
|
149
|
+
},
|
|
150
|
+
"message": "Name: name error"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
expect(err).toEqual({
|
|
154
|
+
"modelState": {
|
|
155
|
+
"name": "name error"
|
|
156
|
+
},
|
|
157
|
+
"message": "Name: name error",
|
|
158
|
+
"httpStatusCode": 400
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe("fetch client exception ", () => {
|
|
163
|
+
it("waiting for proxy to restart", async () => {
|
|
164
|
+
let err = await processHttpException({
|
|
165
|
+
"message": "Request failed with status code 504",
|
|
166
|
+
"name": "Error",
|
|
167
|
+
"stack": "Error: Request failed with status code 504\n at createError (http://localhost:4201/vendor.js:127382:15)\n at settle (http://localhost:4201/vendor.js:94395:12)\n at XMLHttpRequest.onloadend [as __zone_symbol__ON_PROPERTYloadend] (http://localhost:4201/vendor.js:42269:7)\n at XMLHttpRequest.wrapFn (http://localhost:4201/polyfills.js:12099:39)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11742:31)\n at Object.onInvokeTask (http://localhost:4201/vendor.js:73020:33)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11741:60)\n at Zone.runTask (http://localhost:4201/polyfills.js:11514:47)\n at ZoneTask.invokeTask [as invoke] (http://localhost:4201/polyfills.js:11823:34)\n at invokeTask (http://localhost:4201/polyfills.js:12936:14)",
|
|
168
|
+
"isAxiosError": true,
|
|
169
|
+
"response": {
|
|
170
|
+
"data": "Error occured while trying to proxy to: localhost:4201/api/stam"
|
|
171
|
+
},
|
|
172
|
+
"config": {
|
|
173
|
+
"transitional": {
|
|
174
|
+
"silentJSONParsing": true,
|
|
175
|
+
"forcedJSONParsing": true,
|
|
176
|
+
"clarifyTimeoutError": false
|
|
177
|
+
},
|
|
178
|
+
"transformRequest": [
|
|
179
|
+
null
|
|
180
|
+
],
|
|
181
|
+
"transformResponse": [
|
|
182
|
+
null
|
|
183
|
+
],
|
|
184
|
+
"timeout": 0,
|
|
185
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
|
186
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
|
187
|
+
"maxContentLength": -1,
|
|
188
|
+
"maxBodyLength": -1,
|
|
189
|
+
"headers": {
|
|
190
|
+
"Accept": "application/json, text/plain, */*",
|
|
191
|
+
"Content-Type": "application/json"
|
|
192
|
+
},
|
|
193
|
+
"method": "post",
|
|
194
|
+
"url": "api/stam",
|
|
195
|
+
"data": "{\"id\":\"a0637d3c-405c-4d79-a473-a7d043aaebfd\",\"name\":\"noam\"}"
|
|
196
|
+
},
|
|
197
|
+
"status": 504
|
|
198
|
+
});
|
|
199
|
+
expect(err).toEqual({
|
|
200
|
+
"message": "Error occured while trying to proxy to: localhost:4201/api/stam",
|
|
201
|
+
"httpStatusCode": 504
|
|
202
|
+
});
|
|
203
|
+
;
|
|
204
|
+
});
|
|
205
|
+
it("network disconnect", async () => {
|
|
206
|
+
let err = await processHttpException({
|
|
207
|
+
"message": "Network Error",
|
|
208
|
+
"name": "Error",
|
|
209
|
+
"stack": "Error: Network Error\n at createError (http://localhost:4201/vendor.js:127382:15)\n at XMLHttpRequest.handleError [as __zone_symbol__ON_PROPERTYerror] (http://localhost:4201/vendor.js:42320:14)\n at XMLHttpRequest.wrapFn (http://localhost:4201/polyfills.js:12099:39)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11742:31)\n at Object.onInvokeTask (http://localhost:4201/vendor.js:73020:33)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11741:60)\n at Zone.runTask (http://localhost:4201/polyfills.js:11514:47)\n at ZoneTask.invokeTask [as invoke] (http://localhost:4201/polyfills.js:11823:34)\n at invokeTask (http://localhost:4201/polyfills.js:12936:14)\n at XMLHttpRequest.globalZoneAwareCallback (http://localhost:4201/polyfills.js:12962:17)",
|
|
210
|
+
"isAxiosError": true,
|
|
211
|
+
"response": undefined,
|
|
212
|
+
"config": {
|
|
213
|
+
"transitional": {
|
|
214
|
+
"silentJSONParsing": true,
|
|
215
|
+
"forcedJSONParsing": true,
|
|
216
|
+
"clarifyTimeoutError": false
|
|
217
|
+
},
|
|
218
|
+
"transformRequest": [
|
|
219
|
+
null
|
|
220
|
+
],
|
|
221
|
+
"transformResponse": [
|
|
222
|
+
null
|
|
223
|
+
],
|
|
224
|
+
"timeout": 0,
|
|
225
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
|
226
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
|
227
|
+
"maxContentLength": -1,
|
|
228
|
+
"maxBodyLength": -1,
|
|
229
|
+
"headers": {
|
|
230
|
+
"Accept": "application/json, text/plain, */*",
|
|
231
|
+
"Content-Type": "application/json"
|
|
232
|
+
},
|
|
233
|
+
"method": "post",
|
|
234
|
+
"url": "api/stam",
|
|
235
|
+
"data": "{\"id\":\"fa1cf12e-7049-4b95-bf81-665de4a263bb\",\"name\":\"noam\"}"
|
|
236
|
+
},
|
|
237
|
+
"status": null
|
|
238
|
+
});
|
|
239
|
+
expect(err).toEqual({
|
|
240
|
+
"message": "Network Error"
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
it("Forbidden", async () => {
|
|
244
|
+
let err = await processHttpException({
|
|
245
|
+
"message": "Request failed with status code 403",
|
|
246
|
+
"name": "Error",
|
|
247
|
+
"stack": "Error: Request failed with status code 403\n at createError (http://localhost:4201/vendor.js:127382:15)\n at settle (http://localhost:4201/vendor.js:94395:12)\n at XMLHttpRequest.onloadend [as __zone_symbol__ON_PROPERTYloadend] (http://localhost:4201/vendor.js:42269:7)\n at XMLHttpRequest.wrapFn (http://localhost:4201/polyfills.js:12099:39)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11742:31)\n at Object.onInvokeTask (http://localhost:4201/vendor.js:73020:33)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11741:60)\n at Zone.runTask (http://localhost:4201/polyfills.js:11514:47)\n at ZoneTask.invokeTask [as invoke] (http://localhost:4201/polyfills.js:11823:34)\n at invokeTask (http://localhost:4201/polyfills.js:12936:14)",
|
|
248
|
+
"isAxiosError": true,
|
|
249
|
+
"response": {
|
|
250
|
+
"data": "Forbidden"
|
|
251
|
+
},
|
|
252
|
+
"config": {
|
|
253
|
+
"transitional": {
|
|
254
|
+
"silentJSONParsing": true,
|
|
255
|
+
"forcedJSONParsing": true,
|
|
256
|
+
"clarifyTimeoutError": false
|
|
257
|
+
},
|
|
258
|
+
"transformRequest": [
|
|
259
|
+
null
|
|
260
|
+
],
|
|
261
|
+
"transformResponse": [
|
|
262
|
+
null
|
|
263
|
+
],
|
|
264
|
+
"timeout": 0,
|
|
265
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
|
266
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
|
267
|
+
"maxContentLength": -1,
|
|
268
|
+
"maxBodyLength": -1,
|
|
269
|
+
"headers": {
|
|
270
|
+
"Accept": "application/json, text/plain, */*",
|
|
271
|
+
"Content-Type": "application/json"
|
|
272
|
+
},
|
|
273
|
+
"method": "post",
|
|
274
|
+
"url": "api/stam",
|
|
275
|
+
"data": "{\"id\":\"6a896b08-de4a-451a-9905-bf17c7690f78\",\"name\":\"noam\"}"
|
|
276
|
+
},
|
|
277
|
+
"status": 403
|
|
278
|
+
});
|
|
279
|
+
expect(err).toEqual({
|
|
280
|
+
"message": "Forbidden",
|
|
281
|
+
"httpStatusCode": 403
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
it("syntax error", async () => {
|
|
285
|
+
let err = await processHttpException({
|
|
286
|
+
"message": "Request failed with status code 400",
|
|
287
|
+
"name": "Error",
|
|
288
|
+
"stack": "Error: Request failed with status code 400\n at createError (http://localhost:4201/vendor.js:127382:15)\n at settle (http://localhost:4201/vendor.js:94395:12)\n at XMLHttpRequest.onloadend [as __zone_symbol__ON_PROPERTYloadend] (http://localhost:4201/vendor.js:42269:7)\n at XMLHttpRequest.wrapFn (http://localhost:4201/polyfills.js:12099:39)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11742:31)\n at Object.onInvokeTask (http://localhost:4201/vendor.js:73020:33)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11741:60)\n at Zone.runTask (http://localhost:4201/polyfills.js:11514:47)\n at ZoneTask.invokeTask [as invoke] (http://localhost:4201/polyfills.js:11823:34)\n at invokeTask (http://localhost:4201/polyfills.js:12936:14)",
|
|
289
|
+
"isAxiosError": true,
|
|
290
|
+
"response": {
|
|
291
|
+
"data": {
|
|
292
|
+
"message": "Cannot read property 'toString' of undefined",
|
|
293
|
+
"stack": "TypeError: Cannot read property 'toString' of undefined\n at Object.saving (C:\\repos\\radweb\\dist\\test-angular\\test-angular\\src\\app\\products-test\\products.component.js:51:19)\n at rowHelperImplementation.<anonymous> (C:\\repos\\radweb\\dist\\test-angular\\core\\src\\remult3\\RepositoryImplementation.js:648:44)\n at Generator.next (<anonymous>)\n at fulfilled (C:\\repos\\radweb\\node_modules\\tslib\\tslib.js:114:62)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"config": {
|
|
297
|
+
"transitional": {
|
|
298
|
+
"silentJSONParsing": true,
|
|
299
|
+
"forcedJSONParsing": true,
|
|
300
|
+
"clarifyTimeoutError": false
|
|
301
|
+
},
|
|
302
|
+
"transformRequest": [
|
|
303
|
+
null
|
|
304
|
+
],
|
|
305
|
+
"transformResponse": [
|
|
306
|
+
null
|
|
307
|
+
],
|
|
308
|
+
"timeout": 0,
|
|
309
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
|
310
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
|
311
|
+
"maxContentLength": -1,
|
|
312
|
+
"maxBodyLength": -1,
|
|
313
|
+
"headers": {
|
|
314
|
+
"Accept": "application/json, text/plain, */*",
|
|
315
|
+
"Content-Type": "application/json"
|
|
316
|
+
},
|
|
317
|
+
"method": "post",
|
|
318
|
+
"url": "api/stam",
|
|
319
|
+
"data": "{\"id\":\"e53e981d-4339-4d92-bb6b-18c6dfb3a9bb\",\"name\":\"noam\"}"
|
|
320
|
+
},
|
|
321
|
+
"status": 400
|
|
322
|
+
});
|
|
323
|
+
expect(err.message).toBe("Cannot read property 'toString' of undefined");
|
|
324
|
+
expect(err.stack).toContain("toString");
|
|
325
|
+
});
|
|
326
|
+
it("validation error", async () => {
|
|
327
|
+
let err = await processHttpException({
|
|
328
|
+
"message": "Request failed with status code 400",
|
|
329
|
+
"name": "Error",
|
|
330
|
+
"stack": "Error: Request failed with status code 400\n at createError (http://localhost:4201/vendor.js:127382:15)\n at settle (http://localhost:4201/vendor.js:94395:12)\n at XMLHttpRequest.onloadend [as __zone_symbol__ON_PROPERTYloadend] (http://localhost:4201/vendor.js:42269:7)\n at XMLHttpRequest.wrapFn (http://localhost:4201/polyfills.js:12099:39)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11742:31)\n at Object.onInvokeTask (http://localhost:4201/vendor.js:73020:33)\n at ZoneDelegate.invokeTask (http://localhost:4201/polyfills.js:11741:60)\n at Zone.runTask (http://localhost:4201/polyfills.js:11514:47)\n at ZoneTask.invokeTask [as invoke] (http://localhost:4201/polyfills.js:11823:34)\n at invokeTask (http://localhost:4201/polyfills.js:12936:14)",
|
|
331
|
+
"isAxiosError": true,
|
|
332
|
+
"response": {
|
|
333
|
+
"data": {
|
|
334
|
+
"modelState": {
|
|
335
|
+
"name": "name error"
|
|
336
|
+
},
|
|
337
|
+
"message": "Name: name error"
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
"config": {
|
|
341
|
+
"transitional": {
|
|
342
|
+
"silentJSONParsing": true,
|
|
343
|
+
"forcedJSONParsing": true,
|
|
344
|
+
"clarifyTimeoutError": false
|
|
345
|
+
},
|
|
346
|
+
"transformRequest": [
|
|
347
|
+
null
|
|
348
|
+
],
|
|
349
|
+
"transformResponse": [
|
|
350
|
+
null
|
|
351
|
+
],
|
|
352
|
+
"timeout": 0,
|
|
353
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
|
354
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
|
355
|
+
"maxContentLength": -1,
|
|
356
|
+
"maxBodyLength": -1,
|
|
357
|
+
"headers": {
|
|
358
|
+
"Accept": "application/json, text/plain, */*",
|
|
359
|
+
"Content-Type": "application/json"
|
|
360
|
+
},
|
|
361
|
+
"method": "post",
|
|
362
|
+
"url": "api/stam",
|
|
363
|
+
"data": "{\"id\":\"d4c16ebf-5d9b-4eff-98cd-1c3f26d6aa08\",\"name\":\"noam\"}"
|
|
364
|
+
},
|
|
365
|
+
"status": 400
|
|
366
|
+
});
|
|
367
|
+
expect(err).toEqual({
|
|
368
|
+
"modelState": {
|
|
369
|
+
"name": "name error"
|
|
370
|
+
},
|
|
371
|
+
"message": "Name: name error",
|
|
372
|
+
"httpStatusCode": 400
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { TestDataApiResponse } from "./TestDataApiResponse";
|
|
2
|
+
import { Done } from "./Done";
|
|
3
|
+
import { Remult } from '../context';
|
|
4
|
+
import { JsonDataProvider } from '../data-providers/json-data-provider';
|
|
5
|
+
import { InMemoryDataProvider } from '../data-providers/in-memory-database';
|
|
6
|
+
import { DataApi } from '../data-api';
|
|
7
|
+
import { Categories as newCategories } from './remult-3-entities';
|
|
8
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
9
|
+
import { tasks } from './tasks';
|
|
10
|
+
import { deleteAll } from "../shared-tests/deleteAll";
|
|
11
|
+
@Entity('entityWithAutoId')
|
|
12
|
+
class entityWithAutoId extends EntityBase {
|
|
13
|
+
@Fields.autoIncrement()
|
|
14
|
+
id;
|
|
15
|
+
@Fields.string()
|
|
16
|
+
name;
|
|
17
|
+
}
|
|
18
|
+
describe("test json database", () => {
|
|
19
|
+
let db = new JsonDataProvider(localStorage);
|
|
20
|
+
let remult = new Remult();
|
|
21
|
+
remult.dataProvider = (db);
|
|
22
|
+
async function deleteAll1() {
|
|
23
|
+
await deleteAll(remult.repo(newCategories));
|
|
24
|
+
}
|
|
25
|
+
it("test auto increment", async () => {
|
|
26
|
+
let remult = new Remult();
|
|
27
|
+
remult.dataProvider = (new InMemoryDataProvider());
|
|
28
|
+
let p = await remult.repo(entityWithAutoId).create({ name: 'a' }).save();
|
|
29
|
+
expect(p.id).toBe(1);
|
|
30
|
+
p = await remult.repo(entityWithAutoId).create({ name: 'b' }).save();
|
|
31
|
+
expect(p.id).toBe(2);
|
|
32
|
+
});
|
|
33
|
+
it("test insert is in the correct order in the result array", async () => {
|
|
34
|
+
const mem = new InMemoryDataProvider();
|
|
35
|
+
const remult = new Remult(mem);
|
|
36
|
+
await remult.repo(entityWithAutoId).insert([
|
|
37
|
+
{ name: 'a' },
|
|
38
|
+
{ name: 'b' },
|
|
39
|
+
{ name: 'c' }
|
|
40
|
+
]);
|
|
41
|
+
expect(mem.rows[await remult.repo(entityWithAutoId).metadata.getDbName()]).toEqual([
|
|
42
|
+
{ id: 1, name: 'a' },
|
|
43
|
+
{ id: 2, name: 'b' },
|
|
44
|
+
{ id: 3, name: 'c' }
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
it("test basics", async () => {
|
|
48
|
+
await deleteAll1();
|
|
49
|
+
expect(await remult.repo(newCategories).count()).toBe(0);
|
|
50
|
+
let promisis = [];
|
|
51
|
+
for (let index = 1; index < 4; index++) {
|
|
52
|
+
let c = remult.repo(newCategories).create();
|
|
53
|
+
c.id = index;
|
|
54
|
+
c.categoryName = "noam" + index;
|
|
55
|
+
promisis.push(c._.save());
|
|
56
|
+
}
|
|
57
|
+
await Promise.all(promisis);
|
|
58
|
+
expect(await remult.repo(newCategories).count()).toBe(3, 'count');
|
|
59
|
+
let cats = await remult.repo(newCategories).find();
|
|
60
|
+
expect(cats.length).toBe(3);
|
|
61
|
+
expect(cats[0].id).toBe(1);
|
|
62
|
+
expect(cats[0].categoryName).toBe("noam1");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("test tasks", () => {
|
|
66
|
+
it("test tasks", async () => {
|
|
67
|
+
let storage = '';
|
|
68
|
+
let db = new JsonDataProvider({
|
|
69
|
+
getItem: () => storage,
|
|
70
|
+
setItem: (x, y) => storage = y
|
|
71
|
+
});
|
|
72
|
+
let cont = new Remult();
|
|
73
|
+
cont.dataProvider = (db);
|
|
74
|
+
let c = cont.repo(tasks);
|
|
75
|
+
let t = c.create();
|
|
76
|
+
t.id = 1;
|
|
77
|
+
await t._.save();
|
|
78
|
+
t = c.create();
|
|
79
|
+
t.id = 2;
|
|
80
|
+
t.completed = true;
|
|
81
|
+
await t._.save();
|
|
82
|
+
t = c.create();
|
|
83
|
+
t.id = 3;
|
|
84
|
+
t.completed = true;
|
|
85
|
+
await t._.save();
|
|
86
|
+
expect(await c.count({ completed: { $ne: true } })).toBe(1);
|
|
87
|
+
expect(await c.count({ completed: true })).toBe(2);
|
|
88
|
+
expect(await c.count({ completed: false })).toBe(1);
|
|
89
|
+
var api = new DataApi(c, cont);
|
|
90
|
+
let tr = new TestDataApiResponse();
|
|
91
|
+
let d = new Done();
|
|
92
|
+
tr.success = async (data) => {
|
|
93
|
+
d.ok();
|
|
94
|
+
expect(data.length).toBe(1);
|
|
95
|
+
};
|
|
96
|
+
await api.getArray(tr, {
|
|
97
|
+
get: x => {
|
|
98
|
+
if (x == 'completed.ne')
|
|
99
|
+
return 'true';
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
d.test();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it("test data api response fails on wrong answer", () => {
|
|
107
|
+
var r = new TestDataApiResponse();
|
|
108
|
+
r.progress(0.5);
|
|
109
|
+
expect(() => r.created({})).toThrowError();
|
|
110
|
+
expect(() => r.deleted()).toThrowError();
|
|
111
|
+
expect(() => r.error({})).toThrowError();
|
|
112
|
+
expect(() => r.forbidden()).toThrowError();
|
|
113
|
+
expect(() => r.notFound()).toThrowError();
|
|
114
|
+
expect(() => r.success({})).toThrowError();
|
|
115
|
+
});
|