feathers-adapter-vitest 0.0.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.
package/CHANGELOG.md ADDED
File without changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Feathers Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Feathers Adapter Tests for vitest
2
+
3
+ > Feathers shared database adapter test suite
4
+
5
+ ## About
6
+
7
+ This is a repository that contains the test suite for the common database adapter syntax. See the [API documentation](https://docs.feathersjs.com/api/databases/common.html) for more information.
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ npm install --save-dev feathers-adapter-vitest
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ // index.test.ts
19
+
20
+ import { defineTestSuite } from "feathers-adapter-vitest";
21
+
22
+ const testSuite = defineTestSuite([
23
+ ".events",
24
+ // ... and so on
25
+ ]);
26
+ ```
27
+
28
+ ## License
29
+
30
+ Licensed under the [MIT license](./LICENSE).
@@ -0,0 +1,3 @@
1
+ import type { AdapterBasicTest } from './declarations.js';
2
+ declare const _default: (test: AdapterBasicTest, app: any, _errors: any, serviceName: string, idProp: string) => void;
3
+ export default _default;
package/dist/basic.js ADDED
@@ -0,0 +1,39 @@
1
+ import assert from 'node:assert';
2
+ import { describe, beforeEach, it } from 'vitest';
3
+ export default (test, app, _errors, serviceName, idProp) => {
4
+ describe('Basic Functionality', () => {
5
+ let service;
6
+ beforeEach(() => {
7
+ service = app.service(serviceName);
8
+ });
9
+ it('.id', () => {
10
+ assert.strictEqual(service.id, idProp, 'id property is set to expected name');
11
+ });
12
+ test('.options', () => {
13
+ assert.ok(service.options, 'Options are available in service.options');
14
+ });
15
+ test('.events', () => {
16
+ assert.ok(service.events.includes('testing'), 'service.events is set and includes "testing"');
17
+ });
18
+ describe('Raw Methods', () => {
19
+ test('._get', () => {
20
+ assert.strictEqual(typeof service._get, 'function');
21
+ });
22
+ test('._find', () => {
23
+ assert.strictEqual(typeof service._find, 'function');
24
+ });
25
+ test('._create', () => {
26
+ assert.strictEqual(typeof service._create, 'function');
27
+ });
28
+ test('._update', () => {
29
+ assert.strictEqual(typeof service._update, 'function');
30
+ });
31
+ test('._patch', () => {
32
+ assert.strictEqual(typeof service._patch, 'function');
33
+ });
34
+ test('._remove', () => {
35
+ assert.strictEqual(typeof service._remove, 'function');
36
+ });
37
+ });
38
+ });
39
+ };
@@ -0,0 +1,8 @@
1
+ export type AdapterTest = (name: AdapterTestName, runner: any) => void;
2
+ export type AdapterBasicTest = (name: AdapterBasicTestName, runner: any) => void;
3
+ export type AdapterMethodsTest = (name: AdapterMethodsTestName, runner: any) => void;
4
+ export type AdapterSyntaxTest = (name: AdapterSyntaxTestName, runner: any) => void;
5
+ export type AdapterTestName = AdapterBasicTestName | AdapterMethodsTestName | AdapterSyntaxTestName;
6
+ export type AdapterBasicTestName = '.id' | '.options' | '.events' | '._get' | '._find' | '._create' | '._update' | '._patch' | '._remove' | '.$get' | '.$find' | '.$create' | '.$update' | '.$patch' | '.$remove';
7
+ export type AdapterMethodsTestName = '.get' | '.get + $select' | '.get + id + query' | '.get + NotFound' | '.get + id + query id' | '.find' | '.remove' | '.remove + $select' | '.remove + id + query' | '.remove + multi' | '.remove + multi no pagination' | '.remove + id + query id' | '.update' | '.update + $select' | '.update + id + query' | '.update + NotFound' | '.update + query + NotFound' | '.update + id + query id' | '.patch' | '.patch + $select' | '.patch + id + query' | '.patch multiple' | '.patch multiple no pagination' | '.patch multi query same' | '.patch multi query changed' | '.patch + NotFound' | '.patch + query + NotFound' | '.patch + id + query id' | '.create' | '.create + $select' | '.create multi' | '.create ignores query' | 'internal .find' | 'internal .get' | 'internal .create' | 'internal .update' | 'internal .patch' | 'internal .remove';
8
+ export type AdapterSyntaxTestName = '.find + equal' | '.find + equal multiple' | '.find + $sort' | '.find + $sort + string' | '.find + $limit' | '.find + $limit 0' | '.find + $skip' | '.find + $select' | '.find + $or' | '.find + $in' | '.find + $nin' | '.find + $lt' | '.find + $lte' | '.find + $gt' | '.find + $gte' | '.find + $ne' | '.find + $gt + $lt + $sort' | '.find + $or nested + $sort' | '.find + $and' | '.find + $and + $or' | 'params.adapter + paginate' | 'params.adapter + multi' | '.find + paginate' | '.find + paginate + query' | '.find + paginate + $limit + $skip' | '.find + paginate + $limit 0' | '.find + paginate + params';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { AdapterTestName } from './declarations.js';
2
+ export declare const adapterTests: (testNames: AdapterTestName[]) => (app: any, errors: any, serviceName: any, idProp?: string) => void;
3
+ export * from './declarations.js';
4
+ export default adapterTests;
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ import basicTests from './basic.js';
2
+ import methodTests from './methods.js';
3
+ import syntaxTests from './syntax.js';
4
+ import { describe, it, afterAll } from 'vitest';
5
+ export const adapterTests = (testNames) => {
6
+ return (app, errors, serviceName, idProp = 'id') => {
7
+ if (!serviceName) {
8
+ throw new Error('You must pass a service name');
9
+ }
10
+ const skippedTests = [];
11
+ const allTests = [];
12
+ const test = (name, runner) => {
13
+ const skip = !testNames.includes(name);
14
+ const its = skip ? it.skip : it;
15
+ if (skip) {
16
+ skippedTests.push(name);
17
+ }
18
+ allTests.push(name);
19
+ its(name, runner);
20
+ };
21
+ describe(`Adapter tests for '${serviceName}' service with '${idProp}' id property`, () => {
22
+ afterAll(() => {
23
+ testNames.forEach((name) => {
24
+ if (!allTests.includes(name)) {
25
+ console.error(`WARNING: '${name}' test is not part of the test suite`);
26
+ }
27
+ });
28
+ if (skippedTests.length) {
29
+ console.log(`\nSkipped the following ${skippedTests.length} Feathers adapter test(s) out of ${allTests.length} total:`);
30
+ console.log(JSON.stringify(skippedTests, null, ' '));
31
+ }
32
+ });
33
+ basicTests(test, app, errors, serviceName, idProp);
34
+ methodTests(test, app, errors, serviceName, idProp);
35
+ syntaxTests(test, app, errors, serviceName, idProp);
36
+ });
37
+ };
38
+ };
39
+ export * from './declarations.js';
40
+ export default adapterTests;
@@ -0,0 +1,3 @@
1
+ import type { AdapterMethodsTest } from './declarations.js';
2
+ declare const _default: (test: AdapterMethodsTest, app: any, _errors: any, serviceName: string, idProp: string) => void;
3
+ export default _default;