mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-24 09:58:21 +03:00
26 lines
1 KiB
JavaScript
26 lines
1 KiB
JavaScript
import buildShlinkApiClient from '../../../src/utils/services/ShlinkApiClientBuilder';
|
|
|
|
describe('ShlinkApiClientBuilder', () => {
|
|
const builder = buildShlinkApiClient({});
|
|
|
|
it('creates new instances when provided params are different', () => {
|
|
const firstApiClient = builder({ url: 'foo', apiKey: 'bar' });
|
|
const secondApiClient = builder({ url: 'bar', apiKey: 'bar' });
|
|
const thirdApiClient = builder({ url: 'bar', apiKey: 'foo' });
|
|
|
|
expect(firstApiClient).not.toBe(secondApiClient);
|
|
expect(firstApiClient).not.toBe(thirdApiClient);
|
|
expect(secondApiClient).not.toBe(thirdApiClient);
|
|
});
|
|
|
|
it('returns existing instances when provided params are the same', () => {
|
|
const params = { url: 'foo', apiKey: 'bar' };
|
|
const firstApiClient = builder(params);
|
|
const secondApiClient = builder(params);
|
|
const thirdApiClient = builder(params);
|
|
|
|
expect(firstApiClient).toBe(secondApiClient);
|
|
expect(firstApiClient).toBe(thirdApiClient);
|
|
expect(secondApiClient).toBe(thirdApiClient);
|
|
});
|
|
});
|