@natlibfi/melinda-rest-api-commons 4.2.5 → 5.0.0-alpha.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 (69) hide show
  1. package/.github/workflows/melinda-node-tests.yml +9 -6
  2. package/dist/conversion.js +70 -0
  3. package/dist/conversion.js.map +7 -0
  4. package/dist/fix-constants.js +63 -0
  5. package/dist/fix-constants.js.map +7 -0
  6. package/dist/fix-handle-tempurns.js +83 -0
  7. package/dist/fix-handle-tempurns.js.map +7 -0
  8. package/dist/fix-strip-f884s.js +160 -0
  9. package/dist/fix-strip-f884s.js.map +7 -0
  10. package/dist/fix-utils.js +39 -0
  11. package/dist/fix-utils.js.map +7 -0
  12. package/dist/fix.js +142 -0
  13. package/dist/fix.js.map +7 -0
  14. package/dist/validation.js +19 -0
  15. package/dist/validation.js.map +7 -0
  16. package/eslint.config.js +53 -0
  17. package/package.json +23 -96
  18. package/tests/{amqp.health.spec.js → amqp.healthtest.js} +2 -2
  19. package/tests/{amqp.tests.spec.js → amqp.tests.localtest.js} +46 -46
  20. package/tests/helpers/{conversion.spec.js → conversion.test.js} +38 -25
  21. package/tests/helpers/{fix.spec.js → fix.test.js} +6 -6
  22. package/tests/helpers/{validation.spec.js → validation.test.js} +12 -9
  23. package/tests/{mongo-add-blob-size.spec.js → mongo-add-blob-size.test.js} +6 -6
  24. package/tests/{mongo-check-and-check-state.spec.js → mongo-check-and-check-state.test.js} +7 -7
  25. package/tests/{mongo-check-and-set-import-job-state.spec.js → mongo-check-and-set-import-job-state.test.js} +7 -7
  26. package/tests/{mongo-check-timeout.spec.js → mongo-check-timeout.test.js} +7 -7
  27. package/tests/{mongo-create-bulk.spec.js → mongo-create-bulk.test.js} +5 -5
  28. package/tests/{mongo-create-prio.spec.js → mongo-create-prio.test.js} +6 -6
  29. package/tests/{mongo-get-one.spec.js → mongo-get-one.test.js} +7 -7
  30. package/tests/{mongo-get-stream.spec.js → mongo-get-stream.test.js} +7 -7
  31. package/tests/{mongo-push-ids.spec.js → mongo-push-ids.test.js} +5 -5
  32. package/tests/{mongo-push-messages.spec.js → mongo-push-messages.test.js} +6 -6
  33. package/tests/{mongo-query-by-id.spec.js → mongo-query-by-id.test.js} +7 -7
  34. package/tests/{mongo-query.spec.js → mongo-query.test.js} +7 -7
  35. package/tests/{mongo-read-content.spec.js → mongo-read-content.test.js} +8 -8
  36. package/tests/{mongo-remove.spec.js → mongo-remove.test.js} +6 -6
  37. package/tests/{mongo-set-blob-size.spec.js → mongo-set-blob-size.test.js} +6 -6
  38. package/tests/{mongo-set-import-job-state.spec.js → mongo-set-import-job-state.test.js} +6 -6
  39. package/tests/{mongo-set-operation.spec.js → mongo-set-operation.test.js} +6 -6
  40. package/tests/{mongo-set-operations.spec.js → mongo-set-operations.test.js} +6 -6
  41. package/tests/{mongo-set-state.spec.js → mongo-set-state.test.js} +7 -7
  42. package/tests/{mongoLog.spec.js → mongoLog.test.js} +10 -11
  43. package/tests/testUtils.js +9 -8
  44. package/dist/amqp.js +0 -326
  45. package/dist/amqp.js.map +0 -1
  46. package/dist/constants.js +0 -60
  47. package/dist/constants.js.map +0 -1
  48. package/dist/helpers/conversion.js +0 -88
  49. package/dist/helpers/conversion.js.map +0 -1
  50. package/dist/helpers/fix-constants.js +0 -70
  51. package/dist/helpers/fix-constants.js.map +0 -1
  52. package/dist/helpers/fix-handle-tempurns.js +0 -133
  53. package/dist/helpers/fix-handle-tempurns.js.map +0 -1
  54. package/dist/helpers/fix-strip-f884s.js +0 -210
  55. package/dist/helpers/fix-strip-f884s.js.map +0 -1
  56. package/dist/helpers/fix-utils.js +0 -54
  57. package/dist/helpers/fix-utils.js.map +0 -1
  58. package/dist/helpers/fix.js +0 -202
  59. package/dist/helpers/fix.js.map +0 -1
  60. package/dist/helpers/validation.js +0 -37
  61. package/dist/helpers/validation.js.map +0 -1
  62. package/dist/index.js +0 -109
  63. package/dist/index.js.map +0 -1
  64. package/dist/mongo.js +0 -822
  65. package/dist/mongo.js.map +0 -1
  66. package/dist/mongoLog.js +0 -409
  67. package/dist/mongoLog.js.map +0 -1
  68. package/dist/utils.js +0 -211
  69. package/dist/utils.js.map +0 -1
