@opra/testing 0.13.0 → 0.15.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/cjs/api-expect/api-expect-collection.js +1 -0
- package/cjs/api-expect/api-expect-error.js +1 -0
- package/cjs/api-expect/api-expect-object.js +1 -0
- package/cjs/api-expect/api-expect-operation-result.js +1 -0
- package/cjs/api-expect/api-expect.js +1 -0
- package/cjs/index.js +1 -1
- package/cjs/jest-extend/index.js +4 -0
- package/cjs/test-client.js +7 -1
- package/esm/api-expect/api-expect-collection.d.ts +3 -1
- package/esm/api-expect/api-expect-collection.js +1 -0
- package/esm/api-expect/api-expect-error.d.ts +2 -1
- package/esm/api-expect/api-expect-error.js +1 -0
- package/esm/api-expect/api-expect-object.d.ts +2 -1
- package/esm/api-expect/api-expect-object.js +1 -0
- package/esm/api-expect/api-expect-operation-result.d.ts +2 -1
- package/esm/api-expect/api-expect-operation-result.js +1 -0
- package/esm/api-expect/api-expect.d.ts +2 -1
- package/esm/api-expect/api-expect.js +1 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/jest-extend/index.d.ts +1 -0
- package/esm/jest-extend/index.js +1 -0
- package/esm/test-client.d.ts +6 -4
- package/esm/test-client.js +8 -2
- package/package.json +5 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertFilter = exports.ApiExpectCollection = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
require("../jest-extend/index.js");
|
|
5
6
|
const lodash_isnil_1 = tslib_1.__importDefault(require("lodash.isnil"));
|
|
6
7
|
const lodash_omitby_1 = tslib_1.__importDefault(require("lodash.omitby"));
|
|
7
8
|
const rule_judgment_1 = tslib_1.__importDefault(require("rule-judgment"));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiExpectError = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
require("../jest-extend/index.js");
|
|
5
6
|
const jest_matcher_utils_1 = tslib_1.__importDefault(require("jest-matcher-utils"));
|
|
6
7
|
const object_matches_util_js_1 = require("../utils/object-matches.util.js");
|
|
7
8
|
const api_expect_object_js_1 = require("./api-expect-object.js");
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiExpectObject = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
require("../jest-extend/index.js");
|
|
5
6
|
const lodash_isnil_1 = tslib_1.__importDefault(require("lodash.isnil"));
|
|
6
7
|
const lodash_omitby_1 = tslib_1.__importDefault(require("lodash.omitby"));
|
|
7
8
|
class ApiExpectObject {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiExpect = void 0;
|
|
4
|
+
require("../jest-extend/index.js");
|
|
4
5
|
const api_expect_collection_js_1 = require("./api-expect-collection.js");
|
|
5
6
|
const api_expect_error_js_1 = require("./api-expect-error.js");
|
|
6
7
|
const api_expect_object_js_1 = require("./api-expect-object.js");
|
package/cjs/index.js
CHANGED
package/cjs/test-client.js
CHANGED
|
@@ -7,11 +7,17 @@ const common_1 = require("@opra/common");
|
|
|
7
7
|
const node_client_1 = require("@opra/node-client");
|
|
8
8
|
const api_expect_js_1 = require("./api-expect/api-expect.js");
|
|
9
9
|
const is_absolute_url_util_js_1 = require("./utils/is-absolute-url.util.js");
|
|
10
|
-
class OpraTestClient extends node_client_1.
|
|
10
|
+
class OpraTestClient extends node_client_1.OpraHttpClient {
|
|
11
11
|
constructor(app, options) {
|
|
12
12
|
super('/', options);
|
|
13
13
|
this._server = app instanceof http_1.Server ? app : (0, http_1.createServer)(app);
|
|
14
14
|
}
|
|
15
|
+
collection(resourceName) {
|
|
16
|
+
return super.collection(resourceName);
|
|
17
|
+
}
|
|
18
|
+
singleton(resourceName) {
|
|
19
|
+
return super.singleton(resourceName);
|
|
20
|
+
}
|
|
15
21
|
async _fetch(urlString, req = {}) {
|
|
16
22
|
return new Promise((resolve, reject) => {
|
|
17
23
|
urlString = (0, is_absolute_url_util_js_1.isAbsoluteUrl)(urlString) ? urlString : (0, common_1.joinPath)('http://opra.test', urlString);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../jest-extend/index.js';
|
|
2
|
+
import { Expression } from '@opra/common';
|
|
3
|
+
import { HttpResponse } from '@opra/node-client';
|
|
2
4
|
export declare class ApiExpectCollection {
|
|
3
5
|
readonly response: HttpResponse;
|
|
4
6
|
protected _isNot: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../jest-extend/index.js';
|
|
2
|
+
import { HttpResponse } from '@opra/node-client';
|
|
2
3
|
import { ApiExpectObject } from './api-expect-object.js';
|
|
3
4
|
export declare class ApiExpectError extends ApiExpectObject {
|
|
4
5
|
readonly response: HttpResponse;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../jest-extend/index.js';
|
|
2
|
+
import { HttpResponse } from '@opra/node-client';
|
|
2
3
|
import { ApiExpectCollection } from './api-expect-collection.js';
|
|
3
4
|
import { ApiExpectError } from './api-expect-error.js';
|
|
4
5
|
import { ApiExpectObject } from './api-expect-object.js';
|
package/esm/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './jest-extend/
|
|
1
|
+
import './jest-extend/index.js';
|
|
2
2
|
export * from './test-client.js';
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './jest-extend/
|
|
1
|
+
import './jest-extend/index.js';
|
|
2
2
|
export * from './test-client.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common.extend.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common.extend.js';
|
package/esm/test-client.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Type } from 'ts-gems';
|
|
4
|
+
import { HttpCollectionNode, HttpResponse, HttpSingletonNode, OpraHttpClient, OpraHttpClientOptions } from '@opra/node-client';
|
|
5
5
|
import { ApiExpect } from './api-expect/api-expect.js';
|
|
6
6
|
declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
7
7
|
export type ResponseExt = {
|
|
8
8
|
expect: ApiExpect;
|
|
9
9
|
};
|
|
10
|
-
export declare class OpraTestClient extends
|
|
10
|
+
export declare class OpraTestClient extends OpraHttpClient {
|
|
11
11
|
protected _server: Server;
|
|
12
12
|
constructor(app: Server | RequestListener, options?: OpraHttpClientOptions);
|
|
13
|
+
collection<TType = any>(resourceName: string | Type<TType>): HttpCollectionNode<TType, ResponseExt>;
|
|
14
|
+
singleton<TType = any>(resourceName: string | Type<TType>): HttpSingletonNode<TType, ResponseExt>;
|
|
13
15
|
protected _fetch(urlString: string, req?: RequestInit): Promise<Response>;
|
|
14
|
-
protected _createResponse(init?:
|
|
16
|
+
protected _createResponse(init?: HttpResponse.Initiator): HttpResponse;
|
|
15
17
|
}
|
|
16
18
|
export {};
|
package/esm/test-client.js
CHANGED
|
@@ -3,14 +3,20 @@ import { URL } from 'url';
|
|
|
3
3
|
import { joinPath } from '@opra/common';
|
|
4
4
|
import {
|
|
5
5
|
// BatchRequest,
|
|
6
|
-
|
|
6
|
+
OpraHttpClient, } from '@opra/node-client';
|
|
7
7
|
import { ApiExpect } from './api-expect/api-expect.js';
|
|
8
8
|
import { isAbsoluteUrl } from './utils/is-absolute-url.util.js';
|
|
9
|
-
export class OpraTestClient extends
|
|
9
|
+
export class OpraTestClient extends OpraHttpClient {
|
|
10
10
|
constructor(app, options) {
|
|
11
11
|
super('/', options);
|
|
12
12
|
this._server = app instanceof Server ? app : createServer(app);
|
|
13
13
|
}
|
|
14
|
+
collection(resourceName) {
|
|
15
|
+
return super.collection(resourceName);
|
|
16
|
+
}
|
|
17
|
+
singleton(resourceName) {
|
|
18
|
+
return super.singleton(resourceName);
|
|
19
|
+
}
|
|
14
20
|
async _fetch(urlString, req = {}) {
|
|
15
21
|
return new Promise((resolve, reject) => {
|
|
16
22
|
urlString = isAbsoluteUrl(urlString) ? urlString : joinPath('http://opra.test', urlString);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Opra testing package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
18
18
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/testing && cp ../../package.cjs.json ../../build/testing/cjs/package.json",
|
|
19
19
|
"lint": "eslint .",
|
|
20
|
-
"test": "
|
|
21
|
-
"cover": "
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"cover": "jest --collect-coverage",
|
|
22
22
|
"clean": "npm run clean:src && npm run clean:dist && npm run clean:cover",
|
|
23
23
|
"clean:src": "ts-cleanup -s src --all && ts-cleanup -s test --all",
|
|
24
24
|
"clean:dist": "rimraf ../../build/testing",
|
|
25
25
|
"clean:cover": "rimraf ../../coverage/testing"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opra/common": "^0.
|
|
29
|
-
"@opra/node-client": "^0.
|
|
28
|
+
"@opra/common": "^0.15.0",
|
|
29
|
+
"@opra/node-client": "^0.15.0",
|
|
30
30
|
"ansi-colors": "^4.1.3",
|
|
31
31
|
"lodash.isnil": "^4.0.0",
|
|
32
32
|
"lodash.omitby": "^4.6.0",
|