Skip to content

Commit

Permalink
✨ add teste ao connection na model e completa 100% de coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielaMoura25 committed Feb 16, 2023
1 parent f634ee8 commit 51d46b9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/Models/connection.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from 'chai';
import Connection from '../../../src/Models/Connection';

describe('connectToDatabase', function () {
it('should connect to the database successfully', async function () {
try {
const result = await Connection();
expect(result).to.be.an('object');
expect(result.connections[0].readyState).to.equal(1);
} catch (error) {
console.log(error);
}
});

it('should return an error if the connection fails', async function () {
try {
await Connection('mongodb://localhost:27017/invalid-database');
} catch (error) {
expect(error).to.be.an('error');
}
});
});

0 comments on commit 51d46b9

Please sign in to comment.