Skip to content

Commit

Permalink
fix: test MySqlIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
raronpxcsw committed Oct 28, 2024
1 parent 7384632 commit 682ece5
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion projects/aas-server/src/test/aas-index/mysql/mysql-index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { MySqlIndex } from '../../../app/aas-index/mysql/mysql-index.js';
import { Logger } from '../../../app/logging/logger.js';
import { Variable } from '../../../app/variable.js';
import { KeywordDirectory } from '../../../app/aas-index/keyword-directory.js';
import { DocumentCount } from '../../../app/aas-index/mysql/mysql-types.js';
import { DocumentCount, MySqlEndpoint } from '../../../app/aas-index/mysql/mysql-types.js';

describe('MySqlIndex', () => {
let index: MySqlIndex;
Expand Down Expand Up @@ -62,4 +62,31 @@ describe('MySqlIndex', () => {
expect(count).toEqual(42);
});
});

describe('getEndpoints', () => {
it('returns all registered endpoints', () => {
const result: MySqlEndpoint[] = [
{
constructor: { name: 'RowDataPacket' },
name: 'Endpoint 1',
url: 'http://endpoint1.com',
type: 'AAS_API',
},
{
constructor: { name: 'RowDataPacket' },
name: 'Endpoint 2',
url: 'http://endpoint2.com',
type: 'AAS_API',
},
];

connection.query.mockResolvedValue([[result], []]);
const actual = index.getEndpoints();
expect(connection.query).toBeCalledWith('SELECT * FROM `endpoints`');
expect(actual).toEqual([
{ name: 'Endpoint 1', url: 'http://endpoint1.com', type: 'AAS_API' },
{ name: 'Endpoint 2', url: 'http://endpoint2.com', type: 'AAS_API' },
]);
});
});
});

0 comments on commit 682ece5

Please sign in to comment.