@@ -9,32 +9,44 @@ import { expandProperty } from "../memoizedNamespace";
99describe ( "memoizedNamespace" , ( ) => {
1010 describe ( "expandProperty" , ( ) => {
1111 it ( "returns identity when passed undefined" , ( ) => {
12- expect ( expandProperty ( undefined , { } ) ) . toBeUndefined ( ) ;
12+ expect ( expandProperty ( undefined ) ) . toBeUndefined ( ) ;
1313 } ) ;
1414
1515 it ( "returns identity when passed NamedNode" , ( ) => {
1616 const n = rdfFactory . namedNode ( "http://example.com" ) ;
17- expect ( expandProperty ( n , { } ) ) . toEqual ( n ) ;
17+ expect ( expandProperty ( n ) ) . toEqual ( n ) ;
1818 } ) ;
1919
2020 it ( "returns a NamedNode when passed a plain NN object" , ( ) => {
2121 const n = {
2222 termType : "NamedNode" ,
2323 value : "http://example.com/ns#1" ,
2424 } ;
25- expect ( expandProperty ( n , { } ) ) . toEqual ( ex . ns ( "1" ) ) ;
25+ expect ( expandProperty ( n ) ) . toEqual ( ex . ns ( "1" ) ) ;
26+ } ) ;
27+
28+ it ( "returns a NamedNode when passed a plain NN object with prototype interface properties" , ( ) => {
29+ const proto = { termType : "NamedNode" } ;
30+ const n = Object . create ( proto ) ;
31+ n . value = "http://example.com/ns#1" ;
32+
33+ expect ( expandProperty ( n ) ) . toEqual ( ex . ns ( "1" ) ) ;
2634 } ) ;
2735
2836 it ( "returns undefined when passed a random plain object" , ( ) => {
2937 const n = {
3038 termType : "Whatever" ,
3139 value : "http://example.com/ns#1" ,
3240 } ;
33- expect ( expandProperty ( ( n as NamedNode ) , { } ) ) . toBeUndefined ( ) ;
41+ expect ( expandProperty ( ( n as NamedNode ) ) ) . toBeUndefined ( ) ;
3442 } ) ;
3543
3644 it ( "parses url strings to NamedNodes" , ( ) => {
37- expect ( expandProperty ( "http://example.com/ns#1" , { } ) ) . toEqual ( ex . ns ( "1" ) ) ;
45+ expect ( expandProperty ( "http://example.com/ns#1" ) ) . toEqual ( ex . ns ( "1" ) ) ;
46+ } ) ;
47+
48+ it ( "parses n-quads formatted strings to NamedNodes" , ( ) => {
49+ expect ( expandProperty ( "<http://example.com/ns#1>" ) ) . toEqual ( ex . ns ( "1" ) ) ;
3850 } ) ;
3951
4052 it ( "parses shorthand strings to NamedNodes" , ( ) => {
0 commit comments