-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [e2e]: update service integration tests * [e2e]: remove console.log
- Loading branch information
Showing
10 changed files
with
1,036 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1419,7 +1419,7 @@ describe('API Config', () => { | |
expect(results).toEqual(3); | ||
}); | ||
|
||
it("should return default value 1 if nft process max retries is not defined", () => { | ||
it("should return default value 3 if nft process max retries is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => undefined)); | ||
|
@@ -1428,4 +1428,198 @@ describe('API Config', () => { | |
expect(results).toEqual(3); | ||
}); | ||
}); | ||
|
||
describe("getGithubToken", () => { | ||
it("should return GitHub token details", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'test')); | ||
|
||
const results = apiConfigService.getGithubToken(); | ||
expect(results).toEqual('test'); | ||
}); | ||
|
||
it("should return undefined if GitHub token is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => undefined)); | ||
|
||
const results = apiConfigService.getGithubToken(); | ||
expect(results).toStrictEqual(undefined); | ||
}); | ||
}); | ||
|
||
describe("getMaiarExchangeUrlMandatory", () => { | ||
it("should return Maiar Exchange Url", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'https://graph.maiar.exchange/graphql')); | ||
|
||
const results = apiConfigService.getMaiarExchangeUrlMandatory(); | ||
expect(results).toEqual('https://graph.maiar.exchange/graphql'); | ||
}); | ||
|
||
it("should throw new error because test simulates that Maiar Exchange Url is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => undefined)); | ||
|
||
expect(() => apiConfigService.getMaiarExchangeUrlMandatory()).toThrowError('No transaction-action.mex.microServiceUrl present'); | ||
}); | ||
}); | ||
|
||
describe("getDatabaseType", () => { | ||
it("should return database type details", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'mysql')); | ||
|
||
const results = apiConfigService.getDatabaseType(); | ||
expect(results).toEqual('mysql'); | ||
}); | ||
|
||
it("should throw new error because test simulates that database type is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => false)); | ||
|
||
expect(() => apiConfigService.getDatabaseType()).toThrowError('No database.type present'); | ||
}); | ||
}); | ||
|
||
describe("getEventsNotifierExchange", () => { | ||
it("should return events notifier exchange details ( all_events) ", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'all_events')); | ||
|
||
const results = apiConfigService.getEventsNotifierExchange(); | ||
expect(results).toEqual('all_events'); | ||
}); | ||
|
||
it("should throw new error because test simulates that events notifier exchange is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => false)); | ||
|
||
expect(() => apiConfigService.getEventsNotifierExchange()).toThrowError('No events notifier exchange present'); | ||
}); | ||
}); | ||
|
||
describe("getEventsNotifierUrl", () => { | ||
it("should return events notifier url", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'amqp://guest:[email protected]:5672')); | ||
|
||
const results = apiConfigService.getEventsNotifierUrl(); | ||
expect(results).toEqual('amqp://guest:[email protected]:5672'); | ||
}); | ||
|
||
it("should throw new error because test simulates that events notifier url is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => false)); | ||
|
||
expect(() => apiConfigService.getEventsNotifierUrl()).toThrowError('No events notifier url present'); | ||
}); | ||
}); | ||
|
||
describe("getEventsNotifierFeaturePort", () => { | ||
it("should return events notifier port", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => '5674')); | ||
|
||
const results = apiConfigService.getEventsNotifierFeaturePort(); | ||
expect(results).toEqual('5674'); | ||
}); | ||
|
||
it("should throw new error because test simulates that events notifier port is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => undefined)); | ||
|
||
expect(() => apiConfigService.getEventsNotifierFeaturePort()).toThrowError('No events notifier port present'); | ||
}); | ||
}); | ||
|
||
describe("isEventsNotifierFeatureActive", () => { | ||
it("should return events notifier event flag", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => true)); | ||
|
||
const results = apiConfigService.isEventsNotifierFeatureActive(); | ||
expect(results).toEqual(true); | ||
}); | ||
|
||
it("should return false because test simulates that events notifier flag is false", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => undefined)); | ||
|
||
const results = apiConfigService.isEventsNotifierFeatureActive(); | ||
expect(results).toEqual(false); | ||
}); | ||
}); | ||
|
||
describe("getIsElasticUpdaterCronActive", () => { | ||
it("should return true if elastic updater cron active is enabled", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => true)); | ||
|
||
const results = apiConfigService.getIsElasticUpdaterCronActive(); | ||
expect(results).toEqual(true); | ||
}); | ||
|
||
it("should return false because test simulates that elastic updater cron is not active ( false )", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => false)); | ||
|
||
const results = apiConfigService.getIsElasticUpdaterCronActive(); | ||
expect(results).toEqual(false); | ||
}); | ||
}); | ||
|
||
describe("getConfig", () => { | ||
it("should return true if elastic updater cron active is enabled", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => [ | ||
'https://api.elrond.com', | ||
'https://devnet-api.elrond.com', | ||
'https://testnet-api.elrond.com', | ||
])); | ||
|
||
const results = apiConfigService.getConfig('urls.api'); | ||
|
||
expect(results).toEqual(expect.arrayContaining([ | ||
'https://api.elrond.com', | ||
'https://devnet-api.elrond.com', | ||
'https://testnet-api.elrond.com', | ||
])); | ||
}); | ||
}); | ||
|
||
describe("getDatabaseUrl", () => { | ||
it("should return database url details", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, "get") | ||
.mockImplementation(jest.fn(() => 'localhost')); | ||
|
||
const results = apiConfigService.getDatabaseUrl(); | ||
expect(results).toEqual('localhost'); | ||
}); | ||
|
||
it("should throw new error because test simulates that database url is not defined", () => { | ||
jest | ||
.spyOn(ConfigService.prototype, 'get') | ||
.mockImplementation(jest.fn(() => false)); | ||
|
||
expect(() => apiConfigService.getDatabaseUrl()).toThrowError('No database.url present'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/integration/controllers/health.check.controller.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import { PublicAppModule } from 'src/public.app.module'; | ||
import request = require('supertest'); | ||
|
||
describe("Usernames Controller", () => { | ||
let app: INestApplication; | ||
const route: string = "/hello"; | ||
|
||
beforeAll(async () => { | ||
const moduleRef = await Test.createTestingModule({ | ||
imports: [PublicAppModule], | ||
}).compile(); | ||
|
||
app = moduleRef.createNestApplication(); | ||
|
||
await app.init(); | ||
}); | ||
|
||
it("/hello - should return status code 200 and response message 'hello' ", async () => { | ||
|
||
await request(app.getHttpServer()) | ||
.get(route) | ||
.expect(200) | ||
.then(res => { | ||
expect(res.text).toStrictEqual('hello'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.