@comunica/utils-jest 3.2.4-alpha.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +22 -0
- package/README.md +126 -0
- package/lib/expressions.d.ts +28 -0
- package/lib/expressions.js +129 -0
- package/lib/expressions.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/matchers/index.d.ts +2 -0
- package/lib/matchers/index.js +17 -0
- package/lib/matchers/index.js.map +1 -0
- package/lib/matchers/toEqualBindings.d.ts +5 -0
- package/lib/matchers/toEqualBindings.js +24 -0
- package/lib/matchers/toEqualBindings.js.map +1 -0
- package/lib/matchers/toEqualBindingsArray.d.ts +8 -0
- package/lib/matchers/toEqualBindingsArray.js +31 -0
- package/lib/matchers/toEqualBindingsArray.js.map +1 -0
- package/lib/matchers/toEqualBindingsStream.d.ts +9 -0
- package/lib/matchers/toEqualBindingsStream.js +10 -0
- package/lib/matchers/toEqualBindingsStream.js.map +1 -0
- package/lib/matchers/toFailTest.d.ts +8 -0
- package/lib/matchers/toFailTest.js +25 -0
- package/lib/matchers/toFailTest.js.map +1 -0
- package/lib/matchers/toPassTest.d.ts +8 -0
- package/lib/matchers/toPassTest.js +26 -0
- package/lib/matchers/toPassTest.js.map +1 -0
- package/lib/matchers/toPassTestVoid.d.ts +8 -0
- package/lib/matchers/toPassTestVoid.js +25 -0
- package/lib/matchers/toPassTestVoid.js.map +1 -0
- package/package.json +54 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Comunica Jest helpers
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/utils-jest)
|
|
4
|
+
|
|
5
|
+
Jest test helpers for Comunica
|
|
6
|
+
|
|
7
|
+
This module is part of the [Comunica framework](https://github.com/comunica/comunica),
|
|
8
|
+
and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
|
|
9
|
+
|
|
10
|
+
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
$ yarn add --save-dev @comunica/utils-jest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
In order to use matchers in your tests,
|
|
21
|
+
you'll have to make sure that they are imported.
|
|
22
|
+
This can be done by adding the following entry to your Jest configuration:
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"jest": {
|
|
26
|
+
"setupFilesAfterEnv": ["@comunica/utils-jest"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you are already using an existing test framework script file,
|
|
32
|
+
make sure to add @comunica/utils-jest as follows to your file:
|
|
33
|
+
```javascript
|
|
34
|
+
...
|
|
35
|
+
require('@comunica/utils-jest');
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## _Optional: Typescript typings configuration_
|
|
39
|
+
|
|
40
|
+
If you are using TypeScript, possibly in combination with [ts-jest](https://www.npmjs.com/package/ts-jest),
|
|
41
|
+
you will need to import the typings of this package to make the TS compiler recognise the new matchers.
|
|
42
|
+
|
|
43
|
+
For this, include the following import at the top of each applicable test file:
|
|
44
|
+
```
|
|
45
|
+
import "@comunica/utils-jest";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
All examples below make use of these helpers:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { BindingsFactory } from '@comunica/utils-bindings-factory';
|
|
54
|
+
import { DataFactory } from 'rdf-data-factory';
|
|
55
|
+
|
|
56
|
+
const BF = new BindingsFactory(DF);
|
|
57
|
+
const DF = new DataFactory();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### toEqualBindings
|
|
61
|
+
|
|
62
|
+
Check if two Bindings are equal.
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
expect(BF.bindings([
|
|
66
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
67
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
68
|
+
])).toEqualBindings(BF.bindings([
|
|
69
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
70
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
71
|
+
]));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### toEqualBindingsArray
|
|
75
|
+
|
|
76
|
+
Check if two Bindings arrays are equal.
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
expect([
|
|
80
|
+
BF.bindings([
|
|
81
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
82
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
83
|
+
]),
|
|
84
|
+
BF.bindings([
|
|
85
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
86
|
+
[ DF.variable('c'), DF.namedNode('c1') ],
|
|
87
|
+
]),
|
|
88
|
+
]).toEqualBindingsArray([
|
|
89
|
+
BF.bindings([
|
|
90
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
91
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
92
|
+
]),
|
|
93
|
+
BF.bindings([
|
|
94
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
95
|
+
[ DF.variable('c'), DF.namedNode('c1') ],
|
|
96
|
+
]),
|
|
97
|
+
]);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### toEqualBindingsStream
|
|
101
|
+
|
|
102
|
+
Check if a Bindings stream equals a Bindings array.
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import { ArrayIterator } from 'asynciterator';
|
|
106
|
+
|
|
107
|
+
expect(new ArrayIterator([
|
|
108
|
+
BF.bindings([
|
|
109
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
110
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
111
|
+
]),
|
|
112
|
+
BF.bindings([
|
|
113
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
114
|
+
[ DF.variable('c'), DF.namedNode('c1') ],
|
|
115
|
+
]),
|
|
116
|
+
], { autoStart: false })).toEqualBindingsStream([
|
|
117
|
+
BF.bindings([
|
|
118
|
+
[ DF.variable('a'), DF.namedNode('a1') ],
|
|
119
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
120
|
+
]),
|
|
121
|
+
BF.bindings([
|
|
122
|
+
[ DF.variable('b'), DF.namedNode('b1') ],
|
|
123
|
+
[ DF.variable('c'), DF.namedNode('c1') ],
|
|
124
|
+
]),
|
|
125
|
+
]);
|
|
126
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InternalEvaluator } from '@comunica/actor-expression-evaluator-factory-default/lib/InternalEvaluator';
|
|
2
|
+
import type { ActorExpressionEvaluatorFactory, IActorExpressionEvaluatorFactoryArgs, MediatorExpressionEvaluatorFactory } from '@comunica/bus-expression-evaluator-factory';
|
|
3
|
+
import type { MediatorFunctionFactory } from '@comunica/bus-function-factory';
|
|
4
|
+
import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';
|
|
5
|
+
import type { MediatorQueryOperation } from '@comunica/bus-query-operation';
|
|
6
|
+
import type { IActionContext, ISuperTypeProvider } from '@comunica/types';
|
|
7
|
+
import { BindingsFactory } from '@comunica/utils-bindings-factory';
|
|
8
|
+
import type * as RDF from '@rdfjs/types';
|
|
9
|
+
import { DataFactory } from 'rdf-data-factory';
|
|
10
|
+
import { Algebra } from 'sparqlalgebrajs';
|
|
11
|
+
export declare const DF: DataFactory<RDF.Quad>;
|
|
12
|
+
export declare const BF: BindingsFactory;
|
|
13
|
+
export declare function makeAggregate(aggregator: string, distinct?: boolean, separator?: string, wildcard?: boolean): Algebra.AggregateExpression;
|
|
14
|
+
export declare function int(value: string): RDF.Term;
|
|
15
|
+
export declare function float(value: string): RDF.Term;
|
|
16
|
+
export declare function decimal(value: string): RDF.Term;
|
|
17
|
+
export declare function date(value: string): RDF.Term;
|
|
18
|
+
export declare function string(value: string): RDF.Term;
|
|
19
|
+
export declare function double(value: string): RDF.Term;
|
|
20
|
+
export declare function nonLiteral(): RDF.Term;
|
|
21
|
+
export declare function getMockEEActionContext(actionContext?: IActionContext): IActionContext;
|
|
22
|
+
export declare function getMockInternalEvaluator(factory?: ActorExpressionEvaluatorFactory, context?: IActionContext): InternalEvaluator;
|
|
23
|
+
export declare function getMockEEFactory({ mediatorQueryOperation, mediatorFunctionFactory, mediatorMergeBindingsContext, }?: Partial<IActorExpressionEvaluatorFactoryArgs>): ActorExpressionEvaluatorFactory;
|
|
24
|
+
export declare function getMockMediatorQueryOperation(): MediatorQueryOperation;
|
|
25
|
+
export declare function getMockMediatorMergeBindingsContext(): MediatorMergeBindingsContext;
|
|
26
|
+
export declare function getMockMediatorExpressionEvaluatorFactory(args?: Partial<IActorExpressionEvaluatorFactoryArgs>): MediatorExpressionEvaluatorFactory;
|
|
27
|
+
export declare function getMockMediatorFunctionFactory(): MediatorFunctionFactory;
|
|
28
|
+
export declare function getMockSuperTypeProvider(): ISuperTypeProvider;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMockSuperTypeProvider = exports.getMockMediatorFunctionFactory = exports.getMockMediatorExpressionEvaluatorFactory = exports.getMockMediatorMergeBindingsContext = exports.getMockMediatorQueryOperation = exports.getMockEEFactory = exports.getMockInternalEvaluator = exports.getMockEEActionContext = exports.nonLiteral = exports.double = exports.string = exports.date = exports.decimal = exports.float = exports.int = exports.makeAggregate = exports.BF = exports.DF = void 0;
|
|
4
|
+
const lib_1 = require("@comunica/actor-expression-evaluator-factory-default/lib");
|
|
5
|
+
const InternalEvaluator_1 = require("@comunica/actor-expression-evaluator-factory-default/lib/InternalEvaluator");
|
|
6
|
+
const context_entries_1 = require("@comunica/context-entries");
|
|
7
|
+
const core_1 = require("@comunica/core");
|
|
8
|
+
const Eval = require("@comunica/expression-evaluator");
|
|
9
|
+
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
10
|
+
const lru_cache_1 = require("lru-cache");
|
|
11
|
+
const rdf_data_factory_1 = require("rdf-data-factory");
|
|
12
|
+
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
13
|
+
const sparqljs_1 = require("sparqljs");
|
|
14
|
+
exports.DF = new rdf_data_factory_1.DataFactory();
|
|
15
|
+
exports.BF = new utils_bindings_factory_1.BindingsFactory(exports.DF);
|
|
16
|
+
function makeAggregate(aggregator, distinct = false, separator, wildcard = false) {
|
|
17
|
+
const inner = wildcard ?
|
|
18
|
+
{
|
|
19
|
+
type: sparqlalgebrajs_1.Algebra.types.EXPRESSION,
|
|
20
|
+
expressionType: sparqlalgebrajs_1.Algebra.expressionTypes.WILDCARD,
|
|
21
|
+
wildcard: new sparqljs_1.Wildcard(),
|
|
22
|
+
} :
|
|
23
|
+
{
|
|
24
|
+
type: sparqlalgebrajs_1.Algebra.types.EXPRESSION,
|
|
25
|
+
expressionType: sparqlalgebrajs_1.Algebra.expressionTypes.TERM,
|
|
26
|
+
term: exports.DF.variable('x'),
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
type: sparqlalgebrajs_1.Algebra.types.EXPRESSION,
|
|
30
|
+
expressionType: sparqlalgebrajs_1.Algebra.expressionTypes.AGGREGATE,
|
|
31
|
+
aggregator: aggregator,
|
|
32
|
+
distinct,
|
|
33
|
+
separator,
|
|
34
|
+
expression: inner,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.makeAggregate = makeAggregate;
|
|
38
|
+
function int(value) {
|
|
39
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#integer'));
|
|
40
|
+
}
|
|
41
|
+
exports.int = int;
|
|
42
|
+
function float(value) {
|
|
43
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#float'));
|
|
44
|
+
}
|
|
45
|
+
exports.float = float;
|
|
46
|
+
function decimal(value) {
|
|
47
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#decimal'));
|
|
48
|
+
}
|
|
49
|
+
exports.decimal = decimal;
|
|
50
|
+
function date(value) {
|
|
51
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#date'));
|
|
52
|
+
}
|
|
53
|
+
exports.date = date;
|
|
54
|
+
function string(value) {
|
|
55
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#string'));
|
|
56
|
+
}
|
|
57
|
+
exports.string = string;
|
|
58
|
+
function double(value) {
|
|
59
|
+
return exports.DF.literal(value, exports.DF.namedNode('http://www.w3.org/2001/XMLSchema#double'));
|
|
60
|
+
}
|
|
61
|
+
exports.double = double;
|
|
62
|
+
function nonLiteral() {
|
|
63
|
+
return exports.DF.namedNode('http://example.org/');
|
|
64
|
+
}
|
|
65
|
+
exports.nonLiteral = nonLiteral;
|
|
66
|
+
function getMockEEActionContext(actionContext) {
|
|
67
|
+
return new core_1.ActionContext({
|
|
68
|
+
[context_entries_1.KeysInitQuery.queryTimestamp.name]: new Date(Date.now()),
|
|
69
|
+
[context_entries_1.KeysInitQuery.functionArgumentsCache.name]: {},
|
|
70
|
+
[context_entries_1.KeysExpressionEvaluator.superTypeProvider.name]: getMockSuperTypeProvider(),
|
|
71
|
+
[context_entries_1.KeysInitQuery.dataFactory.name]: exports.DF,
|
|
72
|
+
}).merge(actionContext ?? new core_1.ActionContext());
|
|
73
|
+
}
|
|
74
|
+
exports.getMockEEActionContext = getMockEEActionContext;
|
|
75
|
+
function getMockInternalEvaluator(factory, context) {
|
|
76
|
+
return new InternalEvaluator_1.InternalEvaluator(Eval.prepareEvaluatorActionContext(getMockEEActionContext(context)), getMockMediatorFunctionFactory(), {}, {});
|
|
77
|
+
}
|
|
78
|
+
exports.getMockInternalEvaluator = getMockInternalEvaluator;
|
|
79
|
+
function getMockEEFactory({ mediatorQueryOperation, mediatorFunctionFactory, mediatorMergeBindingsContext, } = {}) {
|
|
80
|
+
return new lib_1.ActorExpressionEvaluatorFactoryDefault({
|
|
81
|
+
bus: new core_1.Bus({ name: 'testBusMock' }),
|
|
82
|
+
name: 'mockEEFactory',
|
|
83
|
+
mediatorQueryOperation: mediatorQueryOperation ?? getMockMediatorQueryOperation(),
|
|
84
|
+
mediatorFunctionFactory: mediatorFunctionFactory ?? getMockMediatorFunctionFactory(),
|
|
85
|
+
mediatorMergeBindingsContext: mediatorMergeBindingsContext ?? getMockMediatorMergeBindingsContext(),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.getMockEEFactory = getMockEEFactory;
|
|
89
|
+
function getMockMediatorQueryOperation() {
|
|
90
|
+
return {
|
|
91
|
+
async mediate(_) {
|
|
92
|
+
throw new Error('mediatorQueryOperation mock not implemented');
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
exports.getMockMediatorQueryOperation = getMockMediatorQueryOperation;
|
|
97
|
+
function getMockMediatorMergeBindingsContext() {
|
|
98
|
+
return {
|
|
99
|
+
async mediate(_) {
|
|
100
|
+
return exports.BF;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
exports.getMockMediatorMergeBindingsContext = getMockMediatorMergeBindingsContext;
|
|
105
|
+
function getMockMediatorExpressionEvaluatorFactory(args = {}) {
|
|
106
|
+
return {
|
|
107
|
+
async mediate(arg) {
|
|
108
|
+
// eslint-disable-next-line unicorn/no-useless-undefined
|
|
109
|
+
return getMockEEFactory(args).run(arg, undefined);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
exports.getMockMediatorExpressionEvaluatorFactory = getMockMediatorExpressionEvaluatorFactory;
|
|
114
|
+
function getMockMediatorFunctionFactory() {
|
|
115
|
+
return {
|
|
116
|
+
async mediate(_) {
|
|
117
|
+
throw new Error('mediatorFunctionFactory mock not implemented');
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
exports.getMockMediatorFunctionFactory = getMockMediatorFunctionFactory;
|
|
122
|
+
function getMockSuperTypeProvider() {
|
|
123
|
+
return {
|
|
124
|
+
cache: new lru_cache_1.LRUCache({ max: 1_000 }),
|
|
125
|
+
discoverer: _ => 'term',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
exports.getMockSuperTypeProvider = getMockSuperTypeProvider;
|
|
129
|
+
//# sourceMappingURL=expressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressions.js","sourceRoot":"","sources":["expressions.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n ActorExpressionEvaluatorFactoryDefault,\n} from '@comunica/actor-expression-evaluator-factory-default/lib';\nimport { InternalEvaluator } from '@comunica/actor-expression-evaluator-factory-default/lib/InternalEvaluator';\nimport type {\n ActorExpressionEvaluatorFactory,\n IActorExpressionEvaluatorFactoryArgs,\n MediatorExpressionEvaluatorFactory,\n} from '@comunica/bus-expression-evaluator-factory';\nimport type { MediatorFunctionFactory } from '@comunica/bus-function-factory';\nimport type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';\nimport type { MediatorQueryOperation } from '@comunica/bus-query-operation';\nimport { KeysExpressionEvaluator, KeysInitQuery } from '@comunica/context-entries';\nimport { ActionContext, Bus } from '@comunica/core';\nimport * as Eval from '@comunica/expression-evaluator';\nimport type { GeneralSuperTypeDict, IActionContext, ISuperTypeProvider } from '@comunica/types';\nimport { BindingsFactory } from '@comunica/utils-bindings-factory';\nimport type * as RDF from '@rdfjs/types';\nimport { LRUCache } from 'lru-cache';\nimport { DataFactory } from 'rdf-data-factory';\nimport { Algebra } from 'sparqlalgebrajs';\nimport { Wildcard } from 'sparqljs';\n\nexport const DF = new DataFactory();\n\nexport const BF = new BindingsFactory(DF);\n\nexport function makeAggregate(aggregator: string, distinct = false, separator?: string, wildcard = false):\nAlgebra.AggregateExpression {\n const inner: Algebra.Expression = wildcard ?\n {\n type: Algebra.types.EXPRESSION,\n expressionType: Algebra.expressionTypes.WILDCARD,\n wildcard: new Wildcard(),\n } :\n {\n type: Algebra.types.EXPRESSION,\n expressionType: Algebra.expressionTypes.TERM,\n term: DF.variable('x'),\n };\n return {\n type: Algebra.types.EXPRESSION,\n expressionType: Algebra.expressionTypes.AGGREGATE,\n aggregator: <any>aggregator,\n distinct,\n separator,\n expression: inner,\n };\n}\n\nexport function int(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#integer'));\n}\n\nexport function float(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#float'));\n}\n\nexport function decimal(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#decimal'));\n}\n\nexport function date(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#date'));\n}\n\nexport function string(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#string'));\n}\n\nexport function double(value: string): RDF.Term {\n return DF.literal(value, DF.namedNode('http://www.w3.org/2001/XMLSchema#double'));\n}\n\nexport function nonLiteral(): RDF.Term {\n return DF.namedNode('http://example.org/');\n}\n\nexport function getMockEEActionContext(actionContext?: IActionContext): IActionContext {\n return new ActionContext({\n [KeysInitQuery.queryTimestamp.name]: new Date(Date.now()),\n [KeysInitQuery.functionArgumentsCache.name]: {},\n [KeysExpressionEvaluator.superTypeProvider.name]: getMockSuperTypeProvider(),\n [KeysInitQuery.dataFactory.name]: DF,\n }).merge(actionContext ?? new ActionContext());\n}\n\nexport function getMockInternalEvaluator(factory?: ActorExpressionEvaluatorFactory, context?: IActionContext):\nInternalEvaluator {\n return new InternalEvaluator(\n Eval.prepareEvaluatorActionContext(getMockEEActionContext(context)),\n getMockMediatorFunctionFactory(),\n <any> {},\n <any> {},\n );\n}\n\nexport function getMockEEFactory({\n mediatorQueryOperation,\n mediatorFunctionFactory,\n mediatorMergeBindingsContext,\n}: Partial<IActorExpressionEvaluatorFactoryArgs> = {}): ActorExpressionEvaluatorFactory {\n return new ActorExpressionEvaluatorFactoryDefault({\n bus: new Bus({ name: 'testBusMock' }),\n name: 'mockEEFactory',\n mediatorQueryOperation: mediatorQueryOperation ?? getMockMediatorQueryOperation(),\n mediatorFunctionFactory: mediatorFunctionFactory ?? getMockMediatorFunctionFactory(),\n mediatorMergeBindingsContext: mediatorMergeBindingsContext ?? getMockMediatorMergeBindingsContext(),\n });\n}\n\nexport function getMockMediatorQueryOperation(): MediatorQueryOperation {\n return <any>{\n async mediate(_: any) {\n throw new Error('mediatorQueryOperation mock not implemented');\n },\n };\n}\n\nexport function getMockMediatorMergeBindingsContext(): MediatorMergeBindingsContext {\n return <any>{\n async mediate(_: any) {\n return BF;\n },\n };\n}\n\nexport function getMockMediatorExpressionEvaluatorFactory(\n args: Partial<IActorExpressionEvaluatorFactoryArgs> = {},\n): MediatorExpressionEvaluatorFactory {\n return <any>{\n async mediate(arg: any) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n return getMockEEFactory(args).run(arg, undefined);\n },\n };\n}\n\nexport function getMockMediatorFunctionFactory(): MediatorFunctionFactory {\n return <any>{\n async mediate(_: any) {\n throw new Error('mediatorFunctionFactory mock not implemented');\n },\n };\n}\n\nexport function getMockSuperTypeProvider(): ISuperTypeProvider {\n return {\n cache: new LRUCache<string, GeneralSuperTypeDict>({ max: 1_000 }),\n discoverer: _ => 'term',\n };\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as RDF from '@rdfjs/types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace jest {
|
|
4
|
+
interface Matchers<R> {
|
|
5
|
+
toEqualBindings: (actual: RDF.Bindings) => R;
|
|
6
|
+
toEqualBindingsArray: (actual: RDF.Bindings[]) => R;
|
|
7
|
+
toEqualBindingsStream: (actual: RDF.Bindings[]) => Promise<R>;
|
|
8
|
+
toPassTest: (actual: any) => R;
|
|
9
|
+
toPassTestVoid: () => R;
|
|
10
|
+
toFailTest: (actual: string) => R;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AACA,yCAAkC;AAgB3B,UAAW,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC","sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport matchers from './matchers';\n\ndeclare global {\n // eslint-disable-next-line ts/no-namespace\n namespace jest {\n interface Matchers<R> {\n toEqualBindings: (actual: RDF.Bindings) => R;\n toEqualBindingsArray: (actual: RDF.Bindings[]) => R;\n toEqualBindingsStream: (actual: RDF.Bindings[]) => Promise<R>;\n toPassTest: (actual: any) => R;\n toPassTestVoid: () => R;\n toFailTest: (actual: string) => R;\n }\n }\n}\n\n(<any> globalThis).expect.extend(matchers);\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const toEqualBindings_1 = require("./toEqualBindings");
|
|
4
|
+
const toEqualBindingsArray_1 = require("./toEqualBindingsArray");
|
|
5
|
+
const toEqualBindingsStream_1 = require("./toEqualBindingsStream");
|
|
6
|
+
const toFailTest_1 = require("./toFailTest");
|
|
7
|
+
const toPassTest_1 = require("./toPassTest");
|
|
8
|
+
const toPassTestVoid_1 = require("./toPassTestVoid");
|
|
9
|
+
exports.default = [
|
|
10
|
+
toEqualBindings_1.default,
|
|
11
|
+
toEqualBindingsArray_1.default,
|
|
12
|
+
toEqualBindingsStream_1.default,
|
|
13
|
+
toPassTest_1.default,
|
|
14
|
+
toPassTestVoid_1.default,
|
|
15
|
+
toFailTest_1.default,
|
|
16
|
+
].reduce((acc, matcher) => ({ ...acc, ...matcher }), {});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,uDAAgD;AAChD,iEAA0D;AAC1D,mEAA4D;AAC5D,6CAAsC;AACtC,6CAAsC;AACtC,qDAA8C;AAE9C,kBAAe;IACb,yBAAe;IACf,8BAAoB;IACpB,+BAAqB;IACrB,oBAAU;IACV,wBAAc;IACd,oBAAU;CACX,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import toEqualBindings from './toEqualBindings';\nimport toEqualBindingsArray from './toEqualBindingsArray';\nimport toEqualBindingsStream from './toEqualBindingsStream';\nimport toFailTest from './toFailTest';\nimport toPassTest from './toPassTest';\nimport toPassTestVoid from './toPassTestVoid';\n\nexport default [\n toEqualBindings,\n toEqualBindingsArray,\n toEqualBindingsStream,\n toPassTest,\n toPassTestVoid,\n toFailTest,\n].reduce((acc, matcher) => ({ ...acc, ...matcher }), {});\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
4
|
+
function fail(received, actual) {
|
|
5
|
+
return {
|
|
6
|
+
message: () => `expected ${(0, utils_bindings_factory_1.bindingsToString)(received)} and ${(0, utils_bindings_factory_1.bindingsToString)(actual)} to be equal`,
|
|
7
|
+
pass: false,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function succeed(received, actual) {
|
|
11
|
+
return {
|
|
12
|
+
message: () => `expected ${(0, utils_bindings_factory_1.bindingsToString)(received)} and ${(0, utils_bindings_factory_1.bindingsToString)(actual)} not to be equal`,
|
|
13
|
+
pass: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.default = {
|
|
17
|
+
toEqualBindings(received, actual) {
|
|
18
|
+
if (!received.equals(actual)) {
|
|
19
|
+
return fail(received, actual);
|
|
20
|
+
}
|
|
21
|
+
return succeed(received, actual);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=toEqualBindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEqualBindings.js","sourceRoot":"","sources":["toEqualBindings.ts"],"names":[],"mappings":";;AAAA,6EAAoE;AAGpE,SAAS,IAAI,CAAC,QAAsB,EAAE,MAAoB;IACxD,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,IAAA,yCAAgB,EAAC,QAAQ,CAAC,QAAQ,IAAA,yCAAgB,EAAC,MAAM,CAAC,cAAc;QACnG,IAAI,EAAE,KAAK;KACZ,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,QAAsB,EAAE,MAAoB;IAC3D,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,IAAA,yCAAgB,EAAC,QAAQ,CAAC,QAAQ,IAAA,yCAAgB,EAAC,MAAM,CAAC,kBAAkB;QACvG,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC;AAED,kBAAe;IACb,eAAe,CAAC,QAAsB,EAAE,MAAoB;QAC1D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;CACF,CAAC","sourcesContent":["import { bindingsToString } from '@comunica/utils-bindings-factory';\nimport type * as RDF from '@rdfjs/types';\n\nfunction fail(received: RDF.Bindings, actual: RDF.Bindings): any {\n return {\n message: () => `expected ${bindingsToString(received)} and ${bindingsToString(actual)} to be equal`,\n pass: false,\n };\n}\n\nfunction succeed(received: RDF.Bindings, actual: RDF.Bindings): any {\n return {\n message: () => `expected ${bindingsToString(received)} and ${bindingsToString(actual)} not to be equal`,\n pass: true,\n };\n}\n\nexport default {\n toEqualBindings(received: RDF.Bindings, actual: RDF.Bindings) {\n if (!received.equals(actual)) {\n return fail(received, actual);\n }\n\n return succeed(received, actual);\n },\n};\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
4
|
+
const toEqualBindings_1 = require("./toEqualBindings");
|
|
5
|
+
function bindingsArrayToString(bindings) {
|
|
6
|
+
return `[ ${bindings.map(term => (0, utils_bindings_factory_1.bindingsToString)(term)).join(', ')} ]`;
|
|
7
|
+
}
|
|
8
|
+
exports.default = {
|
|
9
|
+
toEqualBindingsArray(received, actual) {
|
|
10
|
+
if (received.length !== actual.length) {
|
|
11
|
+
return {
|
|
12
|
+
message: () => `expected ${bindingsArrayToString(received)} to equal ${bindingsArrayToString(actual)}`,
|
|
13
|
+
pass: false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
for (const [i, element] of received.entries()) {
|
|
17
|
+
const sub = toEqualBindings_1.default.toEqualBindings(element, actual[i]);
|
|
18
|
+
if (!sub.pass) {
|
|
19
|
+
return {
|
|
20
|
+
message: () => `expected ${bindingsArrayToString(received)} to equal ${bindingsArrayToString(actual)}\nIndex ${i} is different.`,
|
|
21
|
+
pass: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
message: () => `expected ${bindingsArrayToString(received)} not to equal ${bindingsArrayToString(actual)}`,
|
|
27
|
+
pass: true,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=toEqualBindingsArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEqualBindingsArray.js","sourceRoot":"","sources":["toEqualBindingsArray.ts"],"names":[],"mappings":";;AAAA,6EAAoE;AAEpE,uDAAgD;AAEhD,SAAS,qBAAqB,CAAC,QAAwB;IACrD,OAAO,KAAK,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,yCAAgB,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1E,CAAC;AAED,kBAAe;IACb,oBAAoB,CAAC,QAAwB,EAAE,MAAsB;QACnE,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;YACtC,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,qBAAqB,CAAC,QAAQ,CAAC,aAAa,qBAAqB,CAAC,MAAM,CAAC,EAAE;gBACtG,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,CAAE,CAAC,EAAE,OAAO,CAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,yBAAe,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;gBACd,OAAO;oBACL,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,qBAAqB,CAAC,QAAQ,CAAC,aAAa,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB;oBAChI,IAAI,EAAE,KAAK;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,qBAAqB,CAAC,QAAQ,CAAC,iBAAiB,qBAAqB,CAAC,MAAM,CAAC,EAAE;YAC1G,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { bindingsToString } from '@comunica/utils-bindings-factory';\nimport type * as RDF from '@rdfjs/types';\nimport toEqualBindings from './toEqualBindings';\n\nfunction bindingsArrayToString(bindings: RDF.Bindings[]): string {\n return `[ ${bindings.map(term => bindingsToString(term)).join(', ')} ]`;\n}\n\nexport default {\n toEqualBindingsArray(received: RDF.Bindings[], actual: RDF.Bindings[]) {\n if (received.length !== actual.length) {\n return {\n message: () => `expected ${bindingsArrayToString(received)} to equal ${bindingsArrayToString(actual)}`,\n pass: false,\n };\n }\n\n for (const [ i, element ] of received.entries()) {\n const sub = toEqualBindings.toEqualBindings(element, actual[i]);\n if (!sub.pass) {\n return {\n message: () => `expected ${bindingsArrayToString(received)} to equal ${bindingsArrayToString(actual)}\\nIndex ${i} is different.`,\n pass: false,\n };\n }\n }\n\n return {\n message: () => `expected ${bindingsArrayToString(received)} not to equal ${bindingsArrayToString(actual)}`,\n pass: true,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BindingsStream } from '@comunica/types';
|
|
2
|
+
import type * as RDF from '@rdfjs/types';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
toEqualBindingsStream(received: BindingsStream, actual: RDF.Bindings[]): Promise<{
|
|
5
|
+
message: () => string;
|
|
6
|
+
pass: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const arrayify_stream_1 = require("arrayify-stream");
|
|
4
|
+
const toEqualBindingsArray_1 = require("./toEqualBindingsArray");
|
|
5
|
+
exports.default = {
|
|
6
|
+
async toEqualBindingsStream(received, actual) {
|
|
7
|
+
return toEqualBindingsArray_1.default.toEqualBindingsArray(await (0, arrayify_stream_1.default)(received), actual);
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=toEqualBindingsStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEqualBindingsStream.js","sourceRoot":"","sources":["toEqualBindingsStream.ts"],"names":[],"mappings":";;AAEA,qDAA6C;AAC7C,iEAA0D;AAE1D,kBAAe;IACb,KAAK,CAAC,qBAAqB,CAAC,QAAwB,EAAE,MAAsB;QAC1E,OAAO,8BAAoB,CAAC,oBAAoB,CAAC,MAAM,IAAA,yBAAc,EAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;CACF,CAAC","sourcesContent":["import type { BindingsStream } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport arrayifyStream from 'arrayify-stream';\nimport toEqualBindingsArray from './toEqualBindingsArray';\n\nexport default {\n async toEqualBindingsStream(received: BindingsStream, actual: RDF.Bindings[]) {\n return toEqualBindingsArray.toEqualBindingsArray(await arrayifyStream(received), actual);\n },\n};\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires
|
|
4
|
+
const inspect = require('object-inspect');
|
|
5
|
+
exports.default = {
|
|
6
|
+
toFailTest(received, actual) {
|
|
7
|
+
if (!received.isFailed()) {
|
|
8
|
+
return {
|
|
9
|
+
message: () => `expected a passed test result "${inspect(received.get())}" to fail to message "${actual}"`,
|
|
10
|
+
pass: false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (!received.getFailMessage().includes(actual)) {
|
|
14
|
+
return {
|
|
15
|
+
message: () => `expected a failed test result "${received.getFailMessage()}" to fail to message "${actual}"`,
|
|
16
|
+
pass: false,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
message: () => `expected failed test result "${received.getFailMessage()}" not to fail`,
|
|
21
|
+
pass: true,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=toFailTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toFailTest.js","sourceRoot":"","sources":["toFailTest.ts"],"names":[],"mappings":";;AAEA,oEAAoE;AACpE,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE1C,kBAAe;IACb,UAAU,CAAC,QAAyB,EAAE,MAAc;QAClD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,yBAAyB,MAAM,GAAG;gBAC1G,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC,QAAQ,CAAC,cAAc,EAAE,yBAAyB,MAAM,GAAG;gBAC5G,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CAAC,gCAAgC,QAAQ,CAAC,cAAc,EAAE,eAAe;YACvF,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { TestResult } from '@comunica/core';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires\nconst inspect = require('object-inspect');\n\nexport default {\n toFailTest(received: TestResult<any>, actual: string) {\n if (!received.isFailed()) {\n return {\n message: () => `expected a passed test result \"${inspect(received.get())}\" to fail to message \"${actual}\"`,\n pass: false,\n };\n }\n\n if (!received.getFailMessage().includes(actual)) {\n return {\n message: () => `expected a failed test result \"${received.getFailMessage()}\" to fail to message \"${actual}\"`,\n pass: false,\n };\n }\n\n return {\n message: () => `expected failed test result \"${received.getFailMessage()}\" not to fail`,\n pass: true,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const expect_utils_1 = require("@jest/expect-utils");
|
|
4
|
+
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires
|
|
5
|
+
const inspect = require('object-inspect');
|
|
6
|
+
exports.default = {
|
|
7
|
+
toPassTest(received, actual) {
|
|
8
|
+
if (!received.isPassed()) {
|
|
9
|
+
return {
|
|
10
|
+
message: () => `expected a failed test result "${received.getFailMessage()}" to pass to value "${inspect(actual)}"`,
|
|
11
|
+
pass: false,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (!(0, expect_utils_1.equals)(received.get(), actual)) {
|
|
15
|
+
return {
|
|
16
|
+
message: () => `expected a passed test result "${inspect(received.get())}" to pass to value "${inspect(actual)}"`,
|
|
17
|
+
pass: false,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
message: () => `expected passed test result "${inspect(received.get())}" not to pass`,
|
|
22
|
+
pass: true,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=toPassTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toPassTest.js","sourceRoot":"","sources":["toPassTest.ts"],"names":[],"mappings":";;AACA,qDAA4C;AAE5C,oEAAoE;AACpE,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE1C,kBAAe;IACb,UAAU,CAAC,QAAyB,EAAE,MAAW;QAC/C,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC,QAAQ,CAAC,cAAc,EAAE,uBAAuB,OAAO,CAAC,MAAM,CAAC,GAAG;gBACnH,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAA,qBAAM,EAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,uBAAuB,OAAO,CAAC,MAAM,CAAC,GAAG;gBACjH,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CAAC,gCAAgC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,eAAe;YACrF,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { TestResult } from '@comunica/core';\nimport { equals } from '@jest/expect-utils';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires\nconst inspect = require('object-inspect');\n\nexport default {\n toPassTest(received: TestResult<any>, actual: any) {\n if (!received.isPassed()) {\n return {\n message: () => `expected a failed test result \"${received.getFailMessage()}\" to pass to value \"${inspect(actual)}\"`,\n pass: false,\n };\n }\n\n if (!equals(received.get(), actual)) {\n return {\n message: () => `expected a passed test result \"${inspect(received.get())}\" to pass to value \"${inspect(actual)}\"`,\n pass: false,\n };\n }\n\n return {\n message: () => `expected passed test result \"${inspect(received.get())}\" not to pass`,\n pass: true,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires
|
|
4
|
+
const inspect = require('object-inspect');
|
|
5
|
+
exports.default = {
|
|
6
|
+
toPassTestVoid(received) {
|
|
7
|
+
if (!received.isPassed()) {
|
|
8
|
+
return {
|
|
9
|
+
message: () => `expected a failed test result "${received.getFailMessage()}" to pass to a void value`,
|
|
10
|
+
pass: false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (received.get() !== true) {
|
|
14
|
+
return {
|
|
15
|
+
message: () => `expected passed test result "${inspect(received.get())}" to be a void value`,
|
|
16
|
+
pass: false,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
message: () => `expected passed void test result not to be a void value`,
|
|
21
|
+
pass: true,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=toPassTestVoid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toPassTestVoid.js","sourceRoot":"","sources":["toPassTestVoid.ts"],"names":[],"mappings":";;AAEA,oEAAoE;AACpE,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE1C,kBAAe;IACb,cAAc,CAAC,QAAyB;QACtC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAkC,QAAQ,CAAC,cAAc,EAAE,2BAA2B;gBACrG,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC;YAC5B,OAAO;gBACL,OAAO,EAAE,GAAG,EAAE,CAAC,gCAAgC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,sBAAsB;gBAC5F,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CAAC,yDAAyD;YACxE,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { TestResult } from '@comunica/core';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires\nconst inspect = require('object-inspect');\n\nexport default {\n toPassTestVoid(received: TestResult<any>) {\n if (!received.isPassed()) {\n return {\n message: () => `expected a failed test result \"${received.getFailMessage()}\" to pass to a void value`,\n pass: false,\n };\n }\n if (received.get() !== true) {\n return {\n message: () => `expected passed test result \"${inspect(received.get())}\" to be a void value`,\n pass: false,\n };\n }\n return {\n message: () => `expected passed void test result not to be a void value`,\n pass: true,\n };\n },\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/utils-jest",
|
|
3
|
+
"version": "3.2.4-alpha.47.0",
|
|
4
|
+
"description": "Jest utilities for Comunica",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"funding": {
|
|
7
|
+
"type": "opencollective",
|
|
8
|
+
"url": "https://opencollective.com/comunica-association"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://comunica.dev/",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/comunica/comunica.git",
|
|
14
|
+
"directory": "packages/utils-jest"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/comunica/comunica/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"jest",
|
|
21
|
+
"rdf",
|
|
22
|
+
"comunica",
|
|
23
|
+
"testing",
|
|
24
|
+
"testing",
|
|
25
|
+
"matchers",
|
|
26
|
+
"extend"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"main": "lib/index.js",
|
|
30
|
+
"typings": "lib/index",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib/**/*.d.ts",
|
|
36
|
+
"lib/**/*.js",
|
|
37
|
+
"lib/**/*.js.map"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "yarn run build:ts",
|
|
41
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\""
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@comunica/core": "3.2.4-alpha.47.0",
|
|
45
|
+
"@comunica/types": "3.2.4-alpha.47.0",
|
|
46
|
+
"@comunica/utils-bindings-factory": "3.2.4-alpha.47.0",
|
|
47
|
+
"@jest/expect-utils": "^29.7.0",
|
|
48
|
+
"@rdfjs/types": "*",
|
|
49
|
+
"@types/object-inspect": "^1.13.0",
|
|
50
|
+
"arrayify-stream": "^2.0.1",
|
|
51
|
+
"object-inspect": "^1.13.2"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
|
|
54
|
+
}
|