-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(server): return network to
/settings
api and add tests (#657)
* chore(server): return network to /settings api * chore(test): add tests to /settings api
- Loading branch information
1 parent
35b5ea1
commit 339b377
Showing
5 changed files
with
59 additions
and
0 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
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,54 @@ | ||
import { PostgreSqlContainer, StartedPostgreSqlContainer } from '@birthdayresearch/sticky-testcontainers'; | ||
import { ConfigService } from '@nestjs/config'; | ||
|
||
import { BridgeServerTestingApp } from './BridgeServerTestingApp'; | ||
import { buildTestConfig, TestingModule } from './TestingModule'; | ||
|
||
describe.only('Settings Controller Test', () => { | ||
let testing: BridgeServerTestingApp; | ||
let startedPostgresContainer: StartedPostgreSqlContainer; | ||
let config: ConfigService; | ||
|
||
beforeAll(async () => { | ||
startedPostgresContainer = await new PostgreSqlContainer().start(); | ||
|
||
testing = new BridgeServerTestingApp( | ||
TestingModule.register( | ||
buildTestConfig({ | ||
defichain: { transferFee: '0.003', supportedTokens: 'BTC,ETH' }, | ||
ethereum: { transferFee: '0', supportedTokens: 'WBTC,ETH' }, | ||
startedPostgresContainer, | ||
}), | ||
), | ||
); | ||
|
||
const app = await testing.start(); | ||
config = app.get(ConfigService); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testing.stop(); | ||
}); | ||
|
||
it('Settings service should return the correct app settings for both DeFiChain and Ethereum', async () => { | ||
const response = await testing.inject({ | ||
method: 'GET', | ||
url: `/settings`, | ||
}); | ||
const settings = JSON.parse(response.payload); | ||
const dfcSupportedTokens = config.get('SUPPORTED_DFC_TOKENS')?.split(','); | ||
const evmSupportedTokens = config.get('SUPPORTED_EVM_TOKENS')?.split(','); | ||
|
||
expect(settings).toMatchObject({ | ||
defichain: { | ||
transferFee: config.get('DFC_FEE_PERCENTAGE'), | ||
supportedTokens: dfcSupportedTokens, | ||
network: 'Local', | ||
}, | ||
ethereum: { | ||
transferFee: config.get('ETH_FEE_PERCENTAGE'), | ||
supportedTokens: evmSupportedTokens, | ||
}, | ||
}); | ||
}); | ||
}); |
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