@@ -1,20 +1,23 @@
1
1
 
2
2
 
3
- import {expect} from 'chai';
3
+ import assert from 'node:assert';
4
+ import {describe, it} from 'node:test';
4
5
  import fixtureFactory from '@natlibfi/fixura';
5
6
  import {MarcRecord} from '@natlibfi/marc-record';
6
7
  import {Error as ConversionError} from '@natlibfi/melinda-commons';
7
- import createConversionService from '../../src/helpers/conversion';
8
- import {CONVERSION_FORMATS} from '../../src/constants';
8
+ import createConversionService from '../../src/helpers/conversion.js';
9
+ import {CONVERSION_FORMATS} from '../../src/constants.js';
9
10
 
10
11
  describe('services/conversion', () => {
11
- const {getFixture} = fixtureFactory({root: [
12
- __dirname,
13
- '..',
14
- '..',
15
- 'test-fixtures',
16
- 'conversion'
17
- ]});
12
+ const {getFixture} = fixtureFactory({
13
+ root: [
14
+ import.meta.dirname,
15
+ '..',
16
+ '..',
17
+ 'test-fixtures',
18
+ 'conversion'
19
+ ]
20
+ });
18
21
  const conversionService = createConversionService();
19
22
 
20
23
  const marcRecord = new MarcRecord(JSON.parse(getFixture({components: ['json1']})), {subfieldValues: false});
@@ -27,69 +30,79 @@ describe('services/conversion', () => {
27
30
  describe('factory', () => {
28
31
  it('Should create the expected object', () => {
29
32
  const service = createConversionService();
30
- expect(service).to.be.an('object').and
31
- .respondTo('serialize')
32
- .respondTo('unserialize');
33
+ assert.equal(typeof service, 'object');
34
+ assert.equal(Object.hasOwn(service, 'serialize'), true);
35
+ assert.equal(Object.hasOwn(service, 'unserialize'), true);
33
36
  });
34
37
  });
35
38
 
36
39
  describe('#serialize', () => {
37
40
  it('Should throw because of unsupported format', () => {
38
- expect(conversionService.serialize).to.throw();
41
+ try {
42
+ conversionService.serialize();
43
+ } catch (error) {
44
+ assert(error instanceof ConversionError);
45
+ }
39
46
  });
40
47
 
41
48
  it('Should serialize to MARCXML', () => {
42
49
  const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.MARCXML);
43
- expect(data).to.equal(marcXml);
50
+ assert.equal(data, marcXml);
44
51
  });
45
52
 
46
53
  it('Should serialize to ISO2709', () => {
47
54
  const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ISO2709);
48
- expect(data).to.equal(iso2709);
55
+ assert.equal(data, iso2709);
49
56
  });
50
57
 
51
58
  it('Should serialize to JSON', () => {
52
59
  const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.JSON);
53
- expect(data).to.equal(json);
60
+ assert.equal(data, json);
54
61
  });
55
62
 
56
63
  it('Should serialize to aleph sequential', () => {
57
64
  const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ALEPHSEQ);
58
- expect(data).to.equal(alephSeq);
65
+ assert.equal(data, alephSeq);
59
66
  });
60
67
 
61
68
  });
62
69
 
