index.test.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { BankClient } from '../src/index';
  2. import { IWebClient } from '../src/webclient';
  3. import { Storage } from './../src/storage';
  4. import { IWebClientOptions } from './../src/webclient-options';
  5. describe('BankClient', () => {
  6. const storage = new Storage('bankConfig');
  7. test('should successfully bootstrap', async () => {
  8. class FakeWebClient implements IWebClient {
  9. public requestJSON(options: object): Promise<object> {
  10. throw new Error("Method not implemented.");
  11. }
  12. public request(options: IWebClientOptions): Promise<string> {
  13. throw new Error("Method not implemented.");
  14. }
  15. }
  16. const bankClient = new BankClient('/urlBase', storage, new FakeWebClient());
  17. const strapped = await bankClient.bootstrap();
  18. expect(strapped).toBeDefined();
  19. });
  20. test('should return hardcoded nonce', async () => {
  21. class FakeWebClient implements IWebClient {
  22. public requestJSON(options: object): Promise<object> {
  23. throw new Error("Method not implemented.");
  24. }
  25. public request(options: IWebClientOptions): Promise<string> {
  26. return Promise.resolve('42');
  27. }
  28. }
  29. const bankClient = new BankClient('/urlBase', storage, new FakeWebClient());
  30. await bankClient.bootstrap();
  31. const nonce = await bankClient.getNonce();
  32. expect(nonce).toEqual(42);
  33. });
  34. });