Initial project documentation and status
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Tests for the adapter factory function.
|
||||
*/
|
||||
|
||||
import { createMeshCentralAdapter } from '../adapter';
|
||||
import { BridgeError } from '../contracts';
|
||||
|
||||
describe('createMeshCentralAdapter', () => {
|
||||
it('should return mock adapter by default', () => {
|
||||
const adapter = createMeshCentralAdapter();
|
||||
expect(adapter.name).toBe('mock');
|
||||
});
|
||||
|
||||
it('should return mock adapter when adapterType is mock', () => {
|
||||
const adapter = createMeshCentralAdapter({ adapterType: 'mock' });
|
||||
expect(adapter.name).toBe('mock');
|
||||
});
|
||||
|
||||
it('should throw for real adapter without credentials', async () => {
|
||||
// Real adapter requires credentials
|
||||
expect(() =>
|
||||
createMeshCentralAdapter({ adapterType: 'real', meshCentralUrl: 'http://test:8080' }),
|
||||
).toThrow(BridgeError);
|
||||
});
|
||||
|
||||
it('should accept custom configuration', () => {
|
||||
const config = {
|
||||
meshCentralUrl: 'http://custom-url:8080',
|
||||
timeoutMs: 5_000,
|
||||
maxOutputLength: 32_768,
|
||||
};
|
||||
|
||||
const adapter = createMeshCentralAdapter(config);
|
||||
expect(adapter.name).toBe('mock');
|
||||
|
||||
// Verify mock adapter receives config (would be used by real adapter)
|
||||
expect(adapter).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user