63
70
  describe('#unserialize', () => {
64
71
  it('Should throw because of unsupported format', () => {
65
- expect(conversionService.unserialize).to.throw();
72
+ try {
73
+ conversionService.unserialize();
74
+ } catch (error) {
75
+ assert(error instanceof ConversionError);
76
+ }
66
77
  });
67
78
 
68
79
  it('Should unserialize from MARCXML', async () => {
69
80
  const record = await conversionService.unserialize(marcXml, CONVERSION_FORMATS.MARCXML);
70
- expect(record.equalsTo(marcRecord)).to.equal(true);
81
+ assert.equal(record.equalsTo(marcRecord), true);
71
82
  });
72
83
 
73
84
  it('Should unserialize from ISO2709', () => {
74
85
  const record = conversionService.unserialize(iso2709, CONVERSION_FORMATS.ISO2709);
75
- expect(record.equalsTo(marcRecord)).to.equal(true);
86
+ assert.equal(record.equalsTo(marcRecord), true);
76
87
  });
77
88
 
78
89
  it('Should unserialize from JSON', () => {
79
90
  const record = conversionService.unserialize(json, CONVERSION_FORMATS.JSON);
80
- expect(record.equalsTo(marcRecord)).to.equal(true);
91
+ assert.equal(record.equalsTo(marcRecord), true);
81
92
  });
82
93
 
83
94
  it('Should unserialize from Aleph sequential', () => {
84
95
  const record = conversionService.unserialize(alephSeq, CONVERSION_FORMATS.ALEPHSEQ);
85
- expect(record.equalsTo(marcRecord)).to.equal(true);
96
+ assert.equal(record.equalsTo(marcRecord), true);
86
97
  });
87
98
 
88
99
 
89
100
  it('Should throw because the record could not be unserialized', () => {
90
- expect(() => {
101
+ try {
91
102
  conversionService.unserialize('', CONVERSION_FORMATS.JSON);
92
- }).to.throw(ConversionError);
103
+ } catch (error) {
104
+ assert(error instanceof ConversionError);
105
+ }
93
106
  });
94
107
  });
95
108
  });
@@ -1,10 +1,10 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
+ import createDebugLogger from 'debug';
2
3
  import {MarcRecord} from '@natlibfi/marc-record';
3
4
  import {READERS} from '@natlibfi/fixura';
4
5
  import generateTests from '@natlibfi/fixugen';
5
- import {fixRecord} from '../../src/helpers/fix';
6
- import * as fixSettings from '../../src/helpers/fix-constants';
7
- import createDebugLogger from 'debug';
6
+ import {fixRecord} from '../../src/helpers/fix.js';
7
+ import * as fixSettings from '../../src/helpers/fix-constants.js';
8
8
  // import inspect from 'util';
9
9
 
10
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fix:test');
@@ -12,7 +12,7 @@ const debugData = debug.extend('data');
12
12
 
13
13
  generateTests({
14
14
  callback,
15
- path: [__dirname, '..', '..', 'test-fixtures', 'fix'],
15
+ path: [import.meta.dirname, '..', '..', 'test-fixtures', 'fix'],
16
16
  recurse: true,
17
17
  useMetadataFile: true,
18
18
  fixura: {
@@ -36,6 +36,6 @@ function callback({getFixture, settings = undefined}) {
36
36
  const resultRecord = fixRecord(record, runSettings);
37
37
  debugData(`Result: ${JSON.stringify(resultRecord)}`);
38
38
  debugData(`Expected: ${JSON.stringify(expectedRecord)}`);
39
- expect(resultRecord).to.eql(expectedRecord);
39
+ assert.deepStrictEqual(resultRecord, expectedRecord);
40
40
 
41
41
  }
@@ -1,11 +1,12 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
+ import {describe, it} from 'node:test';
2
3
  import fixtureFactory, {READERS} from '@natlibfi/fixura';
3
4
  import {MarcRecord} from '@natlibfi/marc-record';
4
- import createValidator from '../../src/helpers/validation';
5
+ import createValidator from '../../src/helpers/validation.js';
5
6
 
6
7
  describe('services/validate', () => {
7
8
  const FIXTURES_PATH = [
8
- __dirname,
9
+ import.meta.dirname,
9
10
  '..',
10
11
  '..',
11
12
  'test-fixtures',
@@ -23,14 +24,15 @@ describe('services/validate', () => {
23
24
  ]
24
25
  }));
25
26
  const result = await validator(record.toObject());
26
- const expected = getFixture({
27
+ const {record: expectedRecord, ...rest} = getFixture({
27
28
  components: [
28
29
  'out',
29
30
  'f003-fi-melinda.json'
30
31
  ]
31
32
  });
32
- expect(result).to.eql(expected);
33
- expect(result.failed).to.equal(false);
33
+ const {_validationOptions, ...expectedRecordData} = expectedRecord;
34
+ assert.deepStrictEqual(result, {...rest, record: new MarcRecord(expectedRecordData, _validationOptions)});
35
+ assert.equal(result.failed, false);
34
36
  });
35
37
  });
36
38
 
@@ -44,14 +46,15 @@ describe('services/validate', () => {
44
46
  ]
45
47
  }));
