Skip to content

Commit b51b957

Browse files
Copilotrubensworks
andauthored
Fix lint and test failures: eslint-disable for jest mocks, path normalization, missing logger.error, async build mock
Agent-Logs-Url: https://github.com/LinkedSoftwareDependencies/Components.js/sessions/06c889bf-188e-4910-9936-09a22f958cee Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
1 parent be4d8a7 commit b51b957

9 files changed

Lines changed: 15 additions & 7 deletions

test/integration/instantiateFile-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const quad = require('rdf-quad');
1010
// eslint-disable-next-line jest/no-mocks-import
1111
const Hello = require('../../__mocks__/helloworld').Hello;
1212

13+
// eslint-disable-next-line jest/no-untyped-mock-factory
1314
jest.mock('winston', () => ({
1415
format: {
1516
colorize: jest.fn(),
@@ -21,6 +22,7 @@ jest.mock('winston', () => ({
2122
createLogger: jest.fn().mockReturnValue({
2223
warn: jest.fn(),
2324
info: jest.fn(),
25+
error: jest.fn(),
2426
}),
2527
transports: {
2628
Console: jest.fn(),

test/integration/instantiateResourceConfigComponent-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IRIS_OO } from '../../lib/rdf/Iris';
88

99
const N3 = require('n3');
1010

11+
// eslint-disable-next-line jest/no-untyped-mock-factory
1112
jest.mock('n3', () => ({
1213
Lexer: jest.fn((args: any) => ({ type: 'LEXER', args })),
1314
Parser: jest.fn((args: any) => ({ type: 'PARSER', args })),

test/integration/instantiateResourceConfigComponentMapped-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IRIS_OO } from '../../lib/rdf/Iris';
88

99
const N3 = require('n3');
1010

11+
// eslint-disable-next-line jest/no-untyped-mock-factory
1112
jest.mock('n3', () => ({
1213
Lexer: jest.fn((args: any) => ({ type: 'LEXER', args })),
1314
Parser: jest.fn((args: any) => ({ type: 'PARSER', args })),

test/integration/instantiateResourceConfigRaw-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { IConstructionSettings } from '../../lib/construction/IConstruction
66

77
const N3 = require('n3');
88

9+
// eslint-disable-next-line jest/no-untyped-mock-factory
910
jest.mock('n3', () => ({
1011
Lexer: jest.fn((args: any) => ({ type: 'LEXER', args })),
1112
Parser: jest.fn((args: any) => ({ type: 'PARSER', args })),

test/unit/construction/ConfigConstructor-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('ConfigConstructor', () => {
104104
undefined: '"true"',
105105
});
106106
await expect(constructor.getArgumentValue(resource, settings)).resolves.toBeUndefined();
107-
expect(constructionStrategy.createUndefined).toHaveBeenCalled();
107+
expect(constructionStrategy.createUndefined).toHaveBeenCalledWith();
108108
});
109109
});
110110

test/unit/loading/ComponentsManager-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jest.mock<typeof import('fs')>('fs', () => ({
1313
...jest.requireActual<typeof fs>('fs'),
1414
writeFileSync: jest.fn(),
1515
}));
16-
// eslint-disable-next-line max-len
16+
// eslint-disable-next-line jest/no-untyped-mock-factory
1717
jest.mock('../../../lib/loading/ComponentsManagerBuilder', () => ({
1818
// eslint-disable-next-line object-shorthand
1919
ComponentsManagerBuilder: function(args: any) {
2020
return {
21-
build: jest.fn(() => ({
21+
build: jest.fn(async() => ({
2222
type: 'INSTANCE',
2323
args,
2424
})),
@@ -113,7 +113,7 @@ describe('ComponentsManager', () => {
113113
moduleState: {
114114
mainModulePath,
115115
componentModules: {
116-
A: `${mainModulePath}/../../assets/module.jsonld`,
116+
A: Path.join(mainModulePath, '../../assets/module.jsonld'),
117117
},
118118
nodeModulePaths: [],
119119
},
@@ -166,7 +166,7 @@ describe('ComponentsManager', () => {
166166
moduleState: {
167167
mainModulePath,
168168
componentModules: {
169-
A: `${mainModulePath}/../../assets/module.jsonld`,
169+
A: Path.join(mainModulePath, '../../assets/module.jsonld'),
170170
},
171171
nodeModulePaths: [],
172172
},

test/unit/loading/ComponentsManagerBuilder-test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ConfigPreprocessorComponentMapped } from '../../../lib/preprocess/Confi
1313
import { ConfigPreprocessorOverride } from '../../../lib/preprocess/ConfigPreprocessorOverride';
1414

1515
const mainModulePath = __dirname;
16+
// eslint-disable-next-line jest/no-untyped-mock-factory
1617
jest.mock('winston', () => ({
1718
createLogger: jest.fn(() => ({
1819
info: jest.fn(),
@@ -41,7 +42,8 @@ const dummyModuleState = {
4142
},
4243
nodeModulePaths: [],
4344
};
44-
jest.mock<typeof import('../../../lib/loading/ModuleStateBuilder')>('../../../lib/loading/ModuleStateBuilder', () => ({
45+
// eslint-disable-next-line jest/no-untyped-mock-factory
46+
jest.mock('../../../lib/loading/ModuleStateBuilder', () => ({
4547
// eslint-disable-next-line object-shorthand
4648
ModuleStateBuilder: function() {
4749
return {

test/unit/loading/ModuleStateBuilder-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ModuleStateBuilder } from '../../../lib/loading/ModuleStateBuilder';
44
// Import syntax only works in Node > 12
55
const fs = require('node:fs').promises;
66

7+
// eslint-disable-next-line jest/no-untyped-mock-factory
78
jest.mock('fs', () => ({
89
promises: {
910
realpath: jest.fn(),

test/unit/preprocess/parameterproperty/ParameterPropertyHandlerRange-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2911,7 +2911,7 @@ describe('ParameterPropertyHandlerRange', () => {
29112911
objectLoader.createCompactedResource('ex:param'),
29122912
genericsContext,
29132913
conflict,
2914-
)).toThrow(`The value "ex:value" with types "ex:Type1,ex:Type2" for parameter "ex:param" is not of required range type "any"`);
2914+
)).toThrow(`The value "ex:value" with types "ex:Type1, ex:Type2" for parameter "ex:param" is not of required range type "any"`);
29152915
});
29162916

29172917
it('handles a defined list value', () => {

0 commit comments

Comments
 (0)