mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
d8ff186303
Client and server now have their own tsconfig so that the transpilation is only done on the part that is being modified. It also allows faster transpilation since tests are now excluded from tsconfig. They are compiled by ts-node during unit tests execution.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import Assert = require("assert");
|
|
import Sinon = require("sinon");
|
|
import MongoDB = require("mongodb");
|
|
import { MongoClient } from "../../../src/lib/connectors/mongo/MongoClient";
|
|
|
|
describe("MongoClient", function () {
|
|
let mongoClientConnectStub: Sinon.SinonStub;
|
|
let mongoDatabase: any;
|
|
let mongoDatabaseCollectionStub: Sinon.SinonStub;
|
|
|
|
describe("collection", function () {
|
|
before(function () {
|
|
mongoDatabaseCollectionStub = Sinon.stub();
|
|
mongoDatabase = {
|
|
collection: mongoDatabaseCollectionStub
|
|
};
|
|
|
|
mongoClientConnectStub = Sinon.stub(MongoDB.MongoClient, "connect");
|
|
mongoClientConnectStub.yields(undefined, mongoDatabase);
|
|
});
|
|
|
|
after(function () {
|
|
mongoClientConnectStub.restore();
|
|
});
|
|
|
|
it("should create a collection", function () {
|
|
const COLLECTION_NAME = "mycollection";
|
|
const client = new MongoClient(mongoDatabase);
|
|
|
|
mongoDatabaseCollectionStub.returns({});
|
|
|
|
const collection = client.collection(COLLECTION_NAME);
|
|
|
|
Assert(collection);
|
|
Assert(mongoDatabaseCollectionStub.calledWith(COLLECTION_NAME ));
|
|
});
|
|
});
|
|
});
|