museria 0.2.49 → 0.3.1

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.
Files changed (74) hide show
  1. package/.eslintrc +10 -2
  2. package/.github/workflows/build.yml +3 -3
  3. package/.github/workflows/publish.yml +3 -3
  4. package/README.md +55 -59
  5. package/bin/actions.js +28 -28
  6. package/bin/index.js +4 -4
  7. package/bin/runner.js +1 -1
  8. package/bin/utils.js +6 -2
  9. package/dist/client/museria.client.js +7 -7
  10. package/dist/face/45a265d0f07b31cde85f.ttf +0 -0
  11. package/dist/face/6205fd00fb1b573e9f0f.ttf +0 -0
  12. package/dist/face/8d3cabfc66809162fb4d.woff2 +0 -0
  13. package/dist/face/fb8184add5a3101ad0a3.woff2 +0 -0
  14. package/dist/face/museria.face.js +33 -13
  15. package/dist/face/style.css +13 -11
  16. package/package.json +41 -40
  17. package/src/browser/client/index.js +2 -1
  18. package/src/browser/face/client.js +2 -1
  19. package/src/browser/face/controllers/app/app.html +77 -69
  20. package/src/browser/face/controllers/app/app.js +14 -7
  21. package/src/browser/face/controllers/app/app.scss +2 -22
  22. package/src/browser/face/index.js +3 -3
  23. package/src/browser/face/styles/main.scss +91 -11
  24. package/src/browser/face/styles/vars.scss +0 -1
  25. package/src/client.js +73 -74
  26. package/src/collection/transports/music/index.js +20 -18
  27. package/src/db/transports/database/index.js +7 -5
  28. package/src/db/transports/loki/index.js +30 -25
  29. package/src/errors.js +2 -1
  30. package/src/index.js +8 -6
  31. package/src/node.js +312 -323
  32. package/src/schema.js +27 -29
  33. package/src/server/transports/express/api/butler/controllers.js +7 -10
  34. package/src/server/transports/express/api/butler/routes.js +5 -5
  35. package/src/server/transports/express/api/master/controllers.js +7 -10
  36. package/src/server/transports/express/api/master/routes.js +5 -5
  37. package/src/server/transports/express/api/node/controllers.js +52 -61
  38. package/src/server/transports/express/api/node/routes.js +10 -10
  39. package/src/server/transports/express/api/routes.js +1 -1
  40. package/src/server/transports/express/api/slave/controllers.js +7 -10
  41. package/src/server/transports/express/api/slave/routes.js +6 -6
  42. package/src/server/transports/express/client/controllers.js +40 -61
  43. package/src/server/transports/express/client/routes.js +33 -39
  44. package/src/server/transports/express/controllers.js +10 -21
  45. package/src/server/transports/express/index.js +23 -20
  46. package/src/server/transports/express/midds.js +67 -67
  47. package/src/server/transports/express/routes.js +12 -12
  48. package/src/utils.js +175 -184
  49. package/test/client.js +311 -305
  50. package/test/db/database.js +32 -28
  51. package/test/db/loki.js +78 -74
  52. package/test/group.js +161 -156
  53. package/test/index.js +20 -10
  54. package/test/node.js +461 -460
  55. package/test/routes.js +404 -399
  56. package/test/server/express.js +35 -31
  57. package/test/services.js +25 -18
  58. package/test/tools.js +8 -6
  59. package/test/utils.js +236 -234
  60. package/webpack.client.js +9 -7
  61. package/webpack.face.js +8 -6
  62. package/dist/face/fa-brands-400.eot +0 -0
  63. package/dist/face/fa-brands-400.svg +0 -3717
  64. package/dist/face/fa-brands-400.ttf +0 -0
  65. package/dist/face/fa-brands-400.woff +0 -0
  66. package/dist/face/fa-brands-400.woff2 +0 -0
  67. package/dist/face/fa-solid-900.eot +0 -0
  68. package/dist/face/fa-solid-900.svg +0 -5034
  69. package/dist/face/fa-solid-900.ttf +0 -0
  70. package/dist/face/fa-solid-900.woff +0 -0
  71. package/dist/face/fa-solid-900.woff2 +0 -0
  72. /package/dist/face/{open-sans.ttf → 17e98b9e5586529b13cc.ttf} +0 -0
  73. /package/dist/face/{proxima-nova.ttf → 326601dfabd91e3f016c.ttf} +0 -0
  74. /package/dist/face/{logo.svg → ee9c6af64aa224827cec.svg} +0 -0
