Skip to content

Commit

Permalink
Test the applicablePredicates utility function (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed May 11, 2021
1 parent ac9c306 commit ec448ea
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions frontend/src/utilities/relation-utilities-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { constant } from 'lodash';

import { startStore, endStore } from '../test-util';
import mockOntology from '../mock-data/mock-ontology';

import ldChannel from '../common-rdf/radio';
import { readit, skos } from '../common-rdf/ns';
import Node from '../common-rdf/node';
import Graph from '../common-rdf/graph';

import { applicablePredicates } from './relation-utilities';

describe('relation utilities', function() {
beforeEach(startStore);

beforeEach(function() {
const ontology = new Graph(mockOntology);
ldChannel.reply('ontology:graph', constant(ontology));
});

afterEach(function() {
ldChannel.stopReplying('ontology:graph');
});

afterEach(endStore);

describe('applicablePredicates', function() {
it('returns the predicates applicable to a given class', function() {
const Reader = ldChannel.request('obtain', readit('Reader'));
const predicates = applicablePredicates(Reader);
expect(predicates.length).toBe(2);
expect(predicates.at(0).get(skos.prefLabel)).toBe('description of');
expect(predicates.at(1).get(skos.prefLabel)).toBe('inverse of description of');
});
});
});

0 comments on commit ec448ea

Please sign in to comment.