Socket
Socket
Sign inDemoInstall

@feathersjs/adapter-tests

Package Overview
Dependencies
0
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-pre.17 to 5.0.0-pre.18

lib/declarations.d.ts

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
### Bug Fixes
* **adapter-tests:** Add tests for pagination in multi updates ([#2472](https://github.com/feathersjs/feathers/issues/2472)) ([98a811a](https://github.com/feathersjs/feathers/commit/98a811ac605575ff812a08d0504729a5efe7a69c))
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)

@@ -8,0 +19,0 @@

3

lib/basic.d.ts

@@ -1,2 +0,3 @@

declare const _default: (test: any, app: any, _errors: any, serviceName: string, idProp: string) => void;
import { AdapterBasicTest } from './declarations';
declare const _default: (test: AdapterBasicTest, app: any, _errors: any, serviceName: string, idProp: string) => void;
export default _default;

@@ -1,2 +0,4 @@

declare const adapterTests: (testNames: string[]) => (app: any, errors: any, serviceName: any, idProp?: string) => void;
export = adapterTests;
import { AdapterTestName } from './declarations';
declare const adapterTests: (testNames: AdapterTestName[]) => (app: any, errors: any, serviceName: any, idProp?: string) => void;
export * from './declarations';
export default adapterTests;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-console */

@@ -44,3 +59,7 @@ const basic_1 = __importDefault(require("./basic"));

};
module.exports = adapterTests;
__exportStar(require("./declarations"), exports);
exports.default = adapterTests;
if (typeof module !== 'undefined') {
module.exports = Object.assign(adapterTests, module.exports);
}
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

declare const _default: (test: any, app: any, _errors: any, serviceName: string, idProp: string) => void;
import { AdapterMethodsTest } from './declarations';
declare const _default: (test: AdapterMethodsTest, app: any, _errors: any, serviceName: string, idProp: string) => void;
export default _default;

