@opra/testing 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertFilter = exports.ApiExpectCollection = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const rule_judgment_1 = tslib_1.__importDefault(require("rule-judgment"));
6
5
  const type_is_1 = tslib_1.__importDefault(require("@browsery/type-is"));
7
6
  const common_1 = require("@opra/common");
7
+ const rule_judgment_1 = tslib_1.__importDefault(require("rule-judgment"));
8
8
  const api_expect_base_js_1 = require("./api-expect-base.js");
9
9
  // @ts-ignore
10
10
  const ruleJudgment = typeof rule_judgment_1.default === 'object' ? rule_judgment_1.default.default : rule_judgment_1.default;
@@ -9,8 +9,9 @@ class ApiExpectError extends api_expect_base_js_1.ApiExpectBase {
9
9
  try {
10
10
  if (typeof expected === 'string')
11
11
  expected = { message: expected };
12
- else if (expected instanceof RegExp)
12
+ else if (expected instanceof RegExp) {
13
13
  expected = { message: expect.stringMatching(expected) };
14
+ }
14
15
  else
15
16
  expected = (0, common_1.omitNullish)(expected);
16
17
  this._expect(this.response.body.errors).toEqual(expect.arrayContaining([expect.objectContaining(expected)]));
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiExpect = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  require("../jest-extend/index.js");
6
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
7
6
  const common_1 = require("@opra/common");
7
+ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
8
8
  const api_expect_base_js_1 = require("./api-expect-base.js");
9
9
  const api_expect_collection_js_1 = require("./api-expect-collection.js");
10
10
  const api_expect_error_js_1 = require("./api-expect-error.js");
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestBackend = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const http_1 = require("http");
6
5
  const path = tslib_1.__importStar(require("node:path"));
7
6
  const client_1 = require("@opra/client");
7
+ const http_1 = require("http");
8
8
  const api_expect_js_1 = require("./api-expect/api-expect.js");
9
9
  /**
10
10
  *
@@ -23,12 +23,13 @@ function _objectMatches(received, expected, path) {
23
23
  else if (ev && typeof ev === 'object') {
24
24
  _objectMatches(rv, ev, path ? path + '.' + k : k);
25
25
  }
26
- else
26
+ else {
27
27
  try {
28
28
  expect(rv).toEqual(ev);
29
29
  }
30
30
  catch {
31
31
  throw new Error(`Property "${k}" does not match`);
32
32
  }
33
+ }
33
34
  }
34
35
  }
@@ -1,6 +1,6 @@
1
- import ruleJudgmentLib from 'rule-judgment';
2
1
  import typeIs from '@browsery/type-is';
3
2
  import { MimeTypes, omitNullish, OpraFilter } from '@opra/common';
3
+ import ruleJudgmentLib from 'rule-judgment';
4
4
  import { ApiExpectBase } from './api-expect-base.js';
5
5
  // @ts-ignore
6
6
  const ruleJudgment = typeof ruleJudgmentLib === 'object' ? ruleJudgmentLib.default : ruleJudgmentLib;
@@ -6,8 +6,9 @@ export class ApiExpectError extends ApiExpectBase {
6
6
  try {
7
7
  if (typeof expected === 'string')
8
8
  expected = { message: expected };
9
- else if (expected instanceof RegExp)
9
+ else if (expected instanceof RegExp) {
10
10
  expected = { message: expect.stringMatching(expected) };
11
+ }
11
12
  else
12
13
  expected = omitNullish(expected);
13
14
  this._expect(this.response.body.errors).toEqual(expect.arrayContaining([expect.objectContaining(expected)]));
@@ -1,6 +1,6 @@
1
1
  import '../jest-extend/index.js';
2
- import colors from 'ansi-colors';
3
2
  import { MimeTypes } from '@opra/common';
3
+ import colors from 'ansi-colors';
4
4
  import { ApiExpectBase } from './api-expect-base.js';
5
5
  import { ApiExpectCollection } from './api-expect-collection.js';
6
6
  import { ApiExpectError } from './api-expect-error.js';
@@ -1,6 +1,6 @@
1
- import { createServer, Server } from 'http';
2
1
  import * as path from 'node:path';
3
2
  import { FetchBackend, HttpResponse } from '@opra/client';
3
+ import { createServer, Server } from 'http';
4
4
  import { ApiExpect } from './api-expect/api-expect.js';
5
5
  /**
6
6
  *
@@ -19,12 +19,13 @@ function _objectMatches(received, expected, path) {
19
19
  else if (ev && typeof ev === 'object') {
20
20
  _objectMatches(rv, ev, path ? path + '.' + k : k);
21
21
  }
22
- else
22
+ else {
23
23
  try {
24
24
  expect(rv).toEqual(ev);
25
25
  }
26
26
  catch {
27
27
  throw new Error(`Property "${k}" does not match`);
28
28
  }
29
+ }
29
30
  }
30
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/testing",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.9",
4
4
  "description": "Opra testing package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@
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 . --max-warnings=0",
20
+ "lint:fix": "eslint . --max-warnings=0 --fix",
20
21
  "format": "prettier . --write --log-level=warn",
21
22
  "test": "jest --passWithNoTests",
22
23
  "cover": "jest --passWithNoTests --collect-coverage",
@@ -27,9 +28,11 @@
27
28
  "clean:cover": "rimraf ../../coverage/testing"
28
29
  },
29
30
  "dependencies": {
30
- "@opra/client": "^1.0.0-alpha.7",
31
- "@opra/common": "^1.0.0-alpha.7",
31
+ "@browsery/type-is": "^1.6.18-r3",
32
+ "@opra/client": "^1.0.0-alpha.9",
33
+ "@opra/common": "^1.0.0-alpha.9",
32
34
  "ansi-colors": "^4.1.3",
35
+ "jest-matcher-utils": "^29.7.0",
33
36
  "rule-judgment": "^1.1.5"
34
37
  },
35
38
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage, Server, ServerResponse } from 'http';
3
2
  import { FetchBackend, HttpResponse } from '@opra/client';
3
+ import { IncomingMessage, Server, ServerResponse } from 'http';
4
4
  import { ApiExpect } from './api-expect/api-expect.js';
5
5
  import type { OpraTestClient } from './test-client.js';
6
6
  declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage, Server, ServerResponse } from 'http';
3
2
  import { FetchBackend, HttpClientBase, kBackend } from '@opra/client';
3
+ import { IncomingMessage, Server, ServerResponse } from 'http';
4
4
  import { ApiExpect } from './api-expect/api-expect.js';
5
5
  import { TestBackend } from './test-backend.js';
6
6
  declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;