Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add parsing spec for bcf topic

Oliver Günther69a27a94aa41
diff --git a/frontend/src/app/modules/bim/bcf/api/bcf-api.service.spec.ts b/frontend/src/app/modules/bim/bcf/api/bcf-api.service.spec.ts
index eb6110c6588..36611460e43 100644
--- a/frontend/src/app/modules/bim/bcf/api/bcf-api.service.spec.ts
+++ b/frontend/src/app/modules/bim/bcf/api/bcf-api.service.spec.ts
@@ -31,9 +31,9 @@ import {BcfApiService} from "core-app/modules/bim/bcf/api/bcf-api.service";
import {BcfResourceCollectionPath, BcfResourcePath} from "core-app/modules/bim/bcf/api/bcf-path-resources";
import {BcfTopicPaths} from "core-app/modules/bim/bcf/api/topics/bcf-topic.paths";
-fdescribe('BcfApiService', function () {
+describe('BcfApiService', function () {
let service:BcfApiService;
-
+
beforeEach(async(() => {
// noinspection JSIgnoredPromiseFromCall
TestBed.configureTestingModule({
diff --git a/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.spec.ts b/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.spec.ts
new file mode 100644
index 00000000000..c0296013b6c
--- /dev/null
+++ b/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.spec.ts
@@ -0,0 +1,46 @@
+import {TypedJSON} from "typedjson";
+import {BcfTopicResource} from "core-app/modules/bim/bcf/api/topics/bcf-topic.resource";
+import * as moment from 'moment';
+
+export const topic_object = {
+ "guid": "00efc0da-b4d5-4933-bcb6-e01513ee2bcc",
+ "topic_type": "Clash",
+ "topic_status": "New",
+ "priority": "Normal",
+ "reference_links": ["/api/v3/work_packages/52"],
+ "title": "Clash between wall and facade",
+ "index": null,
+ "labels": [],
+ "creation_date": "2020-02-25T15:09:15.000Z",
+ "creation_author": "[email protected]",
+ "modified_date": "2020-02-25T15:09:15.000Z",
+ "modified_author": null,
+ "assigned_to": "",
+ "stage": null,
+ "description": "Clash between wall and facade",
+ "due_date": "2020-05-16",
+ "authorization": {
+ "topic_actions": ["update", "updateRelatedTopics", "updateFiles", "createViewpoint"],
+ "topic_status": ["New", "In progress", "Resolved", "Closed"]
+ }
+};
+
+describe('BcfTopicResource', () => {
+ it('can parse from the API returned JSON', () => {
+ let serializer = new TypedJSON(BcfTopicResource);
+ let subject = serializer.parse(topic_object)!;
+
+ expect(subject).toBeInstanceOf(BcfTopicResource);
+ ['guid', 'topic_type', 'topic_status', 'priority', 'reference_links', 'title',
+ 'index', 'labels', 'creation_author', 'modified_author', 'assigned_to', 'stage',
+ 'description'].forEach((item) => expect((subject as any)[item]).toEqual((topic_object as any)[item]));
+
+ // Expect dates
+ expect(subject.creation_date).toEqual(moment(topic_object.creation_date));
+ expect(subject.modified_date).toEqual(moment(topic_object.modified_date));
+ expect(subject.due_date.format('YYYY-MM-DD')).toEqual(topic_object.due_date);
+
+ expect(serializer.toPlainJson(subject)).toEqual(topic_object);
+ });
+});
+
diff --git a/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.ts b/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.ts
index f3fe02596f5..f823b03dc11 100644
--- a/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.ts
+++ b/frontend/src/app/modules/bim/bcf/api/topics/bcf-topic.resource.ts
@@ -1,4 +1,5 @@
import {jsonArrayMember, jsonMember, jsonObject} from "typedjson";
+import * as moment from "moment";
import {Moment} from "moment";
@jsonObject
@@ -58,7 +59,10 @@ export class BcfTopicResource {
@jsonMember
description:string;
- @jsonMember({ deserializer: value => moment(value), serializer: (timestamp:Moment) => timestamp.format('YYYY-MM-DD') })
+ @jsonMember({
+ deserializer: value => moment(value),
+ serializer: (timestamp:Moment) => timestamp.format('YYYY-MM-DD')
+ })
due_date:Moment;
@jsonMember