Skip to content

Commit

Permalink
test: unit tests for instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Feb 28, 2024
1 parent d147750 commit f5654b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/mapping/DataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ SerializableMember({
} else {
return {
predicates: deserializePredicates(item.predicates),
...item,
};
value: item.value,
termType: item.termType,
} as Thing;
}
}),
};
Expand Down
10 changes: 9 additions & 1 deletion test/specs/beacons.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'mocha';
import { DataFactory, DefaultEngine, IriString, NamedNode, Parser, Quad, RDFSerializer, SPARQLDataDriver, Store, ogc, schema, xsd } from '../../src';
import { DataFactory, DefaultEngine, IriString, Literal, NamedNode, Parser, Quad, RDFSerializer, SPARQLDataDriver, Store, ogc, schema, xsd } from '../../src';
import axios from 'axios';
import { expect } from 'chai';
import { DataObject, DataSerializer, SerializableMember, SerializableObject } from '@openhps/core';
Expand Down Expand Up @@ -97,6 +97,12 @@ describe('openhps2021 beacons.ttl', () => {
expect((deserialized as any).rdf
.predicates[schema.hasMap][0]
.predicates[schema.spatialCoverage]).to.not.be.undefined;
expect((deserialized as any).rdf
.predicates[schema.hasMap][0]
.predicates[schema.image]).to.not.be.undefined;
expect((deserialized as any).rdf
.predicates[schema.hasMap][0]
.predicates[schema.image][0]).to.be.instanceOf(Literal);
expect((deserialized as any).rdf
.predicates[schema.hasMap][0]
.predicates[schema.spatialCoverage][0]
Expand Down Expand Up @@ -174,8 +180,10 @@ describe('openhps2021 beacons.ttl', () => {
.predicates[ogc.hasGeometry]).to.not.be.undefined;
const mapObject = RDFSerializer.deserialize((deserialized as any).rdf.predicates[schema.hasMap][0], MapObject);
expect(mapObject).to.not.be.undefined;
expect(mapObject.image).to.not.be.undefined;
const mapObject2 = RDFSerializer.deserialize((pl9_3 as any).rdf.predicates[schema.hasMap][0], MapObject);
expect(mapObject2).to.not.be.undefined;
expect(mapObject2.image).to.not.be.undefined;
done();
}).catch(done);
});
Expand Down

0 comments on commit f5654b7

Please sign in to comment.