From 9aaa01e4558aa39c3faa00df6951eabf0a50336b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 4 Aug 2018 11:07:28 +0200 Subject: [PATCH] Added new test --- test/api/ShlinkApiClient.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/api/ShlinkApiClient.test.js diff --git a/test/api/ShlinkApiClient.test.js b/test/api/ShlinkApiClient.test.js new file mode 100644 index 00000000..320136f6 --- /dev/null +++ b/test/api/ShlinkApiClient.test.js @@ -0,0 +1,26 @@ +import { ShlinkApiClient } from '../../src/api/ShlinkApiClient' + +describe('ShlinkApiClient', () => { + const createApiClient = extraData => { + const axiosMock = () => + Promise.resolve({ + data: { token: 'foo', ...extraData }, + headers: { authorization: 'Bearer abc123' } + }); + + return new ShlinkApiClient(axiosMock); + }; + + describe('listShortUrls', () => { + it('properly returns short URLs list', async () => { + const expectedList = ['foo', 'bar']; + + const apiClient = createApiClient({ + shortUrls: expectedList + }); + + const actualList = await apiClient.listShortUrls(); + expect(expectedList).toEqual(actualList); + }); + }); +});