@@ -129,2 +129,35 @@ "use strict";

});
test('.remove + multi no pagination', async () => {
try {
await service.remove(doug[idProp]);
}
catch (error) { }
const count = 14;
const defaultPaginate = 10;
assert_1.default.ok(count > defaultPaginate, 'count is bigger than default pagination');
const multiBefore = service.options.multi;
const paginateBefore = service.options.paginate;
try {
service.options.multi = true;
service.options.paginate = {
'default': defaultPaginate,
'max': 100
};
const emptyItems = await service.find({ paginate: false });
assert_1.default.strictEqual(emptyItems.length, 0, 'no items before');
const createdItems = await service.create(Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true })));
assert_1.default.strictEqual(createdItems.length, count, `created ${count} items`);
const foundItems = await service.find({ paginate: false });
assert_1.default.strictEqual(foundItems.length, count, `created ${count} items`);
const foundPaginatedItems = await service.find({});
assert_1.default.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated items');
const allItems = await service.remove(null, { query: { created: true } });
assert_1.default.strictEqual(allItems.length, count, `removed all ${count} items`);
}
finally {
await service.remove(null, { query: { created: true }, paginate: false });
service.options.multi = multiBefore;
service.options.paginate = paginateBefore;
}
});
test('.remove + id + query id', async () => {

@@ -284,2 +317,39 @@ const alice = await service.create({

});
test('.patch multiple no pagination', async () => {
try {
await service.remove(doug[idProp]);
}
catch (error) { }
const count = 14;
const defaultPaginate = 10;
assert_1.default.ok(count > defaultPaginate, 'count is bigger than default pagination');
const multiBefore = service.options.multi;
const paginateBefore = service.options.paginate;
let ids;
try {
service.options.multi = true;
service.options.paginate = {
'default': defaultPaginate,
'max': 100
};
const emptyItems = await service.find({ paginate: false });
assert_1.default.strictEqual(emptyItems.length, 0, 'no items before');
const createdItems = await service.create(Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true })));
assert_1.default.strictEqual(createdItems.length, count, `created ${count} items`);
ids = createdItems.map((item) => item[idProp]);
const foundItems = await service.find({ paginate: false });
assert_1.default.strictEqual(foundItems.length, count, `created ${count} items`);
const foundPaginatedItems = await service.find({});
assert_1.default.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated data');
const allItems = await service.patch(null, { age: 4 }, { query: { created: true } });
assert_1.default.strictEqual(allItems.length, count, `patched all ${count} items`);
}
finally {
service.options.multi = multiBefore;
service.options.paginate = paginateBefore;
if (ids) {
await Promise.all(ids.map(id => service.remove(id)));
}
}
});
test('.patch multi query same', async () => {

@@ -286,0 +356,0 @@ const service = app.service(serviceName);

@@ -1,2 +0,3 @@

declare const _default: (test: any, app: any, _errors: any, serviceName: string, idProp: string) => void;
import { AdapterSyntaxTest } from './declarations';
declare const _default: (test: AdapterSyntaxTest, app: any, _errors: any, serviceName: string, idProp: string) => void;
export default _default;
{
"name": "@feathersjs/adapter-tests",
"version": "5.0.0-pre.17",
"version": "5.0.0-pre.18",
"description": "Feathers shared database adapter test suite",

@@ -16,3 +16,4 @@ "homepage": "https://feathersjs.com",

"type": "git",
"url": "git://github.com/feathersjs/feathers.git"
"url": "git://github.com/feathersjs/feathers.git",
"directory": "packages/adapter-tests"
},

@@ -31,8 +32,8 @@ "author": {

},
"main": "lib/index.js",
"main": "lib/",
"types": "lib/",
"scripts": {
"prepublish": "npm run compile",
"compile": "shx rm -rf lib/ && tsc",
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
"test": "npm run compile && npm run mocha"
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
},

@@ -54,9 +55,9 @@ "directories": {

"@types/mocha": "^9.1.0",
"@types/node": "^17.0.15",
"mocha": "^9.2.0",
"@types/node": "^17.0.23",
"mocha": "^9.2.2",
"shx": "^0.3.4",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
},
"gitHead": "d828748e57b40abfaa15710663afed417de14a1d"
"gitHead": "c0b7b67d872dcd6b6d94e4587f21332c8a519b50"
}

@@ -5,2 +5,3 @@ # Feathers Adapter Tests

[![Download Status](https://img.shields.io/npm/dm/@feathersjs/adapter-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/adapter-commons)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)

@@ -7,0 +8,0 @@ > Feathers shared database adapter test suite

import assert from 'assert';
import { AdapterBasicTest } from './declarations';
export default (test: any, app: any, _errors: any, serviceName: string, idProp: string) => {
export default (test: AdapterBasicTest, app: any, _errors: any, serviceName: string, idProp: string) => {
describe('Basic Functionality', () => {

@@ -5,0 +6,0 @@ let service: any;

/* eslint-disable no-console */
import basicTests from './basic';
import { AdapterTestName } from './declarations';
import methodTests from './methods';
import syntaxTests from './syntax';
const adapterTests = (testNames: string[]) => {
const adapterTests = (testNames: AdapterTestName[]) => {
return (app: any, errors: any, serviceName: any, idProp = 'id') => {

@@ -12,6 +13,6 @@ if (!serviceName) {

const skippedTests: string[] = [];
const allTests: string[] = [];
const skippedTests: AdapterTestName[] = [];
const allTests: AdapterTestName[] = [];
const test = (name: string, runner: any) => {
const test = (name: AdapterTestName, runner: any) => {
const skip = !testNames.includes(name);

@@ -50,2 +51,8 @@ const its = skip ? it.skip : it;

export = adapterTests;
export * from './declarations'
export default adapterTests;
if (typeof module !== 'undefined') {
module.exports = Object.assign(adapterTests, module.exports);
}
import assert from 'assert';
import { AdapterMethodsTest } from './declarations';
export default (test: any, app: any, _errors: any, serviceName: string, idProp: string) => {
export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: string, idProp: string) => {
describe(' Methods', () => {

@@ -159,2 +160,47 @@ let doug: any;

test('.remove + multi no pagination', async () => {
try {
await service.remove(doug[idProp]);
} catch (error: any) {}
const count = 14;
const defaultPaginate = 10;
assert.ok(count > defaultPaginate, 'count is bigger than default pagination');
const multiBefore = service.options.multi;
const paginateBefore = service.options.paginate;
try {
service.options.multi = true;
service.options.paginate = {
'default': defaultPaginate,
'max': 100
};
const emptyItems = await service.find({ paginate: false });
assert.strictEqual(emptyItems.length, 0, 'no items before')
const createdItems = await service.create(
Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true }))
);
assert.strictEqual(createdItems.length, count, `created ${count} items`);
const foundItems = await service.find({ paginate: false });
assert.strictEqual(foundItems.length, count, `created ${count} items`);
const foundPaginatedItems = await service.find({});
assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated items');
const allItems = await service.remove(null, { query: { created: true } });
assert.strictEqual(allItems.length, count, `removed all ${ count } items`);
} finally {
await service.remove(null, { query: { created: true }, paginate: false });
service.options.multi = multiBefore;
service.options.paginate = paginateBefore;
}
});
test('.remove + id + query id', async () => {

@@ -361,2 +407,53 @@ const alice = await service.create({

test('.patch multiple no pagination', async () => {
try {
await service.remove(doug[idProp]);
} catch (error: any) {}
const count = 14;
const defaultPaginate = 10;
assert.ok(count > defaultPaginate, 'count is bigger than default pagination');
const multiBefore = service.options.multi;
const paginateBefore = service.options.paginate;
let ids: any[];
try {
service.options.multi = true;
service.options.paginate = {
'default': defaultPaginate,
'max': 100
};
const emptyItems = await service.find({ paginate: false });
assert.strictEqual(emptyItems.length, 0, 'no items before')
const createdItems = await service.create(
Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true }))
);
assert.strictEqual(createdItems.length, count, `created ${count} items`);
ids = createdItems.map((item: any) => item[idProp]);
const foundItems = await service.find({ paginate: false });
assert.strictEqual(foundItems.length, count, `created ${count} items`);
const foundPaginatedItems = await service.find({});
assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated data')
const allItems = await service.patch(null, { age: 4 }, { query: { created: true } })
assert.strictEqual(allItems.length, count, `patched all ${ count } items`);
} finally {
service.options.multi = multiBefore;
service.options.paginate = paginateBefore;
if (ids) {
await Promise.all(
ids.map(id => service.remove(id))
)
}
}
});
test('.patch multi query same', async () => {

@@ -363,0 +460,0 @@ const service = app.service(serviceName);

import assert from 'assert';
import { AdapterSyntaxTest } from './declarations';
export default (test: any, app: any, _errors: any, serviceName: string, idProp: string) => {
export default (test: AdapterSyntaxTest, app: any, _errors: any, serviceName: string, idProp: string) => {
describe('Query Syntax', () => {

@@ -286,3 +287,3 @@ let bob: any;

});
assert.strictEqual(page.limit, 3);

@@ -311,3 +312,3 @@ assert.strictEqual(page.skip, 0);

assert.strictEqual(users.length, 2);
await service.remove(users[0][idProp]);

@@ -314,0 +315,0 @@ await service.remove(users[1][idProp]);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc