Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions packages/connection-form/src/hooks/use-connect-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,19 @@ describe('use-connect-form hook', function () {
);
});

it('adds an error to the errors with a message and the host field name', function () {
expect(updateResult.errors).to.deep.equal([
{
fieldName: 'hosts',
fieldIndex: 0,
fieldTab: 'general',
message:
'Host cannot be empty. The host is the address hostname, IP address, or UNIX domain socket where the mongodb instance is running.',
},
]);
it('does not add an error to the errors', function () {
expect(updateResult.errors).to.deep.equal([]);
});

it('keeps the connection string and url the same', function () {
it('produces a well formed connection string', function () {
expect(
new ConnectionStringUrl(
updateResult.connectionOptions.connectionString
updateResult.connectionOptions.connectionString,
{ looseValidation: true }
).hosts
).to.deep.equal(['outerspace:27019']);
).to.deep.equal(['']);
expect(updateResult.connectionOptions.connectionString).to.equal(
'mongodb://outerspace:27019/?ssl=true&directConnection=true'
'mongodb:///?ssl=true&directConnection=true'
);
});
});
Expand Down
6 changes: 0 additions & 6 deletions packages/connection-form/src/hooks/use-connect-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@ function handleUpdateHost({
try {
checkForInvalidCharacterInHost(newHostValue, connectionStringUrl.isSRV);

if (connectionStringUrl.hosts.length === 1 && newHostValue === '') {
throw new Error(
'Host cannot be empty. The host is the address hostname, IP address, or UNIX domain socket where the mongodb instance is running.'
);
}

const updatedConnectionString = connectionStringUrl.clone();
updatedConnectionString.hosts[fieldIndex] = newHostValue || '';

Expand Down