@@ -4,129 +4,134 @@ import { instance, sparqlEndpoint } from './lib/tests_env.js'
4
4
5
5
describe ( 'builder' , ( ) => {
6
6
it ( 'should be a function' , ( ) => {
7
- defaultWBK . should . be . a . Function ( )
8
- WBK . should . be . a . Function ( )
9
- defaultWBK . should . equal ( WBK )
7
+ should ( defaultWBK ) . be . a . Function ( )
8
+ should ( WBK ) . be . a . Function ( )
9
+ should ( defaultWBK ) . equal ( WBK )
10
10
} )
11
11
12
12
it ( 'should reference instance-independant helpers' , ( ) => {
13
13
should ( parse ) . be . an . Object ( )
14
14
should ( simplify ) . be . an . Object ( )
15
- parse . entities . should . be . a . Function ( )
16
- simplify . labels . should . be . a . Function ( )
17
- simplifySparqlResults . should . be . a . Function ( )
18
- isEntityId . should . be . a . Function ( )
19
- getSitelinkData . should . be . a . Function ( )
15
+ should ( parse . entities ) . be . a . Function ( )
16
+ should ( simplify . labels ) . be . a . Function ( )
17
+ should ( simplifySparqlResults ) . be . a . Function ( )
18
+ should ( isEntityId ) . be . a . Function ( )
19
+ should ( getSitelinkData ) . be . a . Function ( )
20
20
} )
21
21
22
22
it ( 'should throw when initialized without a config' , ( ) => {
23
- WBK . should . throw ( )
23
+ // @ts -expect-error missing argument
24
+ should ( ( ) => WBK ( ) ) . throw ( )
24
25
} )
25
26
26
27
it ( 'should throw when initialized without an instance or a sparqlEndpoint' , ( ) => {
27
- ( ( ) => WBK ( { } ) ) . should . throw ( )
28
+ should ( ( ) => WBK ( { } ) ) . throw ( )
28
29
} )
29
30
30
31
it ( 'should throw when initialized with an invalid instance' , ( ) => {
31
- ( ( ) => WBK ( { instance : 'foo' } ) ) . should . throw ( 'invalid instance: foo' )
32
+ should ( ( ) => WBK ( { instance : 'foo' } ) ) . throw ( 'invalid instance: foo' )
32
33
} )
33
34
34
35
it ( 'should throw when initialized with an invalid sparql endpoint' , ( ) => {
35
- ( ( ) => WBK ( { instance, sparqlEndpoint : 'foo' } ) ) . should . throw ( 'invalid sparqlEndpoint: foo' )
36
+ should ( ( ) => WBK ( { instance, sparqlEndpoint : 'foo' } ) ) . throw ( 'invalid sparqlEndpoint: foo' )
36
37
} )
37
38
38
39
it ( 'should not throw when initialized without a sparql endpoint' , ( ) => {
39
40
const wbk = WBK ( { instance } )
40
- wbk . sparqlQuery . should . throw ( 'sparqlQuery requires a sparqlEndpoint to be set at initialization' )
41
- wbk . getReverseClaims . should . throw ( 'getReverseClaims requires a sparqlEndpoint to be set at initialization' )
41
+ // @ts -expect-error missing argument
42
+ should ( ( ) => wbk . sparqlQuery ( ) ) . throw ( 'sparqlQuery requires a sparqlEndpoint to be set at initialization' )
43
+ // @ts -expect-error missing argument
44
+ should ( ( ) => wbk . getReverseClaims ( ) ) . throw ( 'getReverseClaims requires a sparqlEndpoint to be set at initialization' )
42
45
} )
43
46
44
47
it ( 'should not throw when initialized without a sparql endpoint' , ( ) => {
45
48
const wbk = WBK ( { sparqlEndpoint } )
46
- wbk . searchEntities . should . throw ( 'searchEntities requires an instance to be set at initialization' )
47
- wbk . getEntities . should . throw ( 'getEntities requires an instance to be set at initialization' )
49
+ // @ts -expect-error missing argument
50
+ should ( ( ) => wbk . searchEntities ( ) ) . throw ( 'searchEntities requires an instance to be set at initialization' )
51
+ // @ts -expect-error missing argument
52
+ should ( ( ) => wbk . getEntities ( ) ) . throw ( 'getEntities requires an instance to be set at initialization' )
48
53
} )
49
54
50
55
it ( 'should produce valid URLs' , ( ) => {
51
56
const wbk = WBK ( { instance, sparqlEndpoint } )
52
- wbk . searchEntities ( { search : 'ingmar Bergman' } ) . should . startWith ( instance )
53
- wbk . getReverseClaims ( { properties : 'P50' , values : 'Q504' } ) . should . startWith ( sparqlEndpoint )
57
+ should ( wbk . searchEntities ( { search : 'ingmar Bergman' } ) ) . startWith ( instance )
58
+ should ( wbk . getReverseClaims ( { properties : 'P50' , values : 'Q504' } ) ) . startWith ( sparqlEndpoint )
54
59
} )
55
60
56
61
it ( 'should exposed sanitized instance URL' , ( ) => {
57
62
const wbk = WBK ( { instance, sparqlEndpoint } )
58
- wbk . instance . root . should . equal ( instance )
59
- wbk . instance . apiEndpoint . should . equal ( `${ instance } /w/api.php` )
63
+ should ( wbk . instance . root ) . equal ( instance )
64
+ should ( wbk . instance . apiEndpoint ) . equal ( `${ instance } /w/api.php` )
60
65
} )
61
66
62
67
it ( 'should allow to customize the script path' , ( ) => {
63
- WBK ( { instance, wgScriptPath : 'foo' } ) . instance . apiEndpoint . should . equal ( `${ instance } /foo/api.php` )
64
- WBK ( { instance, wgScriptPath : '/foo' } ) . instance . apiEndpoint . should . equal ( `${ instance } /foo/api.php` )
68
+ should ( WBK ( { instance, wgScriptPath : 'foo' } ) . instance . apiEndpoint ) . equal ( `${ instance } /foo/api.php` )
69
+ should ( WBK ( { instance, wgScriptPath : '/foo' } ) . instance . apiEndpoint ) . equal ( `${ instance } /foo/api.php` )
65
70
} )
66
71
} )
67
72
68
73
describe ( 'index' , ( ) => {
69
74
it ( 'should give access to all the function' , ( ) => {
70
75
const wbk = WBK ( { instance, sparqlEndpoint } )
71
76
72
- wbk . should . be . an . Object ( )
73
-
74
- wbk . searchEntities . should . be . a . Function ( )
75
- wbk . cirrusSearchPages . should . be . a . Function ( )
76
- wbk . getEntities . should . be . a . Function ( )
77
- wbk . getManyEntities . should . be . a . Function ( )
78
- wbk . getEntityRevision . should . be . a . Function ( )
79
- wbk . getReverseClaims . should . be . a . Function ( )
80
- wbk . getRevisions . should . be . a . Function ( )
81
- wbk . getEntitiesFromSitelinks . should . be . a . Function ( )
82
-
83
- wbk . simplify . entity . should . be . a . Function ( )
84
- wbk . simplify . entities . should . be . a . Function ( )
85
- wbk . simplify . labels . should . be . a . Function ( )
86
- wbk . simplify . descriptions . should . be . a . Function ( )
87
- wbk . simplify . aliases . should . be . a . Function ( )
88
- wbk . simplify . sitelinks . should . be . a . Function ( )
89
- wbk . simplify . claim . should . be . a . Function ( )
90
- wbk . simplify . propertyClaims . should . be . a . Function ( )
91
- wbk . simplify . claims . should . be . a . Function ( )
92
- wbk . simplify . snak . should . be . a . Function ( )
93
- wbk . simplify . propertySnaks . should . be . a . Function ( )
94
- wbk . simplify . snaks . should . be . a . Function ( )
95
- wbk . simplify . qualifier . should . be . a . Function ( )
96
- wbk . simplify . propertyQualifiers . should . be . a . Function ( )
97
- wbk . simplify . qualifiers . should . be . a . Function ( )
98
- wbk . simplify . forms . should . be . a . Function ( )
99
- wbk . simplify . form . should . be . a . Function ( )
100
- wbk . simplify . senses . should . be . a . Function ( )
101
- wbk . simplify . sense . should . be . a . Function ( )
102
- wbk . simplify . sparqlResults . should . be . a . Function ( )
103
- wbk . truthyClaims . should . be . a . Function ( )
104
- wbk . truthyPropertyClaims . should . be . a . Function ( )
105
-
106
- wbk . parse . entities . should . be . a . Function ( )
107
-
108
- wbk . parse . entities . should . be . a . Function ( )
109
- wbk . parse . pagesTitles . should . be . a . Function ( )
110
-
111
- wbk . isEntityId . should . be . a . Function ( )
112
- wbk . isItemId . should . be . a . Function ( )
113
- wbk . isPropertyId . should . be . a . Function ( )
114
- wbk . isNumericId . should . be . a . Function ( )
115
- wbk . isGuid . should . be . a . Function ( )
116
- wbk . isHash . should . be . a . Function ( )
117
- wbk . isPropertyClaimsId . should . be . a . Function ( )
118
- wbk . getNumericId . should . be . a . Function ( )
119
- wbk . isEntityId . should . be . a . Function ( )
120
- wbk . isItemId . should . be . a . Function ( )
121
- wbk . isPropertyId . should . be . a . Function ( )
122
- wbk . wikibaseTimeToDateObject . should . be . a . Function ( )
123
- wbk . wikibaseTimeToEpochTime . should . be . a . Function ( )
124
- wbk . wikibaseTimeToISOString . should . be . a . Function ( )
125
- wbk . wikibaseTimeToSimpleDay . should . be . a . Function ( )
126
- wbk . getSitelinkUrl . should . be . a . Function ( )
127
- wbk . getSitelinkData . should . be . a . Function ( )
128
- wbk . isSitelinkKey . should . be . a . Function ( )
129
- wbk . getImageUrl . should . be . a . Function ( )
130
- wbk . getEntityIdFromGuid . should . be . a . Function ( )
77
+ should ( wbk ) . be . an . Object ( )
78
+
79
+ should ( wbk . searchEntities ) . be . a . Function ( )
80
+ should ( wbk . cirrusSearchPages ) . be . a . Function ( )
81
+ should ( wbk . getEntities ) . be . a . Function ( )
82
+ should ( wbk . getManyEntities ) . be . a . Function ( )
83
+ should ( wbk . getEntityRevision ) . be . a . Function ( )
84
+ should ( wbk . getReverseClaims ) . be . a . Function ( )
85
+ should ( wbk . getRevisions ) . be . a . Function ( )
86
+ should ( wbk . getEntitiesFromSitelinks ) . be . a . Function ( )
87
+
88
+ should ( wbk . simplify . entity ) . be . a . Function ( )
89
+ should ( wbk . simplify . entities ) . be . a . Function ( )
90
+ should ( wbk . simplify . labels ) . be . a . Function ( )
91
+ should ( wbk . simplify . descriptions ) . be . a . Function ( )
92
+ should ( wbk . simplify . aliases ) . be . a . Function ( )
93
+ should ( wbk . simplify . sitelinks ) . be . a . Function ( )
94
+ should ( wbk . simplify . claim ) . be . a . Function ( )
95
+ should ( wbk . simplify . propertyClaims ) . be . a . Function ( )
96
+ should ( wbk . simplify . claims ) . be . a . Function ( )
97
+ should ( wbk . simplify . snak ) . be . a . Function ( )
98
+ should ( wbk . simplify . propertySnaks ) . be . a . Function ( )
99
+ should ( wbk . simplify . snaks ) . be . a . Function ( )
100
+ should ( wbk . simplify . qualifier ) . be . a . Function ( )
101
+ should ( wbk . simplify . propertyQualifiers ) . be . a . Function ( )
102
+ should ( wbk . simplify . qualifiers ) . be . a . Function ( )
103
+ should ( wbk . simplify . forms ) . be . a . Function ( )
104
+ should ( wbk . simplify . form ) . be . a . Function ( )
105
+ should ( wbk . simplify . senses ) . be . a . Function ( )
106
+ should ( wbk . simplify . sense ) . be . a . Function ( )
107
+ should ( wbk . simplify . sparqlResults ) . be . a . Function ( )
108
+ should ( wbk . truthyClaims ) . be . a . Function ( )
109
+ should ( wbk . truthyPropertyClaims ) . be . a . Function ( )
110
+
111
+ should ( wbk . parse . entities ) . be . a . Function ( )
112
+
113
+ should ( wbk . parse . entities ) . be . a . Function ( )
114
+ should ( wbk . parse . pagesTitles ) . be . a . Function ( )
115
+
116
+ should ( wbk . isEntityId ) . be . a . Function ( )
117
+ should ( wbk . isItemId ) . be . a . Function ( )
118
+ should ( wbk . isPropertyId ) . be . a . Function ( )
119
+ should ( wbk . isNumericId ) . be . a . Function ( )
120
+ should ( wbk . isGuid ) . be . a . Function ( )
121
+ should ( wbk . isHash ) . be . a . Function ( )
122
+ should ( wbk . isPropertyClaimsId ) . be . a . Function ( )
123
+ should ( wbk . getNumericId ) . be . a . Function ( )
124
+ should ( wbk . isEntityId ) . be . a . Function ( )
125
+ should ( wbk . isItemId ) . be . a . Function ( )
126
+ should ( wbk . isPropertyId ) . be . a . Function ( )
127
+ should ( wbk . wikibaseTimeToDateObject ) . be . a . Function ( )
128
+ should ( wbk . wikibaseTimeToEpochTime ) . be . a . Function ( )
129
+ should ( wbk . wikibaseTimeToISOString ) . be . a . Function ( )
130
+ should ( wbk . wikibaseTimeToSimpleDay ) . be . a . Function ( )
131
+ should ( wbk . getSitelinkUrl ) . be . a . Function ( )
132
+ should ( wbk . getSitelinkData ) . be . a . Function ( )
133
+ should ( wbk . isSitelinkKey ) . be . a . Function ( )
134
+ should ( wbk . getImageUrl ) . be . a . Function ( )
135
+ should ( wbk . getEntityIdFromGuid ) . be . a . Function ( )
131
136
} )
132
137
} )
0 commit comments