1- import {
2- Util ,
3- NamedNode ,
4- Literal ,
5- BlankNode ,
6- Variable ,
7- DefaultGraph ,
8- Quad ,
9- } from '../src/' ;
1+ import { Util , DataFactory } from '../src/' ;
2+
3+ const { namedNode, blankNode, literal, variable, defaultGraph, quad } = DataFactory ;
104
115describe ( 'Util' , ( ) => {
126 describe ( 'isNamedNode' , ( ) => {
137 it ( 'matches an IRI' , ( ) => {
14- Util . isNamedNode ( new NamedNode ( 'http://example.org/' ) ) . should . be . true ;
8+ Util . isNamedNode ( namedNode ( 'http://example.org/' ) ) . should . be . true ;
159 } ) ;
1610
1711 it ( 'matches an empty IRI' , ( ) => {
18- Util . isNamedNode ( new NamedNode ( '' ) ) . should . be . true ;
12+ Util . isNamedNode ( namedNode ( '' ) ) . should . be . true ;
1913 } ) ;
2014
2115 it ( 'does not match a literal' , ( ) => {
22- Util . isNamedNode ( new Literal ( '" http://example.org/" ') ) . should . be . false ;
16+ Util . isNamedNode ( literal ( ' http://example.org/') ) . should . be . false ;
2317 } ) ;
2418
2519 it ( 'does not match a blank node' , ( ) => {
26- Util . isNamedNode ( new BlankNode ( 'x' ) ) . should . be . false ;
20+ Util . isNamedNode ( blankNode ( 'x' ) ) . should . be . false ;
2721 } ) ;
2822
2923 it ( 'does not match a variable' , ( ) => {
30- Util . isNamedNode ( new Variable ( 'x' ) ) . should . be . false ;
24+ Util . isNamedNode ( variable ( 'x' ) ) . should . be . false ;
3125 } ) ;
3226
3327 it ( 'does not match null' , ( ) => {
@@ -41,39 +35,39 @@ describe('Util', () => {
4135
4236 describe ( 'isLiteral' , ( ) => {
4337 it ( 'matches a literal' , ( ) => {
44- Util . isLiteral ( new Literal ( '" http://example.org/" ') ) . should . be . true ;
38+ Util . isLiteral ( literal ( ' http://example.org/') ) . should . be . true ;
4539 } ) ;
4640
4741 it ( 'matches a literal with a language' , ( ) => {
48- Util . isLiteral ( new Literal ( '" English"@ en') ) . should . be . true ;
42+ Util . isLiteral ( literal ( ' English' , ' en') ) . should . be . true ;
4943 } ) ;
5044
5145 it ( 'matches a literal with a language that contains a number' , ( ) => {
52- Util . isLiteral ( new Literal ( '" English" @es-419') ) . should . be . true ;
46+ Util . isLiteral ( literal ( ' English' , ' @es-419') ) . should . be . true ;
5347 } ) ;
5448
5549 it ( 'matches a literal with a type' , ( ) => {
56- Util . isLiteral ( new Literal ( '"3"^^ http://www.w3.org/2001/XMLSchema#integer') ) . should . be . true ;
50+ Util . isLiteral ( literal ( '3' , ' http://www.w3.org/2001/XMLSchema#integer') ) . should . be . true ;
5751 } ) ;
5852
5953 it ( 'matches a literal with a newline' , ( ) => {
60- Util . isLiteral ( new Literal ( '" a\nb" ') ) . should . be . true ;
54+ Util . isLiteral ( literal ( ' a\nb') ) . should . be . true ;
6155 } ) ;
6256
6357 it ( 'matches a literal with a cariage return' , ( ) => {
64- Util . isLiteral ( new Literal ( '" a\rb" ') ) . should . be . true ;
58+ Util . isLiteral ( literal ( ' a\rb') ) . should . be . true ;
6559 } ) ;
6660
6761 it ( 'does not match an IRI' , ( ) => {
68- Util . isLiteral ( new NamedNode ( 'http://example.org/' ) ) . should . be . false ;
62+ Util . isLiteral ( namedNode ( 'http://example.org/' ) ) . should . be . false ;
6963 } ) ;
7064
7165 it ( 'does not match a blank node' , ( ) => {
72- Util . isLiteral ( new BlankNode ( '_:x' ) ) . should . be . false ;
66+ Util . isLiteral ( blankNode ( '_:x' ) ) . should . be . false ;
7367 } ) ;
7468
7569 it ( 'does not match a variable' , ( ) => {
76- Util . isLiteral ( new Variable ( 'x' ) ) . should . be . false ;
70+ Util . isLiteral ( variable ( 'x' ) ) . should . be . false ;
7771 } ) ;
7872
7973 it ( 'does not match null' , ( ) => {
@@ -87,19 +81,19 @@ describe('Util', () => {
8781
8882 describe ( 'isBlankNode' , ( ) => {
8983 it ( 'matches a blank node' , ( ) => {
90- Util . isBlankNode ( new BlankNode ( 'x' ) ) . should . be . true ;
84+ Util . isBlankNode ( blankNode ( 'x' ) ) . should . be . true ;
9185 } ) ;
9286
9387 it ( 'does not match an IRI' , ( ) => {
94- Util . isBlankNode ( new NamedNode ( 'http://example.org/' ) ) . should . be . false ;
88+ Util . isBlankNode ( namedNode ( 'http://example.org/' ) ) . should . be . false ;
9589 } ) ;
9690
9791 it ( 'does not match a literal' , ( ) => {
98- Util . isBlankNode ( new Literal ( '" http://example.org/" ') ) . should . be . false ;
92+ Util . isBlankNode ( literal ( ' http://example.org/') ) . should . be . false ;
9993 } ) ;
10094
10195 it ( 'does not match a variable' , ( ) => {
102- Util . isBlankNode ( new Variable ( 'x' ) ) . should . be . false ;
96+ Util . isBlankNode ( variable ( 'x' ) ) . should . be . false ;
10397 } ) ;
10498
10599 it ( 'does not match null' , ( ) => {
@@ -113,19 +107,19 @@ describe('Util', () => {
113107
114108 describe ( 'isVariable' , ( ) => {
115109 it ( 'matches a variable' , ( ) => {
116- Util . isVariable ( new Variable ( 'x' ) ) . should . be . true ;
110+ Util . isVariable ( variable ( 'x' ) ) . should . be . true ;
117111 } ) ;
118112
119113 it ( 'does not match an IRI' , ( ) => {
120- Util . isVariable ( new NamedNode ( 'http://example.org/' ) ) . should . be . false ;
114+ Util . isVariable ( namedNode ( 'http://example.org/' ) ) . should . be . false ;
121115 } ) ;
122116
123117 it ( 'does not match a literal' , ( ) => {
124- Util . isVariable ( new Literal ( '" http://example.org/" ') ) . should . be . false ;
118+ Util . isVariable ( literal ( ' http://example.org/') ) . should . be . false ;
125119 } ) ;
126120
127121 it ( 'does not match a blank node' , ( ) => {
128- Util . isNamedNode ( new BlankNode ( 'x' ) ) . should . be . false ;
122+ Util . isNamedNode ( blankNode ( 'x' ) ) . should . be . false ;
129123 } ) ;
130124
131125 it ( 'does not match null' , ( ) => {
@@ -139,15 +133,15 @@ describe('Util', () => {
139133
140134 describe ( 'isDefaultGraph' , ( ) => {
141135 it ( 'does not match a blank node' , ( ) => {
142- Util . isDefaultGraph ( new BlankNode ( 'x' ) ) . should . be . false ;
136+ Util . isDefaultGraph ( blankNode ( 'x' ) ) . should . be . false ;
143137 } ) ;
144138
145139 it ( 'does not match an IRI' , ( ) => {
146- Util . isDefaultGraph ( new NamedNode ( 'http://example.org/' ) ) . should . be . false ;
140+ Util . isDefaultGraph ( namedNode ( 'http://example.org/' ) ) . should . be . false ;
147141 } ) ;
148142
149143 it ( 'does not match a literal' , ( ) => {
150- Util . isDefaultGraph ( new Literal ( '" http://example.org/" ') ) . should . be . false ;
144+ Util . isDefaultGraph ( literal ( ' http://example.org/') ) . should . be . false ;
151145 } ) ;
152146
153147 it ( 'does not match null' , ( ) => {
@@ -161,27 +155,27 @@ describe('Util', () => {
161155
162156 describe ( 'inDefaultGraph' , ( ) => {
163157 it ( 'does not match a blank node' , ( ) => {
164- Util . inDefaultGraph ( new Quad ( null , null , null , new BlankNode ( 'x' ) ) ) . should . be . false ;
158+ Util . inDefaultGraph ( quad ( null , null , null , blankNode ( 'x' ) ) ) . should . be . false ;
165159 } ) ;
166160
167161 it ( 'does not match an IRI' , ( ) => {
168- Util . inDefaultGraph ( new Quad ( null , null , null , new NamedNode ( 'http://example.org/' ) ) ) . should . be . false ;
162+ Util . inDefaultGraph ( quad ( null , null , null , namedNode ( 'http://example.org/' ) ) ) . should . be . false ;
169163 } ) ;
170164
171165 it ( 'does not match a literal' , ( ) => {
172- Util . inDefaultGraph ( new Quad ( null , null , null , new Literal ( '" http://example.org/" ') ) ) . should . be . false ;
166+ Util . inDefaultGraph ( quad ( null , null , null , literal ( ' http://example.org/') ) ) . should . be . false ;
173167 } ) ;
174168
175169 it ( 'matches null' , ( ) => {
176- Util . inDefaultGraph ( new Quad ( null , null , null , null ) ) . should . be . true ;
170+ Util . inDefaultGraph ( quad ( null , null , null , null ) ) . should . be . true ;
177171 } ) ;
178172
179173 it ( 'matches undefined' , ( ) => {
180- Util . inDefaultGraph ( new Quad ( null , null , null , undefined ) ) . should . be . true ;
174+ Util . inDefaultGraph ( quad ( null , null , null , undefined ) ) . should . be . true ;
181175 } ) ;
182176
183177 it ( 'matches the default graph' , ( ) => {
184- Util . inDefaultGraph ( new Quad ( null , null , null , new DefaultGraph ( ) ) ) . should . be . true ;
178+ Util . inDefaultGraph ( quad ( null , null , null , defaultGraph ( ) ) ) . should . be . true ;
185179 } ) ;
186180 } ) ;
187181
@@ -193,7 +187,7 @@ describe('Util', () => {
193187
194188 describe ( 'the function' , ( ) => {
195189 it ( 'should expand the prefix' , ( ) => {
196- expect ( rdfs ( 'label' ) ) . to . deep . equal ( new NamedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
190+ expect ( rdfs ( 'label' ) ) . to . deep . equal ( namedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
197191 } ) ;
198192
199193 it ( 'should use a custom factory when specified' , ( ) => {
@@ -225,7 +219,7 @@ describe('Util', () => {
225219
226220 it ( 'should expand the newly registered prefix' , ( ) => {
227221 const rdfs = prefixes ( 'rdfs' ) ;
228- expect ( rdfs ( 'label' ) ) . to . deep . equal ( new NamedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
222+ expect ( rdfs ( 'label' ) ) . to . deep . equal ( namedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
229223 } ) ;
230224 } ) ;
231225 } ) ;
@@ -241,8 +235,8 @@ describe('Util', () => {
241235
242236 describe ( 'the function' , ( ) => {
243237 it ( 'should expand registered prefixes' , ( ) => {
244- expect ( prefixes ( 'rdfs' ) ( 'label' ) ) . to . deep . equal ( new NamedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
245- expect ( prefixes ( 'owl' ) ( 'sameAs' ) ) . to . deep . equal ( new NamedNode ( 'http://www.w3.org/2002/07/owl#sameAs' ) ) ;
238+ expect ( prefixes ( 'rdfs' ) ( 'label' ) ) . to . deep . equal ( namedNode ( 'http://www.w3.org/2000/01/rdf-schema#label' ) ) ;
239+ expect ( prefixes ( 'owl' ) ( 'sameAs' ) ) . to . deep . equal ( namedNode ( 'http://www.w3.org/2002/07/owl#sameAs' ) ) ;
246240 } ) ;
247241
248242 it ( 'should not expand non-registered prefixes' , ( ) => {
@@ -258,7 +252,7 @@ describe('Util', () => {
258252
259253 it ( 'should expand the newly registered prefix' , ( ) => {
260254 const my = prefixes ( 'my' ) ;
261- expect ( my ( 'me' ) ) . to . deep . equal ( new NamedNode ( 'http://example.org/#me' ) ) ;
255+ expect ( my ( 'me' ) ) . to . deep . equal ( namedNode ( 'http://example.org/#me' ) ) ;
262256 } ) ;
263257 } ) ;
264258 } ) ;
0 commit comments