diff --git a/projects/aas-server/src/app/live/http/http-socket-item.ts b/projects/aas-server/src/app/live/http/http-socket-item.ts index 9710f5de..5172914d 100644 --- a/projects/aas-server/src/app/live/http/http-socket-item.ts +++ b/projects/aas-server/src/app/live/http/http-socket-item.ts @@ -7,8 +7,8 @@ *****************************************************************************/ import { LiveNode } from 'common'; -import { SocketItem } from '../socket-item.js'; import { noop } from 'lodash-es'; +import { SocketItem } from '../socket-item.js'; export class HttpSocketItem implements SocketItem { public constructor( diff --git a/projects/aas-server/src/test/application-info.spec.ts b/projects/aas-server/src/test/application-info.spec.ts index a67f62a1..1fc2d21e 100644 --- a/projects/aas-server/src/test/application-info.spec.ts +++ b/projects/aas-server/src/test/application-info.spec.ts @@ -30,4 +30,4 @@ describe('Application Info service', () => { const expected: PackageInfo = JSON.parse((await readFile(file)).toString()); await expect(applicationInfo.getAsync(file)).resolves.toEqual(expected); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/configuration.spec.ts b/projects/aas-server/src/test/configuration.spec.ts index e011e354..2376599d 100644 --- a/projects/aas-server/src/test/configuration.spec.ts +++ b/projects/aas-server/src/test/configuration.spec.ts @@ -6,8 +6,8 @@ * *****************************************************************************/ -import { getEndpointName, getEndpointType } from "../app/configuration.js"; -import { describe, it, expect } from '@jest/globals' +import { getEndpointName, getEndpointType } from '../app/configuration.js'; +import { describe, it, expect } from '@jest/globals'; describe('configuration', function () { describe('getEndpointName', function () { @@ -24,13 +24,15 @@ describe('configuration', function () { }); it('gets the default name of an AAS registry', function () { - expect(getEndpointName('http://localhost:1234/v1/registry?type=AASRegistry')) - .toEqual('http://localhost:1234/v1/registry'); + expect(getEndpointName('http://localhost:1234/v1/registry?type=AASRegistry')).toEqual( + 'http://localhost:1234/v1/registry', + ); }); it('gets the default name of an OPCUA server', function () { - expect(getEndpointName(new URL('opc.tcp://172.16.160.178:30001/I4AASServer'))) - .toEqual('opc.tcp://172.16.160.178:30001/I4AASServer'); + expect(getEndpointName(new URL('opc.tcp://172.16.160.178:30001/I4AASServer'))).toEqual( + 'opc.tcp://172.16.160.178:30001/I4AASServer', + ); }); it('gets the default name of an AASX directory', function () { @@ -51,4 +53,4 @@ describe('configuration', function () { expect(getEndpointType('http://localhost:1234/')).toEqual('AasxServer'); }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/controller/endpoints-controller.spec.ts b/projects/aas-server/src/test/controller/endpoints-controller.spec.ts index 4b363ba0..c910d5f3 100644 --- a/projects/aas-server/src/test/controller/endpoints-controller.spec.ts +++ b/projects/aas-server/src/test/controller/endpoints-controller.spec.ts @@ -35,23 +35,21 @@ describe('EndpointsController', function () { beforeEach(function () { logger = createSpyObj(['error', 'warning', 'info', 'debug', 'start', 'stop']); variable = createSpyObj({}, { JWT_SECRET: 'SecretSecretSecretSecretSecretSecret' }); - auth = createSpyObj( - [ - 'hasUserAsync', - 'loginAsync', - 'getCookieAsync', - 'getCookiesAsync', - 'setCookieAsync', - 'deleteCookieAsync' - ]); - - aasProvider = createSpyObj( - [ - 'getEndpoints', - 'addEndpointAsync', - 'removeEndpointAsync', - 'resetAsync', - ]); + auth = createSpyObj([ + 'hasUserAsync', + 'loginAsync', + 'getCookieAsync', + 'getCookiesAsync', + 'setCookieAsync', + 'deleteCookieAsync', + ]); + + aasProvider = createSpyObj([ + 'getEndpoints', + 'addEndpointAsync', + 'removeEndpointAsync', + 'resetAsync', + ]); authentication = createSpyObj(['checkAsync']); authentication.checkAsync.mockResolvedValue(guestPayload); @@ -76,13 +74,11 @@ describe('EndpointsController', function () { const endpoints: AASEndpoint = { name: 'Test', url: 'http://localhost:1234', - type: 'AasxServer' + type: 'AasxServer', }; aasProvider.getEndpoints.mockResolvedValue([endpoints]); - const response = await request(app) - .get('/api/v1/endpoints') - .set('Authorization', `Bearer ${getToken()}`); + const response = await request(app).get('/api/v1/endpoints').set('Authorization', `Bearer ${getToken()}`); expect(response.statusCode).toBe(200); expect(response.body).toEqual([endpoints]); @@ -93,7 +89,8 @@ describe('EndpointsController', function () { const endpoint: AASEndpoint = { name: 'Samples', url: 'file:///assets/samples', type: 'AasxDirectory' }; aasProvider.addEndpointAsync.mockResolvedValue(); auth.hasUserAsync.mockResolvedValue(true); - const response = await request(app).post('/api/v1/endpoints/samples') + const response = await request(app) + .post('/api/v1/endpoints/samples') .set('Authorization', `Bearer ${getToken('John')}`) .send(endpoint); @@ -122,4 +119,4 @@ describe('EndpointsController', function () { expect(response.statusCode).toBe(204); expect(aasProvider.resetAsync).toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/controller/templates-controller.spec.ts b/projects/aas-server/src/test/controller/templates-controller.spec.ts index 9e941c71..e527fe53 100644 --- a/projects/aas-server/src/test/controller/templates-controller.spec.ts +++ b/projects/aas-server/src/test/controller/templates-controller.spec.ts @@ -35,18 +35,16 @@ describe('TemplateController', function () { beforeEach(function () { logger = createSpyObj(['error', 'warning', 'info', 'debug', 'start', 'stop']); variable = createSpyObj({}, { JWT_SECRET: 'SecretSecretSecretSecretSecretSecret' }); - auth = createSpyObj( - [ - 'hasUserAsync', - 'loginAsync', - 'getCookieAsync', - 'getCookiesAsync', - 'setCookieAsync', - 'deleteCookieAsync' - ]); + auth = createSpyObj([ + 'hasUserAsync', + 'loginAsync', + 'getCookieAsync', + 'getCookiesAsync', + 'setCookieAsync', + 'deleteCookieAsync', + ]); templateStorage = createSpyObj(['readAsync']); - authentication = createSpyObj(['checkAsync']); authentication.checkAsync.mockResolvedValue(guestPayload); @@ -68,13 +66,11 @@ describe('TemplateController', function () { it('getTemplates: /api/v1/templates', async function () { const templates: TemplateDescriptor[] = [{ name: 'TestTemplate' }]; - templateStorage.readAsync.mockReturnValue(new Promise(resolve => resolve(templates))); - const response = await request(app) - .get('/api/v1/templates') - .set('Authorization', `Bearer ${getToken()}`); + templateStorage.readAsync.mockResolvedValue(templates); + const response = await request(app).get('/api/v1/templates').set('Authorization', `Bearer ${getToken()}`); - expect(response.statusCode).toBe(200) + expect(response.statusCode).toBe(200); expect(response.body).toEqual(templates); expect(templateStorage.readAsync).toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/convert.spec.ts b/projects/aas-server/src/test/convert.spec.ts index c688d73f..b4aeaeb6 100644 --- a/projects/aas-server/src/test/convert.spec.ts +++ b/projects/aas-server/src/test/convert.spec.ts @@ -12,15 +12,17 @@ import { describe, it, expect } from '@jest/globals'; describe('convert', () => { describe('atob', () => { it('converts ascii to base64', () => { - expect(encodeBase64Url('https://iosb-ina.fraunhofer.de/ids/aas/5174_7001_0122_9237')) - .toEqual('aHR0cHM6Ly9pb3NiLWluYS5mcmF1bmhvZmVyLmRlL2lkcy9hYXMvNTE3NF83MDAxXzAxMjJfOTIzNw'); + expect(encodeBase64Url('https://iosb-ina.fraunhofer.de/ids/aas/5174_7001_0122_9237')).toEqual( + 'aHR0cHM6Ly9pb3NiLWluYS5mcmF1bmhvZmVyLmRlL2lkcy9hYXMvNTE3NF83MDAxXzAxMjJfOTIzNw', + ); }); }); describe('btoa', () => { it('converts base64 to ascii', () => { - expect(decodeBase64Url('aHR0cHM6Ly9pb3NiLWluYS5mcmF1bmhvZmVyLmRlL2lkcy9hYXMvNTE3NF83MDAxXzAxMjJfOTIzNw')) - .toEqual('https://iosb-ina.fraunhofer.de/ids/aas/5174_7001_0122_9237'); + expect( + decodeBase64Url('aHR0cHM6Ly9pb3NiLWluYS5mcmF1bmhvZmVyLmRlL2lkcy9hYXMvNTE3NF83MDAxXzAxMjJfOTIzNw'), + ).toEqual('https://iosb-ina.fraunhofer.de/ids/aas/5174_7001_0122_9237'); }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/image-processing.spec.ts b/projects/aas-server/src/test/image-processing.spec.ts index c6ed17fc..8605efff 100644 --- a/projects/aas-server/src/test/image-processing.spec.ts +++ b/projects/aas-server/src/test/image-processing.spec.ts @@ -6,21 +6,21 @@ * *****************************************************************************/ +import { describe, it, expect } from '@jest/globals'; import fs from 'fs'; import Jimp from 'jimp'; import { ImageProcessing } from '../app/image-processing.js'; -import { describe, it, expect } from '@jest/globals'; describe('image processing', function () { - it('resizes an image to 128 x 128 pixels', async function () { + it('resizes an image to 128 x 128 pixels', async () => { const source = fs.createReadStream('./src/test/assets/thumbnail.jpg'); const stream = await ImageProcessing.resizeAsync(source, 128, 128); expect(stream).toBeTruthy(); }); - it('converts a tiff-image to a png-image', async function() { + it('converts a tiff-image to a png-image', async () => { const source = fs.createReadStream('./src/test/assets/image.tiff'); const stream = await ImageProcessing.convertAsync(source, Jimp.MIME_PNG); expect(stream).toBeTruthy(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/live/http/opcua-socket-item.spec.ts b/projects/aas-server/src/test/live/http/http-socket-item.spec.ts similarity index 95% rename from projects/aas-server/src/test/live/http/opcua-socket-item.spec.ts rename to projects/aas-server/src/test/live/http/http-socket-item.spec.ts index 0c9855b7..b30d5c43 100644 --- a/projects/aas-server/src/test/live/http/opcua-socket-item.spec.ts +++ b/projects/aas-server/src/test/live/http/http-socket-item.spec.ts @@ -16,9 +16,9 @@ describe('HttpSocketItem', function () { item = new HttpSocketItem({ nodeId: '', valueType: 'xs:integer' }, 'http://localhost:1234'); }); - it('should be created', function() { + it('should be created', () => { expect(item).toBeTruthy(); expect(item.url).toEqual('http://localhost:1234'); expect(item.node).toEqual({ nodeId: '', valueType: 'xs:integer' }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/live/http/http-subscription.spec.ts b/projects/aas-server/src/test/live/http/http-subscription.spec.ts index 97d697cd..bd811469 100644 --- a/projects/aas-server/src/test/live/http/http-subscription.spec.ts +++ b/projects/aas-server/src/test/live/http/http-subscription.spec.ts @@ -24,28 +24,37 @@ describe('HttpSubscription', function () { beforeEach(function () { logger = createSpyObj(['error', 'warning', 'info', 'debug', 'start', 'stop']); client = createSpyObj(['has', 'subscribe', 'notify']); - aasxServer = createSpyObj( - ['getShellsAsync', 'commitAsync', 'openFileAsync', 'readValueAsync', 'resolveNodeId']); + aasxServer = createSpyObj([ + 'getShellsAsync', + 'commitAsync', + 'openFileAsync', + 'readValueAsync', + 'resolveNodeId', + ]); const reference: aas.Reference = { type: 'ModelReference', - keys: [{ - type: 'Submodel', - value: 'http://i40.customer.com/type/1/1/F13E8576F6488342' - }, - { - type: 'Property', - value: 'GLN', - }] + keys: [ + { + type: 'Submodel', + value: 'http://i40.customer.com/type/1/1/F13E8576F6488342', + }, + { + type: 'Property', + value: 'GLN', + }, + ], }; const request: LiveRequest = { endpoint: 'AasxDirectory', id: 'http://customer.com/aas/9175_7013_7091_9168', - nodes: [{ - nodeId: JSON.stringify(reference), - valueType: 'xs:integer' - }], + nodes: [ + { + nodeId: JSON.stringify(reference), + valueType: 'xs:integer', + }, + ], }; subscription = new HttpSubscription(logger, aasxServer, client, request, env); @@ -57,13 +66,15 @@ describe('HttpSubscription', function () { it('open/close subscription', function (done: DoneFn) { jest.useFakeTimers(); - aasxServer.readValueAsync.mockReturnValue(new Promise(result => { - expect(true).toBeTruthy(); - result(42); - subscription.close(); - done(); - })); + aasxServer.readValueAsync.mockReturnValue( + new Promise(result => { + expect(true).toBeTruthy(); + result(42); + subscription.close(); + done(); + }), + ); subscription.open(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/live/opcua/opcua-socket-item.spec.ts b/projects/aas-server/src/test/live/opcua/opcua-socket-item.spec.ts index d04b4ead..47d2e435 100644 --- a/projects/aas-server/src/test/live/opcua/opcua-socket-item.spec.ts +++ b/projects/aas-server/src/test/live/opcua/opcua-socket-item.spec.ts @@ -7,28 +7,28 @@ *****************************************************************************/ import { beforeEach, describe, expect, it, jest } from '@jest/globals'; +import { ClientMonitoredItem } from 'node-opcua'; import { OpcuaSocketItem } from '../../../app/live/opcua/opcua-socket-item.js'; import { Logger } from '../../../app/logging/logger.js'; import { createSpyObj } from '../../utils.js'; import { SocketClient } from '../../../app/live/socket-client.js'; -import { ClientMonitoredItem } from 'node-opcua'; -describe('OpcuaSocketItem', function () { +describe('OpcuaSocketItem', () => { let item: OpcuaSocketItem; let logger: jest.Mocked; let client: jest.Mocked; - beforeEach(function () { + beforeEach(() => { logger = createSpyObj(['error', 'warning', 'info', 'debug', 'start', 'stop']); client = createSpyObj([]); item = new OpcuaSocketItem(logger, client, { nodeId: '', valueType: 'xs:integer' }); }); - it('should be created', function() { + it('should be created', () => { expect(item).toBeTruthy(); }); - it('can subscribe/unsubscribe', function() { + it('can subscribe/unsubscribe', () => { const monitoredItem = createSpyObj(['on', 'off', 'terminate']); item.subscribe(monitoredItem); expect(monitoredItem.on).toHaveBeenCalled(); @@ -37,4 +37,4 @@ describe('OpcuaSocketItem', function () { expect(monitoredItem.off).toHaveBeenCalled(); expect(monitoredItem.terminate).toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/live/socket-client.spec.ts b/projects/aas-server/src/test/live/socket-client.spec.ts index fb8919f2..5e67e3ad 100644 --- a/projects/aas-server/src/test/live/socket-client.spec.ts +++ b/projects/aas-server/src/test/live/socket-client.spec.ts @@ -32,6 +32,6 @@ describe('SocketClient', function () { expect(client.has('test')).toBeTruthy(); client.notify({ type: 'test', data: 42 }); - expect(ws.send).toHaveBeenCalled(); + expect(ws.send).toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/memory-logger.spec.ts b/projects/aas-server/src/test/memory-logger.spec.ts index 805b7a7b..55a3cd94 100644 --- a/projects/aas-server/src/test/memory-logger.spec.ts +++ b/projects/aas-server/src/test/memory-logger.spec.ts @@ -7,19 +7,17 @@ *****************************************************************************/ import 'reflect-metadata'; +import { describe, beforeEach, it, expect, jest } from '@jest/globals'; import { MemoryLogger, MemoryLoggerLevel } from '../app/logging/memory-logger.js'; import { DebugConsole } from '../app/logging/logger.js'; import { createSpyObj } from './utils.js'; -import { describe, beforeEach, it, expect, jest } from '@jest/globals'; describe('MemoryLogger', function () { describe('log level Info', function () { let logger: MemoryLogger; beforeEach(function () { - logger = new MemoryLogger( - MemoryLoggerLevel.Info, - createSpyObj(['debug'])); + logger = new MemoryLogger(MemoryLoggerLevel.Info, createSpyObj(['debug'])); }); it('should create', function () { @@ -125,4 +123,4 @@ describe('MemoryLogger', function () { expect(console.debug).toHaveBeenCalled(); }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/packages/aasx-server/aasx-package.spec.ts b/projects/aas-server/src/test/packages/aasx-server/aasx-package.spec.ts index 639d93cb..c94efe0e 100644 --- a/projects/aas-server/src/test/packages/aasx-server/aasx-package.spec.ts +++ b/projects/aas-server/src/test/packages/aasx-server/aasx-package.spec.ts @@ -7,11 +7,11 @@ *****************************************************************************/ import { describe, beforeEach, it, expect, jest } from '@jest/globals'; -import { AasxPackage } from '../../../app/packages/aasx-directory/aasx-package.js' +import { AasxPackage } from '../../../app/packages/aasx-directory/aasx-package.js'; import { AasxDirectory } from '../../../app/packages/aasx-directory/aasx-directory.js'; import { Logger } from '../../../app/logging/logger.js'; import { LocalFileStorage } from '../../../app/file-storage/local-file-storage.js'; -import { createSpyObj, fail } from '../../utils.js'; +import { createSpyObj } from '../../utils.js'; import { FileStorage } from '../../../app/file-storage/file-storage.js'; describe('AasxPackage', function () { diff --git a/projects/aas-server/src/test/packages/aasx-server/aasx-server-package.spec.ts b/projects/aas-server/src/test/packages/aasx-server/aasx-server-package.spec.ts index 0f90e7ad..c80ff49e 100644 --- a/projects/aas-server/src/test/packages/aasx-server/aasx-server-package.spec.ts +++ b/projects/aas-server/src/test/packages/aasx-server/aasx-server-package.spec.ts @@ -13,34 +13,36 @@ import { AasxServer } from '../../../app/packages/aasx-server/aasx-server.js'; import { AasxServerPackage } from '../../../app/packages/aasx-server/aasx-server-package.js'; import { createSpyObj } from '../../utils.js'; -describe('AasxServerPackage', function () { +describe('AasxServerPackage', () => { let aasPackage: AasxServerPackage; let logger: jest.Mocked; let server: jest.Mocked; let env: aas.Environment; - beforeEach(function () { + beforeEach(() => { logger = createSpyObj(['error', 'warning', 'info', 'debug', 'start', 'stop']); server = createSpyObj(['readEnvironmentAsync'], { url: 'http:/localhost:1234', - name: 'Test' + name: 'Test', }); aasPackage = new AasxServerPackage(logger, server, 'CunaCup_Becher1'); env = { - assetAdministrationShells: [{ - id: 'Sample AAS', - idShort: 'http://www.fraunhofer.de/aas', - modelType: 'AssetAdministrationShell', - assetInformation: { assetKind: 'Instance' } - }], submodels: [], conceptDescriptions: [] + assetAdministrationShells: [ + { + id: 'Sample AAS', + idShort: 'http://www.fraunhofer.de/aas', + modelType: 'AssetAdministrationShell', + assetInformation: { assetKind: 'Instance' }, + }, + ], + submodels: [], + conceptDescriptions: [], }; }); - it('creates a document', async function () { - server.readEnvironmentAsync.mockReturnValue( - new Promise(resolve => resolve(env))); - + it('creates a document', async () => { + server.readEnvironmentAsync.mockResolvedValue(env); await expect(aasPackage.createDocumentAsync()).resolves.toBeTruthy(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/packages/aasx-server/aasx-server-v0.spec.ts b/projects/aas-server/src/test/packages/aasx-server/aasx-server-v0.spec.ts index 200fb90d..9a9bf0c3 100644 --- a/projects/aas-server/src/test/packages/aasx-server/aasx-server-v0.spec.ts +++ b/projects/aas-server/src/test/packages/aasx-server/aasx-server-v0.spec.ts @@ -56,7 +56,7 @@ describe('AasxServerV0', function () { it('gets the AAS with the specified idShort', async function () { jest.spyOn(http, 'request').mockImplementation((options, callback) => { - let value: any; + let value: unknown; switch ((options as http.RequestOptions).path) { case '/aas/CunaCup_Becher1/submodels': value = submodels; @@ -78,9 +78,9 @@ describe('AasxServerV0', function () { const stream = new IncomingMessage(new Socket()); stream.push(JSON.stringify(value)); stream.push(null); - (stream.statusCode = 200), - (stream.statusMessage = 'OK'), - (callback as (res: IncomingMessage) => void)(stream); + stream.statusCode = 200; + stream.statusMessage = 'OK'; + (callback as (res: IncomingMessage) => void)(stream); return new http.ClientRequest('http://localhost:1234'); }); @@ -97,9 +97,9 @@ describe('AasxServerV0', function () { }), ); stream.push(null); - (stream.statusCode = 200), - (stream.statusMessage = 'OK'), - (callback as (res: IncomingMessage) => void)(stream); + stream.statusCode = 200; + stream.statusMessage = 'OK'; + (callback as (res: IncomingMessage) => void)(stream); return new http.ClientRequest('http://localhost:1234'); }); @@ -117,9 +117,9 @@ describe('AasxServerV0', function () { const stream = new IncomingMessage(new Socket()); stream.push(JSON.stringify({ value: 42 })); stream.push(null); - (stream.statusCode = 200), - (stream.statusMessage = 'OK'), - (callback as (res: IncomingMessage) => void)(stream); + stream.statusCode = 200; + stream.statusMessage = 'OK'; + (callback as (res: IncomingMessage) => void)(stream); return new http.ClientRequest('http://localhost:1234'); }); diff --git a/projects/aas-server/src/test/packages/json-reader-v2.spec.ts b/projects/aas-server/src/test/packages/json-reader-v2.spec.ts index cb723dda..fd9155d7 100644 --- a/projects/aas-server/src/test/packages/json-reader-v2.spec.ts +++ b/projects/aas-server/src/test/packages/json-reader-v2.spec.ts @@ -8,7 +8,7 @@ import { Logger } from '../../app/logging/logger.js'; import { readFile } from 'fs/promises'; -import { JsonReaderV2 } from '../../app/packages/json-reader-v2.js' +import { JsonReaderV2 } from '../../app/packages/json-reader-v2.js'; import { createSpyObj } from '../utils.js'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; @@ -31,4 +31,4 @@ describe('JsonReaderV2', function () { const env = reader.readEnvironment(); expect(env).toBeDefined(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/packages/json-reader.spec.ts b/projects/aas-server/src/test/packages/json-reader.spec.ts index 8c01aee7..5fbec31b 100644 --- a/projects/aas-server/src/test/packages/json-reader.spec.ts +++ b/projects/aas-server/src/test/packages/json-reader.spec.ts @@ -8,7 +8,7 @@ import { Logger } from '../../app/logging/logger.js'; import { readFile } from 'fs/promises'; -import { JsonReader } from '../../app/packages/json-reader.js' +import { JsonReader } from '../../app/packages/json-reader.js'; import { resolve } from 'path'; import { createSpyObj } from '../utils.js'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; @@ -29,7 +29,7 @@ describe('JsonReader', function () { }); it('reads the AAS environment from a JSON source', function () { - let env = reader.readEnvironment(); + const env = reader.readEnvironment(); expect(env).toBeDefined(); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/packages/opcua/opcua-server.spec.ts b/projects/aas-server/src/test/packages/opcua/opcua-server.spec.ts index dc8f5abe..b5001417 100644 --- a/projects/aas-server/src/test/packages/opcua/opcua-server.spec.ts +++ b/projects/aas-server/src/test/packages/opcua/opcua-server.spec.ts @@ -6,7 +6,7 @@ * *****************************************************************************/ -import { beforeEach, describe, expect, it, jest } from '@jest/globals'; +import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals'; import { OpcuaServer } from '../../../app/packages/opcua/opcua-server.js'; import { Logger } from '../../../app/logging/logger.js'; import { createSpyObj } from '../../utils.js'; @@ -14,7 +14,6 @@ import { CallMethodRequestLike, CallMethodResult, ClientSession, OPCUAClient, St import { SocketClient } from '../../../app/live/socket-client.js'; import { LiveRequest, aas } from 'common'; import env from '../../assets/aas-environment.js'; -import { afterEach } from 'node:test'; type CallMethod = (methodToCall: CallMethodRequestLike) => Promise; diff --git a/projects/aas-server/src/test/packages/xml-reader.spec.ts b/projects/aas-server/src/test/packages/xml-reader.spec.ts index 8003c101..74a3db2a 100644 --- a/projects/aas-server/src/test/packages/xml-reader.spec.ts +++ b/projects/aas-server/src/test/packages/xml-reader.spec.ts @@ -6,10 +6,10 @@ * *****************************************************************************/ -import { readFile } from "fs/promises"; -import { resolve } from "path"; -import { Logger } from "../../app/logging/logger.js"; -import { XmlReader } from '../../app/packages/xml-reader.js' +import { readFile } from 'fs/promises'; +import { resolve } from 'path'; +import { Logger } from '../../app/logging/logger.js'; +import { XmlReader } from '../../app/packages/xml-reader.js'; import { createSpyObj } from '../utils.js'; import { describe, beforeAll, beforeEach, it, expect, jest } from '@jest/globals'; @@ -33,9 +33,9 @@ describe('XmlReader', function () { it('should be created', function () { expect(reader).toBeTruthy(); }); - - it('reads the AAS environment from a xml source', function() { - let environment = reader.readEnvironment(); + + it('reads the AAS environment from a xml source', function () { + const environment = reader.readEnvironment(); expect(environment).toBeDefined(); }); }); @@ -60,9 +60,9 @@ describe('XmlReader', function () { expect(reader).toBeTruthy(); }); - it('reads the AAS environment from a xml source', function() { - let environment = reader.readEnvironment(); + it('reads the AAS environment from a xml source', function () { + const environment = reader.readEnvironment(); expect(environment).toBeDefined(); }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/template/template-storage.spec.ts b/projects/aas-server/src/test/template/template-storage.spec.ts index 0b513379..a2effbe6 100644 --- a/projects/aas-server/src/test/template/template-storage.spec.ts +++ b/projects/aas-server/src/test/template/template-storage.spec.ts @@ -7,11 +7,11 @@ *****************************************************************************/ import { describe, beforeEach, it, expect, jest } from '@jest/globals'; +import { TemplateDescriptor, aas } from 'common'; import { TemplateStorage } from '../../app/template/template-storage.js'; import { createSpyObj } from '../utils.js'; import { Logger } from '../../app/logging/logger.js'; import { FileStorage } from '../../app/file-storage/file-storage.js'; -import { TemplateDescriptor, aas } from 'common'; describe('TemplateStorage', function () { let templateStorage: TemplateStorage; @@ -22,7 +22,7 @@ describe('TemplateStorage', function () { logger = createSpyObj(['error']); fileStorage = createSpyObj(['exists', 'isDirectory', 'readDir', 'readFile'], { root: './' }); templateStorage = new TemplateStorage(logger, fileStorage); - }) + }); it('should create', function () { expect(templateStorage).toBeTruthy(); @@ -36,7 +36,7 @@ describe('TemplateStorage', function () { id: 'http://aas/submodel', idShort: 'aSubmodel', kind: 'Instance', - modelType: 'Submodel' + modelType: 'Submodel', }; }); @@ -45,12 +45,14 @@ describe('TemplateStorage', function () { fileStorage.isDirectory.mockResolvedValue(false); fileStorage.readDir.mockResolvedValue(['submodel.json']); fileStorage.readFile.mockResolvedValue(Buffer.from(JSON.stringify(submodel))); - await expect(templateStorage.readAsync()).resolves.toEqual([{ - name: 'submodel.json', - format: '.json', - endpoint: { type: 'file', address: 'submodel.json' }, - template: submodel - }] as TemplateDescriptor[]); + await expect(templateStorage.readAsync()).resolves.toEqual([ + { + name: 'submodel.json', + format: '.json', + endpoint: { type: 'file', address: 'submodel.json' }, + template: submodel, + }, + ] as TemplateDescriptor[]); }); }); -}); \ No newline at end of file +}); diff --git a/projects/aas-server/src/test/winston-logger.spec.ts b/projects/aas-server/src/test/winston-logger.spec.ts index 8ffb4377..7d6b2179 100644 --- a/projects/aas-server/src/test/winston-logger.spec.ts +++ b/projects/aas-server/src/test/winston-logger.spec.ts @@ -18,7 +18,15 @@ describe('WinstonLogger', function () { let winstonLogger: jest.Mocked; beforeEach(function () { - winstonLogger = createSpyObj(['error', 'warn', 'info', 'isErrorEnabled', 'isInfoEnabled', 'isWarnEnabled']); + winstonLogger = createSpyObj([ + 'error', + 'warn', + 'info', + 'isErrorEnabled', + 'isInfoEnabled', + 'isWarnEnabled', + ]); + winstonLogger.isErrorEnabled.mockReturnValue(true); winstonLogger.isWarnEnabled.mockReturnValue(true); winstonLogger.isInfoEnabled.mockReturnValue(true); @@ -33,7 +41,7 @@ describe('WinstonLogger', function () { logger.stop(); expect(logger.getMessages().length).toEqual(3); }); - + it('logs message objects', function () { logger.start('test'); logger.log({ type: 'Info', text: 'This is an info.', timestamp: Date.now() }); @@ -42,7 +50,7 @@ describe('WinstonLogger', function () { logger.stop(); expect(logger.getMessages().length).toEqual(3); }); - + it('logs only different errors', function () { logger.start('test'); logger.error('This is a first error.'); @@ -76,7 +84,14 @@ describe('WinstonLogger', function () { let winstonLogger: jest.Mocked; beforeEach(function () { - winstonLogger = createSpyObj(['error', 'warn', 'info', 'isErrorEnabled', 'isInfoEnabled', 'isWarnEnabled']); + winstonLogger = createSpyObj([ + 'error', + 'warn', + 'info', + 'isErrorEnabled', + 'isInfoEnabled', + 'isWarnEnabled', + ]); winstonLogger.isErrorEnabled.mockReturnValue(true); winstonLogger.isWarnEnabled.mockReturnValue(false); winstonLogger.isInfoEnabled.mockReturnValue(false); @@ -98,7 +113,14 @@ describe('WinstonLogger', function () { let winstonLogger: jest.Mocked; beforeEach(function () { - winstonLogger = createSpyObj(['error', 'warn', 'info', 'isErrorEnabled', 'isInfoEnabled', 'isWarnEnabled']); + winstonLogger = createSpyObj([ + 'error', + 'warn', + 'info', + 'isErrorEnabled', + 'isInfoEnabled', + 'isWarnEnabled', + ]); winstonLogger.isErrorEnabled.mockReturnValue(true); winstonLogger.isWarnEnabled.mockReturnValue(true); winstonLogger.isInfoEnabled.mockReturnValue(false); @@ -120,7 +142,16 @@ describe('WinstonLogger', function () { let winstonLogger: jest.Mocked; beforeEach(function () { - winstonLogger = createSpyObj(['error', 'warn', 'info', 'debug', 'isErrorEnabled', 'isInfoEnabled', 'isWarnEnabled', 'isDebugEnabled']); + winstonLogger = createSpyObj([ + 'error', + 'warn', + 'info', + 'debug', + 'isErrorEnabled', + 'isInfoEnabled', + 'isWarnEnabled', + 'isDebugEnabled', + ]); winstonLogger.isErrorEnabled.mockReturnValue(true); winstonLogger.isWarnEnabled.mockReturnValue(true); winstonLogger.isInfoEnabled.mockReturnValue(true); @@ -138,4 +169,4 @@ describe('WinstonLogger', function () { expect(winstonLogger.debug).toHaveBeenCalled(); }); }); -}); \ No newline at end of file +});