Skip to content

Commit

Permalink
fixed tests, which require some explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
janpaepke authored and edorivai committed Feb 19, 2024
1 parent b199c39 commit 3ceb30f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 4 additions & 3 deletions tests/integration/orders.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import axios from 'axios';
import httpAdapter from 'axios/lib/adapters/http';
import dotenv from 'dotenv';
import createMollieClient, { PaymentMethod, OrderLineType, Locale, OrderEmbed, Payment } from '../..';
import { fail } from 'node:assert';

import createMollieClient, { Locale, OrderEmbed, OrderLineType, Payment, PaymentMethod } from '../..';

/**
* Overwrite the default XMLHttpRequestAdapter
*/
axios.defaults.adapter = httpAdapter;
axios.defaults.adapter = 'http';

/**
* Load the API_KEY environment variable
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/payments.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import axios from 'axios';
import httpAdapter from 'axios/lib/adapters/http';
import dotenv from 'dotenv';
import { fail } from 'node:assert';

import createMollieClient from '../..';

/**
* Overwrite the default XMLHttpRequestAdapter
*/
axios.defaults.adapter = httpAdapter;
axios.defaults.adapter = 'http';

/**
* Load the API_KEY environment variable
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/resources/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ describe('methods', () => {
mock.onGet(`/methods/${methodId}`).reply(200, response._embedded.methods[0], {});
mock.onGet('/methods/foo').reply(500, error, {});

it('should return a method instance', done =>
it('should return a method instance', () =>
methods.get(methodId).then(result => {
expect(result).toMatchSnapshot();
done();
}));

it('should work with a callback', done => {
Expand All @@ -36,14 +35,13 @@ describe('methods', () => {
});
});

it('should throw an error for non-existent IDs', done =>
it('should throw an error for non-existent IDs', () =>
methods
.get('foo')
.then(result => expect(result).toBeUndefined())
.catch(err => {
expect(err).toBeInstanceOf(ApiError);
expect(err.getMessage()).toEqual(error.detail);
done();
}));

it('should return an error with a callback for non-existent IDs', done => {
Expand Down

0 comments on commit 3ceb30f

Please sign in to comment.