Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe("get()", () => {
it("should return value stored in memoryStorage", inject([MemoryStorage], (memoryStorage: MemoryStorage) => {
// GIVEN
memoryStorage.set("key", "value");
// WHEN
memoryStorage.get("key").should.eq("value");
}));
});
});
describe("SwaggerModule", () => {
before(
inject(
[SwaggerModule, ServerSettingsService, ExpressApplication],
(swaggerModule: SwaggerModule, serverSettingsService: ServerSettingsService, expressApp: ExpressApplication) => {
this.swaggerModule = swaggerModule;
this.settingsService = serverSettingsService;
this.expressApp = expressApp;
}
)
);
describe("$afterRoutesInit()", () => {
before(() => {
this.config = [
{
path: "/doc1",
doc: "doc1",
options: "options",
describe("Swagger", () => {
let request: SuperTest.SuperTest;
before(bootstrap(FakeServer));
before(inject([ExpressApplication], (expressApplication: ExpressApplication) => (request = SuperTest(expressApplication))));
after(TestContext.reset);
describe("GET /api-doc/swagger.json", () => {
let spec: any;
before(done => {
request
.get("/api-doc/swagger.json")
.expect(200)
.end((err: any, response: any) => {
spec = JSON.parse(response.text);
done();
});
});
it("should have a swagger version", () => {
expect(spec.swagger).to.be.eq("2.0");
describe("SwaggerService", () => {
before(
inject([SwaggerService, ServerSettingsService], (swaggerService: SwaggerService, serverSettingsService: ServerSettingsService) => {
this.swaggerService = swaggerService;
this.settingsService = serverSettingsService;
})
);
describe("getDefaultSpec()", () => {
describe("when specPath is given", () => {
before(() => {
return (this.result = this.swaggerService.getDefaultSpec({specPath: __dirname + "/data/spec.json"}));
});
it("should return default spec", () => {
this.result.should.be.deep.equals(require("./data/spec.expected.json"));
});
});
describe("MultipartFileFilter", () => {
before(
inject([MultipartFileFilter], (filter: MultipartFileFilter) => {
this.filter = filter;
})
);
describe("transform()", () => {
before(() => {
this.result = this.filter.transform("", {files: [{}]});
});
it("should transform expression", () => {
expect(this.result).to.be.an("object");
});
});
});
describe("QueryParamsFilter", () => {
before(
inject([QueryParamsFilter], (filter: QueryParamsFilter) => {
this.filter = filter;
})
);
describe("transform()", () => {
before(() => {
this.result = this.filter.transform("test", {query: {test: "test"}});
});
it("should transform expression", () => {
expect(this.result).to.equal("test");
});
});
});
{options: "options"}
)
.then(() => {
this.result = mongooseService.connect(
"key",
"mongodb://test",
{options: "options"}
);
return this.result;
});
})
);
after(
inject([ServerSettingsService], (serverSetttings: ServerSettingsService) => {
serverSetttings.set("mongoose", {
url: undefined,
connectionOptions: undefined,
urls: undefined
});
this.connectStub.restore();
})
);
it("should call mongoose.connect", () => {
this.connectStub.should.have.been.calledOnce;
this.connectStub.should.have.been.calledWithExactly("mongodb://test", {options: "options"});
});
it("should return the instance of mongoose", () => {
return this.result.should.eventually.eq("mongooseinstance");
describe("object", () => {
it("should convert object", () => {
expect(this.converterService.deserialize({}, Object)).to.be.an("object");
});
it("should convert a date", inject([ConverterService], (converterService: ConverterService) => {
expect(converterService.deserialize(new Date().toISOString(), Date)).to.be.instanceof(Date);
}));
});
describe("GlobalAcceptMimesMiddleware", () => {
before(
inject([], () => {
const settings = new ServerSettingsService();
settings.acceptMimes = ["application/json"];
this.middleware = new GlobalAcceptMimesMiddleware(settings);
this.request = new FakeRequest();
})
);
describe("accept", () => {
before(() => {
this.request.mime = "application/json";
});
it("should return nothing", () => {
expect(this.middleware.use(this.request)).to.eq(undefined);
});
});
describe("getNsp()", () => {
before(
inject([InjectorService], (injector: InjectorService) => {
this.namespace = {
on: Sinon.stub()
};
this.ioStub = {
of: Sinon.stub().returns(this.namespace)
};
this.instance = {
onConnection: Sinon.stub(),
onDisconnect: Sinon.stub()
};
this.socket = {
on: Sinon.stub()
};
const service = new SocketIOService(injector, {} as any, {} as any, this.ioStub, {} as any, {} as any);
const nspConf = service.getNsp("/");