46
48
  const result = await validator(record.toObject());
47
- const expected = getFixture({
49
+ const {record: expectedRecord, ...rest} = getFixture({
48
50
  components: [
49
51
  'out',
50
52
  'f003-not-fi-melinda.json'
51
53
  ]
52
54
  });
53
- expect(result).to.eql(expected);
54
- expect(result.failed).to.equal(true);
55
+ const {_validationOptions, ...expectedRecordData} = expectedRecord;
56
+ assert.deepStrictEqual(result, {...rest, record: new MarcRecord(expectedRecordData, _validationOptions)});
57
+ assert.equal(result.failed, true);
55
58
  });
56
59
  });
57
60
  });
@@ -1,10 +1,10 @@
1
- //import {expect} from 'chai';
1
+ //import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
8
8
 
9
9
 
10
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:add-bl
12
12
 
13
13
  generateTests({
14
14
  callback,
15
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
15
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
16
16
  recurse: false,
17
17
  useMetadataFile: true,
18
18
  fixura: {
19
19
  failWhenNotFound: true,
20
20
  reader: READERS.JSON
21
21
  },
22
- mocha: {
22
+ hooks: {
23
23
  before: async () => {
24
24
  //debug(`<< Before`);
25
25
  await initMongofixtures();
@@ -42,7 +42,7 @@ generateTests({
42
42
  async function initMongofixtures() {
43
43
  mongoFixtures = await mongoFixturesFactory({
44
44
  recurse: false,
45
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
45
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
46
46
  gridFS: {bucketName: 'foobar'},
47
47
  useObjectId: true
48
48
  });
@@ -1,10 +1,10 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
8
8
 
9
9
 
10
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test')
12
12
 
13
13
  generateTests({
14
14
  callback,
15
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
15
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
16
16
  recurse: false,
17
17
  useMetadataFile: true,
18
18
  fixura: {
19
19
  failWhenNotFound: true,
20
20
  reader: READERS.JSON
21
21
  },
22
- mocha: {
22
+ hooks: {
23
23
  before: async () => {
24
24
  //debug(`<< Before`);
25
25
  await initMongofixtures();
@@ -42,7 +42,7 @@ generateTests({
42
42
  async function initMongofixtures() {
43
43
  mongoFixtures = await mongoFixturesFactory({
44
44
  recurse: false,
45
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
45
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
46
46
  gridFS: {bucketName: 'foobar'},
47
47
  useObjectId: true
48
48
  });
@@ -91,7 +91,7 @@ async function callback({
91
91
 
92
92
  // eslint-disable-next-line functional/no-conditional-statements
93
93
  if (expectedOpResult !== undefined) {
94
- expect(opResult).to.eql(expectedOpResult);
94
+ assert.deepStrictEqual(opResult, expectedOpResult);
95
95
  }
96
96
  await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
97
97
 
@@ -1,24 +1,24 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
8
8
 
9
9
  let mongoFixtures; // eslint-disable-line functional/no-let
10
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:check-and-set-import-job-state-test');
11
11
 
12
12
  generateTests({
13
13
  callback,
14
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
14
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
15
15
  recurse: false,
16
16
  useMetadataFile: true,
17
17
  fixura: {
18
18
  failWhenNotFound: true,
19
19
  reader: READERS.JSON
20
20
  },
21
- mocha: {
21
+ hooks: {
22
22
  before: async () => {
23
23
  //debug(`<< Before`);
24
24
  await initMongofixtures();
@@ -41,7 +41,7 @@ generateTests({
41
41
  async function initMongofixtures() {
42
42
  mongoFixtures = await mongoFixturesFactory({
43
43
  recurse: false,
44
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
44
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
45
45
  gridFS: {bucketName: 'foobar'},
46
46
  useObjectId: true
47
47
  });
@@ -91,7 +91,7 @@ async function callback({
91
91
 
92
92
  // eslint-disable-next-line functional/no-conditional-statements
93
93
  if (expectedOpResult !== undefined) {
94
- expect(opResult).to.eql(expectedOpResult);
94
+ assert.deepStrictEqual(opResult, expectedOpResult);
95
95
  }
96
96
  await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
97
97
  } catch (error) {
@@ -1,10 +1,10 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
8
8
 
9
9
 
10
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:check-
12
12
 
13
13
  generateTests({
14
14
  callback,
15
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
15
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
16
16
  recurse: false,
17
17
  useMetadataFile: true,
18
18
  fixura: {
19
19
  failWhenNotFound: true,
20
20
  reader: READERS.JSON
21
21
  },
22
- mocha: {
22
+ hooks: {
23
23
  before: async () => {
24
24
  //debug(`<< Before`);
25
25
  await initMongofixtures();
@@ -42,7 +42,7 @@ generateTests({
42
42
  async function initMongofixtures() {
43
43
  mongoFixtures = await mongoFixturesFactory({
44
44
  recurse: false,
45
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
45
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
46
46
  gridFS: {bucketName: 'foobar'},
47
47
  useObjectId: true
48
48
  });
@@ -91,7 +91,7 @@ async function callback({
91
91
 
92
92
  // eslint-disable-next-line functional/no-conditional-statements
93
93
  if (expectedOpResult !== undefined) {
94
- expect(opResult).to.eql(expectedOpResult);
94
+ assert.deepStrictEqual(opResult, expectedOpResult);
95
95
  }
96
96
  await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
97
97
  } catch (error) {
@@ -2,22 +2,22 @@ import {READERS} from '@natlibfi/fixura';
2
2
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
3
3
  import generateTests from '@natlibfi/fixugen';
4
4
  import createDebugLogger from 'debug';
5
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
6
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
5
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
7
7
 
8
8
  let mongoFixtures; // eslint-disable-line functional/no-let
9
9
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test:create-bulk');
10
10
 
11
11
  generateTests({
12
12
  callback,
13
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
13
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
14
14
  recurse: false,
15
15
  useMetadataFile: true,
16
16
  fixura: {
17
17
  failWhenNotFound: true,
18
18
  reader: READERS.JSON
19
19
  },
20
- mocha: {
20
+ hooks: {
21
21
  before: async () => {
22
22
  //debug(`<< Before`);
23
23
  await initMongofixtures();
@@ -40,7 +40,7 @@ generateTests({
40
40
  async function initMongofixtures() {
41
41
  mongoFixtures = await mongoFixturesFactory({
42
42
  recurse: false,
43
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
43
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
44
44
  gridFS: {bucketName: 'foobar'},
45
45
  useObjectId: true
46
46
  });
@@ -1,24 +1,24 @@
1
- //import {expect} from 'chai';
1
+ //import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
7
- // import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
7
+ // import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
8
8
 
9
9
  let mongoFixtures; // eslint-disable-line functional/no-let
10
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:create-prio-test');
11
11
 
12
12
  generateTests({
13
13
  callback,
14
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
14
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
15
15
  recurse: false,
16
16
  useMetadataFile: true,
17
17
  fixura: {
18
18
  failWhenNotFound: true,
19
19
  reader: READERS.JSON
20
20
  },
21
- mocha: {
21
+ hooks: {
22
22
  before: async () => {
23
23
  //debug(`<< Before`);
24
24
  await initMongofixtures();
@@ -41,7 +41,7 @@ generateTests({
41
41
  async function initMongofixtures() {
42
42
  mongoFixtures = await mongoFixturesFactory({
43
43
  recurse: false,
44
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
44
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
45
45
  gridFS: {bucketName: 'foobar'},
46
46
  useObjectId: true
47
47
  });
@@ -1,10 +1,10 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError} from './testUtils.js';
8
8
 
9
9
 
10
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:get-on
12
12
 
13
13
  generateTests({
14
14
  callback,
15
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'get-one'],
15
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'get-one'],
16
16
  recurse: false,
17
17
  useMetadataFile: true,
18
18
  fixura: {
19
19
  failWhenNotFound: true,
20
20
  reader: READERS.JSON
21
21
  },
22
- mocha: {
22
+ hooks: {
23
23
  before: async () => {
24
24
  //debug(`<< Before`);
25
25
  await initMongofixtures();
@@ -42,7 +42,7 @@ generateTests({
42
42
  async function initMongofixtures() {
43
43
  mongoFixtures = await mongoFixturesFactory({
44
44
  recurse: false,
45
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'get-one'],
45
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'get-one'],
46
46
  gridFS: {bucketName: 'foobar'},
47
47
  useObjectId: true
48
48
  });
@@ -81,7 +81,7 @@ async function callback({
81
81
  const opResult = await mongoOperator.getOne(params);
82
82
  debug(`getOne result: ${JSON.stringify(opResult)} (it should be: ${JSON.stringify(expectedOpResult)})}`);
83
83
 
84
- expect(opResult).to.eql(expectedOpResult);
84
+ assert.deepStrictEqual(opResult, expectedOpResult);
85
85
 
86
86
  } catch (error) {
87
87
  handleError({error, expectedToThrow, expectedErrorMessage, expectedErrorStatus});
@@ -1,24 +1,24 @@
1
- import {expect} from 'chai';
1
+ import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, streamToString} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, streamToString} from './testUtils.js';
8
8
 
9
9
  let mongoFixtures; // eslint-disable-line functional/no-let
10
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:get-stream:test');
11
11
 
12
12
  generateTests({
13
13
  callback,
14
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'get-stream'],
14
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'get-stream'],
15
15
  recurse: false,
16
16
  useMetadataFile: true,
17
17
  fixura: {
18
18
  failWhenNotFound: true,
19
19
  reader: READERS.JSON
20
20
  },
21
- mocha: {
21
+ hooks: {
22
22
  before: async () => {
23
23
  //debug(`<< Before`);
24
24
  await initMongofixtures();
@@ -41,7 +41,7 @@ generateTests({
41
41
  async function initMongofixtures() {
42
42
  mongoFixtures = await mongoFixturesFactory({
43
43
  recurse: false,
44
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'get-stream'],
44
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'get-stream'],
45
45
  gridFS: {bucketName: 'foobar'},
46
46
  useObjectId: true
47
47
  });
@@ -96,7 +96,7 @@ async function callback({
96
96
  if (contentStream) {
97
97
  const contentStreamString = await getFixture({components: ['contentStream'], reader: READERS.TEXT});
98
98
  //debug(contentStreamString);
99
- expect(opResultString).to.eql(contentStreamString);
99
+ assert.equal(opResultString, contentStreamString);
100
100
  return;
101
101
  }
102
102
 
@@ -2,8 +2,8 @@ import {READERS} from '@natlibfi/fixura';
2
2
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
3
3
  import generateTests from '@natlibfi/fixugen';
4
4
  import createDebugLogger from 'debug';
5
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
6
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
5
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
7
7
 
8
8
 
9
9
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -11,14 +11,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:push-i
11
11
 
12
12
  generateTests({
13
13
  callback,
14
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'push-ids'],
14
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'push-ids'],
15
15
  recurse: false,
16
16
  useMetadataFile: true,
17
17
  fixura: {
18
18
  failWhenNotFound: true,
19
19
  reader: READERS.JSON
20
20
  },
21
- mocha: {
21
+ hooks: {
22
22
  before: async () => {
23
23
  //debug(`<< Before`);
24
24
  await initMongofixtures();
@@ -41,7 +41,7 @@ generateTests({
41
41
  async function initMongofixtures() {
42
42
  mongoFixtures = await mongoFixturesFactory({
43
43
  recurse: false,
44
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'push-ids'],
44
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'push-ids'],
45
45
  gridFS: {bucketName: 'foobar'},
46
46
  useObjectId: true
47
47
  });
@@ -1,24 +1,24 @@
1
- //import {expect} from 'chai';
1
+ //import assert from 'node:assert';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
5
  import createDebugLogger from 'debug';
6
- //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
6
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
8
8
 
9
9
  let mongoFixtures; // eslint-disable-line functional/no-let
10
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:push-messages:test');
11
11
 
12
12
  generateTests({
13
13
  callback,
14
- path: [__dirname, '..', 'test-fixtures', 'mongo', 'push-messages'],
14
+ path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'push-messages'],
15
15
  recurse: false,
16
16
  useMetadataFile: true,
17
17
  fixura: {
18
18
  failWhenNotFound: true,
19
19
  reader: READERS.JSON
20
20
  },
21
- mocha: {
21
+ hooks: {
22
22
  before: async () => {
23
23
  //debug(`<< Before`);
24
24
  await initMongofixtures();
@@ -41,7 +41,7 @@ generateTests({
41
41
  async function initMongofixtures() {
42
42
  mongoFixtures = await mongoFixturesFactory({
43
43
  recurse: false,
44
- rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'push-messages'],
44
+ rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'push-messages'],
45
45
  gridFS: {bucketName: 'foobar'},
46
46
  useObjectId: true
47
47
  });