@opra/testing 0.17.0 → 0.17.2

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.
@@ -135,10 +135,10 @@ class ApiExpectCollection {
135
135
  }
136
136
  exports.ApiExpectCollection = ApiExpectCollection;
137
137
  function convertFilter(str) {
138
- const ast = typeof str === 'string' ? (0, common_1.parseFilter)(str) : str;
138
+ const ast = typeof str === 'string' ? common_1.OpraFilter.parse(str) : str;
139
139
  if (!ast)
140
140
  return;
141
- if (ast instanceof common_1.ComparisonExpression) {
141
+ if (ast instanceof common_1.OpraFilter.ComparisonExpression) {
142
142
  const left = convertFilter(ast.left);
143
143
  const right = convertFilter(ast.right);
144
144
  switch (ast.op) {
@@ -162,29 +162,29 @@ function convertFilter(str) {
162
162
  throw new Error(`ComparisonExpression operator (${ast.op}) not implemented yet`);
163
163
  }
164
164
  }
165
- if (ast instanceof common_1.QualifiedIdentifier) {
165
+ if (ast instanceof common_1.OpraFilter.QualifiedIdentifier) {
166
166
  return ast.value;
167
167
  }
168
- if (ast instanceof common_1.NumberLiteral ||
169
- ast instanceof common_1.StringLiteral ||
170
- ast instanceof common_1.BooleanLiteral ||
171
- ast instanceof common_1.NullLiteral ||
172
- ast instanceof common_1.DateLiteral ||
173
- ast instanceof common_1.TimeLiteral) {
168
+ if (ast instanceof common_1.OpraFilter.NumberLiteral ||
169
+ ast instanceof common_1.OpraFilter.StringLiteral ||
170
+ ast instanceof common_1.OpraFilter.BooleanLiteral ||
171
+ ast instanceof common_1.OpraFilter.NullLiteral ||
172
+ ast instanceof common_1.OpraFilter.DateLiteral ||
173
+ ast instanceof common_1.OpraFilter.TimeLiteral) {
174
174
  return ast.value;
175
175
  }
176
- if (ast instanceof common_1.ArrayExpression) {
176
+ if (ast instanceof common_1.OpraFilter.ArrayExpression) {
177
177
  return ast.items.map(convertFilter);
178
178
  }
179
- if (ast instanceof common_1.LogicalExpression) {
179
+ if (ast instanceof common_1.OpraFilter.LogicalExpression) {
180
180
  if (ast.op === 'or')
181
181
  return { $or: ast.items.map(convertFilter) };
182
182
  return { $and: ast.items.map(convertFilter) };
183
183
  }
184
- if (ast instanceof common_1.ArrayExpression) {
184
+ if (ast instanceof common_1.OpraFilter.ArrayExpression) {
185
185
  return ast.items.map(convertFilter);
186
186
  }
187
- if (ast instanceof common_1.ParenthesesExpression) {
187
+ if (ast instanceof common_1.OpraFilter.ParenthesizedExpression) {
188
188
  return convertFilter(ast.expression);
189
189
  }
190
190
  throw new Error(`${ast.kind} is not implemented yet`);
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpraTestClient = void 0;
4
4
  const http_1 = require("http");
5
5
  const url_1 = require("url");
6
+ const client_1 = require("@opra/client");
6
7
  const common_1 = require("@opra/common");
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.OpraHttpClient {
10
+ class OpraTestClient extends 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);
@@ -2,7 +2,7 @@ import '../jest-extend/index.js';
2
2
  import isNil from 'lodash.isnil';
3
3
  import omitBy from 'lodash.omitby';
4
4
  import ruleJudgmentLib from 'rule-judgment';
5
- import { ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, parseFilter, QualifiedIdentifier, StringLiteral, TimeLiteral } from '@opra/common';
5
+ import { OpraFilter } from '@opra/common';
6
6
  // @ts-ignore
7
7
  const ruleJudgment = typeof ruleJudgmentLib === 'object' ? ruleJudgmentLib.default : ruleJudgmentLib;
8
8
  export class ApiExpectCollection {
@@ -130,10 +130,10 @@ export class ApiExpectCollection {
130
130
  }
131
131
  }
132
132
  export function convertFilter(str) {
133
- const ast = typeof str === 'string' ? parseFilter(str) : str;
133
+ const ast = typeof str === 'string' ? OpraFilter.parse(str) : str;
134
134
  if (!ast)
135
135
  return;
136
- if (ast instanceof ComparisonExpression) {
136
+ if (ast instanceof OpraFilter.ComparisonExpression) {
137
137
  const left = convertFilter(ast.left);
138
138
  const right = convertFilter(ast.right);
139
139
  switch (ast.op) {
@@ -157,29 +157,29 @@ export function convertFilter(str) {
157
157
  throw new Error(`ComparisonExpression operator (${ast.op}) not implemented yet`);
158
158
  }
159
159
  }
160
- if (ast instanceof QualifiedIdentifier) {
160
+ if (ast instanceof OpraFilter.QualifiedIdentifier) {
161
161
  return ast.value;
162
162
  }
163
- if (ast instanceof NumberLiteral ||
164
- ast instanceof StringLiteral ||
165
- ast instanceof BooleanLiteral ||
166
- ast instanceof NullLiteral ||
167
- ast instanceof DateLiteral ||
168
- ast instanceof TimeLiteral) {
163
+ if (ast instanceof OpraFilter.NumberLiteral ||
164
+ ast instanceof OpraFilter.StringLiteral ||
165
+ ast instanceof OpraFilter.BooleanLiteral ||
166
+ ast instanceof OpraFilter.NullLiteral ||
167
+ ast instanceof OpraFilter.DateLiteral ||
168
+ ast instanceof OpraFilter.TimeLiteral) {
169
169
  return ast.value;
170
170
  }
171
- if (ast instanceof ArrayExpression) {
171
+ if (ast instanceof OpraFilter.ArrayExpression) {
172
172
  return ast.items.map(convertFilter);
173
173
  }
174
- if (ast instanceof LogicalExpression) {
174
+ if (ast instanceof OpraFilter.LogicalExpression) {
175
175
  if (ast.op === 'or')
176
176
  return { $or: ast.items.map(convertFilter) };
177
177
  return { $and: ast.items.map(convertFilter) };
178
178
  }
179
- if (ast instanceof ArrayExpression) {
179
+ if (ast instanceof OpraFilter.ArrayExpression) {
180
180
  return ast.items.map(convertFilter);
181
181
  }
182
- if (ast instanceof ParenthesesExpression) {
182
+ if (ast instanceof OpraFilter.ParenthesizedExpression) {
183
183
  return convertFilter(ast.expression);
184
184
  }
185
185
  throw new Error(`${ast.kind} is not implemented yet`);
@@ -1,9 +1,9 @@
1
1
  import { createServer, Server } from 'http';
2
2
  import { URL } from 'url';
3
- import { joinPath } from '@opra/common';
4
3
  import {
5
4
  // BatchRequest,
6
- OpraHttpClient, } from '@opra/node-client';
5
+ OpraHttpClient, } from '@opra/client';
6
+ import { joinPath } from '@opra/common';
7
7
  import { ApiExpect } from './api-expect/api-expect.js';
8
8
  import { isAbsoluteUrl } from './utils/is-absolute-url.util.js';
9
9
  export class OpraTestClient extends OpraHttpClient {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/testing",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "Opra testing package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -25,8 +25,8 @@
25
25
  "clean:cover": "rimraf ../../coverage/testing"
26
26
  },
27
27
  "dependencies": {
28
- "@opra/common": "^0.17.0",
29
- "@opra/node-client": "^0.17.0",
28
+ "@opra/common": "^0.17.2",
29
+ "@opra/client": "^0.17.2",
30
30
  "ansi-colors": "^4.1.3",
31
31
  "lodash.isnil": "^4.0.0",
32
32
  "lodash.omitby": "^4.6.0",
@@ -1,6 +1,6 @@
1
1
  import '../jest-extend/index.js';
2
- import { Expression } from '@opra/common';
3
- import { HttpResponse } from '@opra/node-client';
2
+ import { HttpResponse } from '@opra/client';
3
+ import { OpraFilter } from '@opra/common';
4
4
  export declare class ApiExpectCollection {
5
5
  readonly response: HttpResponse;
6
6
  protected _isNot: boolean;
@@ -11,10 +11,10 @@ export declare class ApiExpectCollection {
11
11
  toHaveFields(keys: string[]): this;
12
12
  toHaveFieldsOnly(keys: string[]): this;
13
13
  toBeSortedBy(...fields: string[]): this;
14
- toBeFilteredBy(filter: string | Expression): this;
14
+ toBeFilteredBy(filter: string | OpraFilter.Expression): this;
15
15
  toHaveExactItems(expected: number): this;
16
16
  toHaveMaxItems(expected: number): this;
17
17
  toHaveMinItems(expected: number): this;
18
18
  protected _expect(expected: any): jest.Matchers<any>;
19
19
  }
20
- export declare function convertFilter(str: string | Expression | undefined): any;
20
+ export declare function convertFilter(str: string | OpraFilter.Expression | undefined): any;
@@ -1,5 +1,5 @@
1
1
  import '../jest-extend/index.js';
2
- import { HttpResponse } from '@opra/node-client';
2
+ import { HttpResponse } from '@opra/client';
3
3
  import { ApiExpectObject } from './api-expect-object.js';
4
4
  export declare class ApiExpectError extends ApiExpectObject {
5
5
  readonly response: HttpResponse;
@@ -1,5 +1,5 @@
1
1
  import '../jest-extend/index.js';
2
- import { HttpResponse } from '@opra/node-client';
2
+ import { HttpResponse } from '@opra/client';
3
3
  export declare class ApiExpectObject {
4
4
  readonly response: HttpResponse;
5
5
  protected _isNot: boolean;
@@ -1,5 +1,5 @@
1
1
  import '../jest-extend/index.js';
2
- import { HttpResponse } from '@opra/node-client';
2
+ import { HttpResponse } from '@opra/client';
3
3
  export declare class ApiExpectOperationResult {
4
4
  readonly response: HttpResponse;
5
5
  protected _isNot: boolean;
@@ -1,5 +1,5 @@
1
1
  import '../jest-extend/index.js';
2
- import { HttpResponse } from '@opra/node-client';
2
+ import { HttpResponse } from '@opra/client';
3
3
  import { ApiExpectCollection } from './api-expect-collection.js';
4
4
  import { ApiExpectError } from './api-expect-error.js';
5
5
  import { ApiExpectObject } from './api-expect-object.js';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { IncomingMessage, Server, ServerResponse } from 'http';
3
3
  import { Type } from 'ts-gems';
4
- import { HttpCollectionNode, HttpResponse, HttpSingletonNode, OpraHttpClient, OpraHttpClientOptions } from '@opra/node-client';
4
+ import { HttpCollectionNode, HttpResponse, HttpSingletonNode, OpraHttpClient, OpraHttpClientOptions } from '@opra/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 = {