@feathersjs/adapter-tests 5.0.0-pre.3 → 5.0.0-pre.30

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/src/basic.ts CHANGED
@@ -1,53 +1,74 @@
1
- import assert from 'assert';
1
+ import assert from 'assert'
2
+ import { AdapterBasicTest } from './declarations'
2
3
 
3
- export default (test: any, app: any, _errors: any, serviceName: string, idProp: string) => {
4
+ export default (test: AdapterBasicTest, app: any, _errors: any, serviceName: string, idProp: string) => {
4
5
  describe('Basic Functionality', () => {
5
- let service: any;
6
+ let service: any
6
7
 
7
8
  beforeEach(() => {
8
- service = app.service(serviceName);
9
- });
9
+ service = app.service(serviceName)
10
+ })
10
11
 
11
12
  it('.id', () => {
12
- assert.strictEqual(service.id, idProp,
13
- 'id property is set to expected name'
14
- );
15
- });
13
+ assert.strictEqual(service.id, idProp, 'id property is set to expected name')
14
+ })
16
15
 
17
16
  test('.options', () => {
18
- assert.ok(service.options, 'Options are available in service.options');
19
- });
17
+ assert.ok(service.options, 'Options are available in service.options')
18
+ })
20
19
 
21
20
  test('.events', () => {
22
- assert.ok(service.events.includes('testing'),
23
- 'service.events is set and includes "testing"'
24
- );
25
- });
21
+ assert.ok(service.events.includes('testing'), 'service.events is set and includes "testing"')
22
+ })
26
23
 
27
24
  describe('Raw Methods', () => {
28
25
  test('._get', () => {
29
- assert.strictEqual(typeof service._get, 'function');
30
- });
26
+ assert.strictEqual(typeof service._get, 'function')
27
+ })
31
28
 
32
29
  test('._find', () => {
33
- assert.strictEqual(typeof service._find, 'function');
34
- });
30
+ assert.strictEqual(typeof service._find, 'function')
31
+ })
35
32
 
36
33
  test('._create', () => {
37
- assert.strictEqual(typeof service._create, 'function');
38
- });
34
+ assert.strictEqual(typeof service._create, 'function')
35
+ })
39
36
 
40
37
  test('._update', () => {
41
- assert.strictEqual(typeof service._update, 'function');
42
- });
38
+ assert.strictEqual(typeof service._update, 'function')
39
+ })
43
40
 
44
41
  test('._patch', () => {
45
- assert.strictEqual(typeof service._patch, 'function');
46
- });
42
+ assert.strictEqual(typeof service._patch, 'function')
43
+ })
47
44
 
48
45
  test('._remove', () => {
49
- assert.strictEqual(typeof service._remove, 'function');
50
- });
51
- });
52
- });
53
- };
46
+ assert.strictEqual(typeof service._remove, 'function')
47
+ })
48
+
49
+ test('.$get', () => {
50
+ assert.strictEqual(typeof service.$get, 'function')
51
+ })
52
+
53
+ test('.$find', () => {
54
+ assert.strictEqual(typeof service.$find, 'function')
55
+ })
56
+
57
+ test('.$create', () => {
58
+ assert.strictEqual(typeof service.$create, 'function')
59
+ })
60
+
61
+ test('.$update', () => {
62
+ assert.strictEqual(typeof service.$update, 'function')
63
+ })
64
+
65
+ test('.$patch', () => {
66
+ assert.strictEqual(typeof service.$patch, 'function')
67
+ })
68
+
69
+ test('.$remove', () => {
70
+ assert.strictEqual(typeof service.$remove, 'function')
71
+ })
72
+ })
73
+ })
74
+ }
@@ -0,0 +1,90 @@
1
+ export type AdapterTest = (name: AdapterTestName, runner: any) => void
2
+
3
+ export type AdapterBasicTest = (name: AdapterBasicTestName, runner: any) => void
4
+ export type AdapterMethodsTest = (name: AdapterMethodsTestName, runner: any) => void
5
+ export type AdapterSyntaxTest = (name: AdapterSyntaxTestName, runner: any) => void
6
+
7
+ export type AdapterTestName = AdapterBasicTestName | AdapterMethodsTestName | AdapterSyntaxTestName
8
+
9
+ export type AdapterBasicTestName =
10
+ | '.id'
11
+ | '.options'
12
+ | '.events'
13
+ | '._get'
14
+ | '._find'
15
+ | '._create'
16
+ | '._update'
17
+ | '._patch'
18
+ | '._remove'
19
+ | '.$get'
20
+ | '.$find'
21
+ | '.$create'
22
+ | '.$update'
23
+ | '.$patch'
24
+ | '.$remove'
25
+
26
+ export type AdapterMethodsTestName =
27
+ | '.get'
28
+ | '.get + $select'
29
+ | '.get + id + query'
30
+ | '.get + NotFound'
31
+ | '.get + id + query id'
32
+ | '.find'
33
+ | '.remove'
34
+ | '.remove + $select'
35
+ | '.remove + id + query'
36
+ | '.remove + multi'
37
+ | '.remove + multi no pagination'
38
+ | '.remove + id + query id'
39
+ | '.update'
40
+ | '.update + $select'
41
+ | '.update + id + query'
42
+ | '.update + NotFound'
43
+ | '.update + query + NotFound'
44
+ | '.update + id + query id'
45
+ | '.patch'
46
+ | '.patch + $select'
47
+ | '.patch + id + query'
48
+ | '.patch multiple'
49
+ | '.patch multiple no pagination'
50
+ | '.patch multi query same'
51
+ | '.patch multi query changed'
52
+ | '.patch + NotFound'
53
+ | '.patch + query + NotFound'
54
+ | '.patch + id + query id'
55
+ | '.create'
56
+ | '.create + $select'
57
+ | '.create multi'
58
+ | 'internal .find'
59
+ | 'internal .get'
60
+ | 'internal .create'
61
+ | 'internal .update'
62
+ | 'internal .patch'
63
+ | 'internal .remove'
64
+
65
+ export type AdapterSyntaxTestName =
66
+ | '.find + equal'
67
+ | '.find + equal multiple'
68
+ | '.find + $sort'
69
+ | '.find + $sort + string'
70
+ | '.find + $limit'
71
+ | '.find + $limit 0'
72
+ | '.find + $skip'
73
+ | '.find + $select'
74
+ | '.find + $or'
75
+ | '.find + $in'
76
+ | '.find + $nin'
77
+ | '.find + $lt'
78
+ | '.find + $lte'
79
+ | '.find + $gt'
80
+ | '.find + $gte'
81
+ | '.find + $ne'
82
+ | '.find + $gt + $lt + $sort'
83
+ | '.find + $or nested + $sort'
84
+ | 'params.adapter + paginate'
85
+ | 'params.adapter + multi'
86
+ | '.find + paginate'
87
+ | '.find + paginate + query'
88
+ | '.find + paginate + $limit + $skip'
89
+ | '.find + paginate + $limit 0'
90
+ | '.find + paginate + params'
package/src/index.ts CHANGED
@@ -1,49 +1,57 @@
1
1
  /* eslint-disable no-console */
