Skip to content

Commit

Permalink
first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paula-stacho committed Jul 11, 2024
1 parent c6c74e7 commit e03d5d4
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 17 deletions.
50 changes: 50 additions & 0 deletions packages/compass-connections/src/connections-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,25 @@ describe('ConnectionsManager', function () {
).to.equal(ConnectionStatus.Connected);
});

it('#getConnectionIdsByStatus(ConnectionStatus.Connected) should return the connected connections', async function () {
await Promise.all([
connectionsManager.connect(
connectedConnectionInfo1,
getConnectionConfigurationOptions()
),
connectionsManager.connect(
connectedConnectionInfo2,
getConnectionConfigurationOptions()
),
]);
const connections = connectionsManager.getConnectionIdsByStatus(
ConnectionStatus.Connected
);
expect(connections).to.have.length(2);
expect(connections).to.contain(connectedConnectionInfo1.id);
expect(connections).to.contain(connectedConnectionInfo2.id);
});

it('#getDataServiceForConnection should be able to return connected dataService', async function () {
await Promise.all([
connectionsManager.connect(
Expand Down Expand Up @@ -564,6 +583,20 @@ describe('ConnectionsManager', function () {
);
});

it('#getConnectionIdsByStatus(ConnectionStatus.Failed) should return the failed connection', async function () {
try {
await connectionsManager.connect(
failedConnectionInfo,
getConnectionConfigurationOptions()
);
} catch (error) {
// nothing
}
expect(
connectionsManager.getConnectionIdsByStatus(ConnectionStatus.Failed)
).to.deep.equal([failedConnectionInfo.id]);
});

it('#getDataServiceForConnection should not return anything for failed connection', async function () {
try {
await connectionsManager.connect(
Expand Down Expand Up @@ -632,6 +665,23 @@ describe('ConnectionsManager', function () {
);
});

it('#getConnectionIdsByStatus(ConnectionStatus.Disconnected) should return the connection after disconnecting', async function () {
await connectionsManager.connect(
activeConnectionInfo,
getConnectionConfigurationOptions()
);
expect(
connectionsManager.getConnectionIdsByStatus(ConnectionStatus.Connected)
).to.deep.equal([activeConnectionInfo.id]);

await connectionsManager.closeConnection(activeConnectionInfo.id);
expect(
connectionsManager.getConnectionIdsByStatus(
ConnectionStatus.Disconnected
)
).to.deep.equal([activeConnectionInfo.id]);
});

it('#getDataServiceForConnection should not return anything for disconnected connection', async function () {
await connectionsManager.connect(
activeConnectionInfo,
Expand Down
Loading

0 comments on commit e03d5d4

Please sign in to comment.