@@ -1,37 +1,41 @@
1
- const assert = require('chai').assert;
2
- const DatabaseMuseria = require('../../src/db/transports/database')();
1
+ import { assert } from "chai";
2
+ import database from "../../src/db/transports/database/index.js";
3
3
 
4
- describe('DatabaseMetastocle', () => {
5
- let db;
6
-
7
- describe('instance creation', function () {
8
- it('should create an instance', function () {
9
- assert.doesNotThrow(() => db = new DatabaseMuseria());
10
- db.node = this.node;
4
+ const DatabaseMuseria = database();
5
+
6
+ export default function () {
7
+ describe('DatabaseMetastocle', () => {
8
+ let db;
9
+
10
+ describe('instance creation', function () {
11
+ it('should create an instance', function () {
12
+ assert.doesNotThrow(() => db = new DatabaseMuseria());
13
+ db.node = this.node;
14
+ });
11
15
  });
12
- });
13
16
 
14
- describe('.init()', function () {
15
- it('should not throw an exception', async function () {
16
- await db.init();
17
- });
18
- });
17
+ describe('.init()', function () {
18
+ it('should not throw an exception', async function () {
19
+ await db.init();
20
+ });
21
+ });
19
22
 
20
- describe('.deinit()', function () {
21
- it('should not throw an exception', async function () {
22
- await db.deinit();
23
+ describe('.deinit()', function () {
24
+ it('should not throw an exception', async function () {
25
+ await db.deinit();
26
+ });
23
27
  });
24
- });
25
28
 
26
- describe('reinitialization', () => {
27
- it('should not throw an exception', async function () {
28
- await db.init();
29
+ describe('reinitialization', () => {
30
+ it('should not throw an exception', async function () {
31
+ await db.init();
32
+ });
29
33
  });
30
- });
31
-
32
- describe('.destroy()', function () {
33
- it('should not throw an exception', async function () {
34
- await db.destroy();
34
+
35
+ describe('.destroy()', function () {
36
+ it('should not throw an exception', async function () {
37
+ await db.destroy();
38
+ });
35
39
  });
36
40
  });
37
- });
41
+ }
package/test/db/loki.js CHANGED
@@ -1,94 +1,98 @@
1
- const assert = require('chai').assert;
2
- const tools = require('../tools');
3
- const DatabaseLokiMuseria = require('../../src/db/transports/loki')();
4
- const utils = require('../../src/utils');
1
+ import { assert } from "chai";
2
+ import tools from "../tools.js";
3
+ import loki from "../../src/db/transports/loki/index.js";
4
+ import utils from "../../src/utils.js";
5
5
 
6
- describe('DatabaseLokiMetastocle', () => {
7
- let loki;
8
- let lastNodeDb;
9
-
10
- describe('instance creation', function () {
11
- it('should create an instance', function () {
12
- assert.doesNotThrow(() => loki = new DatabaseLokiMuseria({
13
- filename: tools.getDbFilePath(this.node)
14
- }));
15
- loki.node = this.node;
16
- lastNodeDb = this.node.db;
17
- this.node.db = loki;
18
- });
19
- });
6
+ const DatabaseLokiMuseria = loki();
7
+
8
+ export default function () {
9
+ describe('DatabaseLokiMetastocle', () => {
10
+ let loki;
11
+ let lastNodeDb;
20
12
 
21
- describe('.init()', function () {
22
- it('should not throw an exception', async function () {
23
- await loki.init();
13
+ describe('instance creation', function () {
14
+ it('should create an instance', function () {
15
+ assert.doesNotThrow(() => loki = new DatabaseLokiMuseria({
16
+ filename: tools.getDbFilePath(this.node)
17
+ }));
18
+ loki.node = this.node;
19
+ lastNodeDb = this.node.db;
20
+ this.node.db = loki;
21
+ });
24
22
  });
25
23
 
26
- it('should create a music collection', async function () {
27
- await loki.addCollection('music', { pk: 'title', loki: { unique: ['fileHash'] } });
28
- })
29
- });
24
+ describe('.init()', function () {
25
+ it('should not throw an exception', async function () {
26
+ await loki.init();
27
+ });
30
28
 
31
- describe('.getMusicByPk()', function () {
32
- it('should return the document', async function () {
33
- const title = 'artist - title';
34
- await loki.addMusicDocument({ title: title + '0' });
35
- await loki.addMusicDocument({ title: title + '1' });
36
- await loki.addMusicDocument({ title: title + '2' });
37
- const docStrict = await loki.getMusicByPk(title + '1');
38
- const doc = await loki.getMusicByPk(title + 'on');
39
- assert.equal(docStrict.title, utils.beautifySongTitle(title + '1'), 'check the strict document');
40
- assert.isObject(doc, 'check the approximate document');
29
+ it('should create a music collection', async function () {
30
+ await loki.addCollection('music', { pk: 'title', loki: { unique: ['fileHash'] } });
31
+ });
41
32
  });
42
33
 
43
- it('should return null', async function () {
44
- assert.isNull(await loki.getMusicByPk('wrong'));
45
- });
46
- });
34
+ describe('.getMusicByPk()', function () {
35
+ it('should return the document', async function () {
36
+ const title = 'artist - title';
37
+ await loki.addMusicDocument({ title: title + '0' });
38
+ await loki.addMusicDocument({ title: title + '1' });
39
+ await loki.addMusicDocument({ title: title + '2' });
40
+ const docStrict = await loki.getMusicByPk(title + '1');
41
+ const doc = await loki.getMusicByPk(title + 'on');
42
+ assert.equal(docStrict.title, utils.beautifySongTitle(title + '1'), 'check the strict document');
43
+ assert.isObject(doc, 'check the approximate document');
44
+ });
47
45
 
48
- describe('.getMusicByFileHash()', function () {
49
- it('should get the right document', async function () {
50
- const hash = 'y';
51
- await loki.addMusicDocument({ title: 'it - is a song', fileHash: hash });
52
- const doc = await loki.getMusicByFileHash(hash);
53
- assert.equal(doc.fileHash, hash);
46
+ it('should return null', async function () {
47
+ assert.isNull(await loki.getMusicByPk('wrong'));
48
+ });
54
49
  });
55
50
 
56
- it('should return null', async function () {
57
- assert.isNull(await loki.getMusicByFileHash('wrong'));
58
- });
59
- });
51
+ describe('.getMusicByFileHash()', function () {
52
+ it('should get the right document', async function () {
53
+ const hash = 'y';
54
+ await loki.addMusicDocument({ title: 'it - is a song', fileHash: hash });
55
+ const doc = await loki.getMusicByFileHash(hash);
56
+ assert.equal(doc.fileHash, hash);
57
+ });
60
58
 
61
- describe('.removeMusicByFileHash()', function () {
62
- it('should not remove anything', async function () {
63
- const count = await loki.getCollectionSize('music');
64
- await loki.removeMusicByFileHash('x');
65
- assert.equal(count, await loki.getCollectionSize('music'));
59
+ it('should return null', async function () {
60
+ assert.isNull(await loki.getMusicByFileHash('wrong'));
61
+ });
66
62
  });
67
63
 
68
- it('should remove only the necessary document', async function () {
69
- const count = await loki.getCollectionSize('music');
70
- await loki.addMusicDocument({ title: 'new - song', fileHash: 'x' });
71
- await loki.removeMusicByFileHash('x');
72
- assert.equal(count, await loki.getCollectionSize('music'));
64
+ describe('.removeMusicByFileHash()', function () {
65
+ it('should not remove anything', async function () {
66
+ const count = await loki.getCollectionSize('music');
67
+ await loki.removeMusicByFileHash('x');
68
+ assert.equal(count, await loki.getCollectionSize('music'));
69
+ });
70
+
71
+ it('should remove only the necessary document', async function () {
72
+ const count = await loki.getCollectionSize('music');
73
+ await loki.addMusicDocument({ title: 'new - song', fileHash: 'x' });
74
+ await loki.removeMusicByFileHash('x');
75
+ assert.equal(count, await loki.getCollectionSize('music'));
76
+ });
73
77
  });
74
- });
75
78
 
76
- describe('.deinit()', function () {
77
- it('should not throw an exception', async function () {
78
- await loki.deinit();
79
+ describe('.deinit()', function () {
80
+ it('should not throw an exception', async function () {
81
+ await loki.deinit();
82
+ });
79
83
  });
80
- });
81
84
 
82
- describe('reinitialization', () => {
83
- it('should not throw an exception', async function () {
84
- await loki.init();
85
+ describe('reinitialization', () => {
86
+ it('should not throw an exception', async function () {
87
+ await loki.init();
88
+ });
85
89
  });
86
- });
87
-
88
- describe('.destroy()', function () {
89
- it('should not throw an exception', async function () {
90
- await loki.destroy();
91
- this.node.db = lastNodeDb;
90
+
91
+ describe('.destroy()', function () {
92
+ it('should not throw an exception', async function () {
93
+ await loki.destroy();
94
+ this.node.db = lastNodeDb;
95
+ });
92
96
  });
93
97
  });
94
- });
98
+ }
package/test/group.js CHANGED
@@ -1,168 +1,173 @@
1
- const assert = require('chai').assert;
2
- const fse = require('fs-extra');
3
- const path = require('path');
4
- const Node = require('../src/node')();
5
- const Client = require('../src/client')();
6
- const utils = require('../src/utils');
7
- const tools = require('./tools');
8
-
9
- describe('group communication', () => {
10
- let nodes;
11
- let client;
12
- let filePath;
13
- let duplicates;
14
- let fileStoringNodeTimeout;
15
-
16
- before(async () => {
17
- nodes = [];
18
- fileStoringNodeTimeout = 1000;
19
-
20
- for(let i = 0; i < 4; i++) {
21
- const node = new Node(await tools.createNodeOptions({ request: { fileStoringNodeTimeout } }));
22
- await node.init();
23
- nodes.push(node);
24
- node.initialNetworkAddress = nodes[0].address;
25
- }
26
-
27
- client = new Client(await tools.createClientOptions({ address: nodes[0].address }));
28
- await client.init();
29
- await tools.nodesSync(nodes, nodes.length * 3);
30
- filePath = path.join(tools.tmpPath, 'audio.mp3');
31
- duplicates = await nodes[0].getFileDuplicatesCount();
32
- });
33
-
34
- after(async () => {
35
- for(let i = 0; i < nodes.length; i++) {
36
- await nodes[i].deinit();
37
- }
38
- });
39
-
40
- it('should get the right network size', async () => {
41
- for(let i = 0; i < nodes.length; i++) {
42
- assert.equal(await nodes[i].getNetworkSize(), nodes.length);
43
- }
44
- });
45
-
46
- it('should add the song', async () => {
47
- const title = 'artist - title';
48
- await utils.setSongTags(filePath, { fullTitle: title });
49
- await client.addSong(filePath);
50
- await tools.wait(fileStoringNodeTimeout);
51
- let count = 0;
52
-
53
- for(let i = 0; i < nodes.length; i++) {
54
- const node = nodes[i];
55
- const doc = await node.db.getMusicByPk(title);
56
- doc && await node.hasFile(doc.fileHash) && count++;
57
- }
58
-
59
- assert.equal(count, duplicates);
60
- });
61
-
62
- it('should not add the existent songs again', async () => {
63
- const title = 'artist - title';
64
- await utils.setSongTags(filePath, { fullTitle: title });
65
- await client.addSong(filePath);
66
- await tools.wait(fileStoringNodeTimeout);
67
- let count = 0;
68
-
69
- for(let i = 0; i < nodes.length; i++) {
70
- const node = nodes[i];
71
- const doc = await node.db.getMusicByPk(title);
72
- doc && await node.hasFile(doc.fileHash) && count++;
73
- }
74
-
75
- assert.equal(count, duplicates);
76
- });
77
-
78
- it('should not add the similar songs again', async () => {
79
- const title = 'artists - title';
80
- await utils.setSongTags(filePath, { fullTitle: title });
81
- await client.addSong(filePath);
82
- await tools.wait(fileStoringNodeTimeout);
83
- let count = 0;
84
-
85
- for(let i = 0; i < nodes.length; i++) {
86
- const node = nodes[i];
87
- const doc = await node.db.getMusicByPk(title);
88
- doc && await node.hasFile(doc.fileHash) && count++;
89
- }
90
-
91
- assert.equal(count, duplicates);
92
- });
1
+ import { assert } from "chai";
2
+ import fse from "fs-extra";
3
+ import path from "path";
4
+ import node from "../src/node.js";
5
+ import client from "../src/client.js";
6
+ import utils from "../src/utils.js";
7
+ import tools from "./tools.js";
8
+
9
+ const Node = node();
10
+ const Client = client();
11
+
12
+ export default function () {
13
+ describe('group communication', () => {
14
+ let nodes;
15
+ let client;
16
+ let filePath;
17
+ let duplicates;
18
+ let fileStoringNodeTimeout;
19
+
20
+ before(async () => {
21
+ nodes = [];
22
+ fileStoringNodeTimeout = 1000;
23
+
24
+ for (let i = 0; i < 4; i++) {
25
+ const node = new Node(await tools.createNodeOptions({ request: { fileStoringNodeTimeout } }));
26
+ await node.init();
27
+ nodes.push(node);
28
+ node.initialNetworkAddress = nodes[0].address;
29
+ }
30
+
31
+ client = new Client(await tools.createClientOptions({ address: nodes[0].address }));
32
+ await client.init();
33
+ await tools.nodesSync(nodes, nodes.length * 3);
34
+ filePath = path.join(tools.tmpPath, 'audio.mp3');
35
+ duplicates = await nodes[0].getFileDuplicatesCount();
36
+ });
37
+
38
+ after(async () => {
39
+ for (let i = 0; i < nodes.length; i++) {
40
+ await nodes[i].deinit();
41
+ }
42
+ });
93
43
 
94
- it('should add the necessary count of duplicates', async () => {
95
- const title = 'artist - title';
44
+ it('should get the right network size', async () => {
45
+ for (let i = 0; i < nodes.length; i++) {
46
+ assert.equal(await nodes[i].getNetworkSize(), nodes.length);
47
+ }
48
+ });
49
+
50
+ it('should add the song', async () => {
51
+ const title = 'artist - title';
52
+ await utils.setSongTags(filePath, { fullTitle: title });
53
+ await client.addSong(filePath);
54
+ await tools.wait(fileStoringNodeTimeout);
55
+ let count = 0;
56
+
57
+ for (let i = 0; i < nodes.length; i++) {
58
+ const node = nodes[i];
59
+ const doc = await node.db.getMusicByPk(title);
60
+ doc && await node.hasFile(doc.fileHash) && count++;
61
+ }
96
62
 
97
- for(let i = 0; i < nodes.length; i++) {
98
- const node = nodes[i];
99
- const doc = await node.db.getMusicByPk(title);
63
+ assert.equal(count, duplicates);
64
+ });
65
+
66
+ it('should not add the existent songs again', async () => {
67
+ const title = 'artist - title';
68
+ await utils.setSongTags(filePath, { fullTitle: title });
69
+ await client.addSong(filePath);
70
+ await tools.wait(fileStoringNodeTimeout);
71
+ let count = 0;
72
+
73
+ for (let i = 0; i < nodes.length; i++) {
74
+ const node = nodes[i];
75
+ const doc = await node.db.getMusicByPk(title);
76
+ doc && await node.hasFile(doc.fileHash) && count++;
77
+ }
100
78
 
101
- if(doc) {
102
- await node.removeFileFromStorage(doc.fileHash);
103
- break;
79
+ assert.equal(count, duplicates);
80
+ });
81
+
82
+ it('should not add the similar songs again', async () => {
83
+ const title = 'artists - title';
84
+ await utils.setSongTags(filePath, { fullTitle: title });
85
+ await client.addSong(filePath);
86
+ await tools.wait(fileStoringNodeTimeout);
87
+ let count = 0;
88
+
89
+ for (let i = 0; i < nodes.length; i++) {
90
+ const node = nodes[i];
91
+ const doc = await node.db.getMusicByPk(title);
92
+ doc && await node.hasFile(doc.fileHash) && count++;
104
93
  }
105
- }
106
94
 
107
- await client.addSong(filePath);
108
- await tools.wait(fileStoringNodeTimeout);
109
- let count = 0;
95
+ assert.equal(count, duplicates);
96
+ });
97
+
98
+ it('should add the necessary count of duplicates', async () => {
99
+ const title = 'artist - title';
100
+
101
+ for (let i = 0; i < nodes.length; i++) {
102
+ const node = nodes[i];
103
+ const doc = await node.db.getMusicByPk(title);
104
+
105
+ if (doc) {
106
+ await node.removeFileFromStorage(doc.fileHash);
107
+ break;
108
+ }
109
+ }
110
110
 
111
- for(let i = 0; i < nodes.length; i++) {
112
- const node = nodes[i];
113
- const doc = await node.db.getMusicByPk(title);
114
- doc && await node.hasFile(doc.fileHash) && count++;
115
- }
111
+ await client.addSong(filePath);
112
+ await tools.wait(fileStoringNodeTimeout);
113
+ let count = 0;
114
+
115
+ for (let i = 0; i < nodes.length; i++) {
116
+ const node = nodes[i];
117
+ const doc = await node.db.getMusicByPk(title);
118
+ doc && await node.hasFile(doc.fileHash) && count++;
119
+ }
116
120
 
117
- assert.equal(count, duplicates);
118
- });
121
+ assert.equal(count, duplicates);
122
+ });
123
+
124
+ it('should return the right links', async () => {
125
+ const info = await client.getSongInfo('artist - title');
126
+ assert.equal(info.length, duplicates);
127
+ });
128
+
129
+ it('should remove the song', async () => {
130
+ const title = 'artist - title';
131
+ await client.removeSong(title);
132
+ let count = 0;
133
+
134
+ for (let i = 0; i < nodes.length; i++) {
135
+ const node = nodes[i];
136
+ const doc = await node.db.getMusicByPk(title);
137
+ doc && await node.hasFile(doc.fileHash) && count++;
138
+ }
119
139
 
120
- it('should return the right links', async () => {
121
- const info = await client.getSongInfo('artist - title');
122
- assert.equal(info.length, duplicates);
123
- });
140
+ assert.equal(count, 0);
141
+ });
142
+
143
+ it('should add songs in parallel', async () => {
144
+ const length = 6;
145
+ const p = [];
146
+ let fCount = 0;
147
+ let dCount = 0;
148
+
149
+ for (let i = 0; i < length; i++) {
150
+ const newPath = path.join(tools.tmpPath, `audio${i}.mp3`);
151
+ await fse.copy(filePath, newPath);
152
+ const tags = { fullTitle: `${Math.random()} - ${Math.random()}` };
153
+ await utils.setSongTags(newPath, tags);
154
+ }
124
155
 
125
- it('should remove the song', async () => {
126
- const title = 'artist - title';
127
- await client.removeSong(title);
128
- let count = 0;
156
+ for (let i = 0; i < length; i++) {
157
+ p.push(client.addSong(path.join(tools.tmpPath, `audio${i}.mp3`)));
158
+ }
129
159
 
130
- for(let i = 0; i < nodes.length; i++) {
131
- const node = nodes[i];
132
- const doc = await node.db.getMusicByPk(title);
133
- doc && await node.hasFile(doc.fileHash) && count++;
134
- }
160
+ await Promise.all(p);
161
+ await tools.wait(fileStoringNodeTimeout * 2);
162
+
163
+ for (let i = 0; i < nodes.length; i++) {
164
+ const node = nodes[i];
165
+ fCount += await node.db.getData('filesCount');
166
+ dCount += await node.db.getCollectionSize('music');
167
+ }
135
168
 
136
- assert.equal(count, 0);
169
+ assert.isOk(fCount >= length * duplicates, 'check the files');
170
+ assert.isOk(dCount >= length * duplicates, 'check the documents');
171
+ });
137
172
  });
138
-
139
- it('should add songs in parallel', async () => {
140
- const length = 6;
141
- const p = [];
142
- let fCount = 0;
143
- let dCount = 0;
144
-
145
- for(let i = 0; i < length; i++) {
146
- const newPath = path.join(tools.tmpPath, `audio${i}.mp3`);
147
- await fse.copy(filePath, newPath);
148
- const tags = { fullTitle: `${ Math.random() } - ${ Math.random() }` };
149
- await utils.setSongTags(newPath, tags);
150
- }
151
-
152
- for(let i = 0; i < length; i++) {
153
- p.push(client.addSong(path.join(tools.tmpPath, `audio${i}.mp3`)));
154
- }
155
-
156
- await Promise.all(p);
157
- await tools.wait(fileStoringNodeTimeout * 2);
158
-
159
- for(let i = 0; i < nodes.length; i++) {
160
- const node = nodes[i];
161
- fCount += await node.db.getData('filesCount');
162
- dCount += await node.db.getCollectionSize('music');
163
- }
164
-
165
- assert.isOk(fCount >= length * duplicates, 'check the files');
166
- assert.isOk(dCount >= length * duplicates, 'check the documents');
167
- });
168
- });
173
+ }
package/test/index.js CHANGED
@@ -1,6 +1,16 @@
1
- const fse = require('fs-extra');
2
- const path = require('path');
3
- const tools = require('./tools');
1
+ import fse from "fs-extra";
2
+ import path from "path";
3
+ import tools from "./tools.js";
4
+ import { createRequire } from 'node:module';
5
+ import utils from "./utils.js";
6
+ import node from "./node.js";
7
+
8
+ import client from "./client.js";
9
+ import services from "./services.js";
10
+ import routes from "./routes.js";
11
+ import group from "./group.js";
12
+
13
+ const require = createRequire(import.meta.url);
4
14
 
5
15
  describe('museria', () => {
6
16
  before(async () => {
@@ -9,10 +19,10 @@ describe('museria', () => {
9
19
  await fse.copy(require.resolve('./data/cover.jpg'), path.join(tools.tmpPath, 'cover.jpg'));
10
20
  });
11
21
  after(() => fse.remove(tools.tmpPath));
12
- require('./node');
13
- require('./client');
14
- require('./services');
15
- require('./routes');
16
- require('./utils');
17
- require('./group');
18
- });
22
+ describe('utils', utils.bind(this));
23
+ describe('node', node.bind(this));
24
+ describe('client', client.bind(this));
25
+ describe('services', services.bind(this));
26
+ describe('routes', routes.bind(this));
27
+ describe('group', group.bind(this));
28
+ });