2
- import basicTests from './basic';
3
- import methodTests from './methods';
4
- import syntaxTests from './syntax';
2
+ import basicTests from './basic'
3
+ import { AdapterTestName } from './declarations'
4
+ import methodTests from './methods'
5
+ import syntaxTests from './syntax'
5
6
 
6
- const adapterTests = (testNames: string[]) => {
7
+ const adapterTests = (testNames: AdapterTestName[]) => {
7
8
  return (app: any, errors: any, serviceName: any, idProp = 'id') => {
8
9
  if (!serviceName) {
9
- throw new Error('You must pass a service name');
10
+ throw new Error('You must pass a service name')
10
11
  }
11
12
 
12
- const skippedTests: string[] = [];
13
- const allTests: string[] = [];
13
+ const skippedTests: AdapterTestName[] = []
14
+ const allTests: AdapterTestName[] = []
14
15
 
15
- const test = (name: string, runner: any) => {
16
- const skip = !testNames.includes(name);
17
- const its = skip ? it.skip : it;
16
+ const test = (name: AdapterTestName, runner: any) => {
17
+ const skip = !testNames.includes(name)
18
+ const its = skip ? it.skip : it
18
19
 
19
20
  if (skip) {
20
- skippedTests.push(name);
21
+ skippedTests.push(name)
21
22
  }
22
23
 
23
- allTests.push(name);
24
+ allTests.push(name)
24
25
 
25
- its(name, runner);
26
- };
26
+ its(name, runner)
27
+ }
27
28
 
28
29
  describe(`Adapter tests for '${serviceName}' service with '${idProp}' id property`, () => {
29
30
  after(() => {
30
- console.log('\n');
31
- testNames.forEach(name => {
31
+ testNames.forEach((name) => {
32
32
  if (!allTests.includes(name)) {
33
- console.error(`WARNING: '${name}' test is not part of the test suite`);
33
+ console.error(`WARNING: '${name}' test is not part of the test suite`)
34
34
  }
35
- });
35
+ })
36
36
  if (skippedTests.length) {
37
- console.log(`\nSkipped the following ${skippedTests.length} Feathers adapter test(s) out of ${allTests.length} total:`);
38
- console.log(JSON.stringify(skippedTests, null, ' '));
37
+ console.log(
38
+ `\nSkipped the following ${skippedTests.length} Feathers adapter test(s) out of ${allTests.length} total:`
39
+ )
40
+ console.log(JSON.stringify(skippedTests, null, ' '))
39
41
  }
40
- });
42
+ })
43
+
44
+ basicTests(test, app, errors, serviceName, idProp)
45
+ methodTests(test, app, errors, serviceName, idProp)
46
+ syntaxTests(test, app, errors, serviceName, idProp)
47
+ })
48
+ }
49
+ }
50
+
51
+ export * from './declarations'
41
52
 
42
- basicTests(test, app, errors, serviceName, idProp);
43
- methodTests(test, app, errors, serviceName, idProp);
44
- syntaxTests(test, app, errors, serviceName, idProp);
45
- });
46
- };
47
- };
53
+ export default adapterTests
48
54
 
49
- export = adapterTests;
55
+ if (typeof module !== 'undefined') {
56
+ module.exports = Object.assign(adapterTests, module.exports)
57
+ }