From 677ec5b7fd068305f18a887f7a5f03496d99493a Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Sun, 10 Oct 2021 17:18:26 +1100 Subject: [PATCH] chore(#71): update test coverage --- packages/druxt/test/client.test.js | 6 ++++ .../get/5bee0d1fd2e0ecabbfae045266e65729.json | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/__fixtures__/get/5bee0d1fd2e0ecabbfae045266e65729.json diff --git a/packages/druxt/test/client.test.js b/packages/druxt/test/client.test.js index 804c917a1..ae848685e 100644 --- a/packages/druxt/test/client.test.js +++ b/packages/druxt/test/client.test.js @@ -170,11 +170,17 @@ describe('DruxtClient', () => { }) test('getRelated', async () => { + expect((await druxt.getRelated())).toBe(false) + const mockArticle = await getMockResource('node--article') const { type, id } = mockArticle.data const related = await druxt.getRelated(type, id, 'field_media_image') + expect(mockAxios.get).toHaveBeenCalledWith(`${baseUrl}/en/jsonapi/node/article/${id}/field_media_image`) expect(related.data).toHaveProperty('type') + + await druxt.getRelated('node--fake', id, 'field_media_image') + expect(mockAxios.get).toHaveBeenCalledWith(`/jsonapi/node/fake/${id}/field_media_image`) }) test('getResource', async () => { diff --git a/test/__fixtures__/get/5bee0d1fd2e0ecabbfae045266e65729.json b/test/__fixtures__/get/5bee0d1fd2e0ecabbfae045266e65729.json new file mode 100644 index 000000000..1a3f33dfb --- /dev/null +++ b/test/__fixtures__/get/5bee0d1fd2e0ecabbfae045266e65729.json @@ -0,0 +1,31 @@ +{ + "data": "\n\n \n \n\n\n\n\n\n\n Page not found | Drupal\n \n\n\n\n \n\n\n\n \n \n \n Skip to main content\n \n \n
\n \n
\n
\n
\n
\n \n \n \n\n
\n\n
\n\n
\n \n
\n\n
\n
\n
\n \n \n \n

Page not found

\n\n\n
\n\n \n
\n
\n\n
\n
\n \n\n
\n
\n\n
\n\n
\n \n\n
\n
\n \n
\n
\n\n
\n\n
\n \n\n
\n \n
\n
\n \n \n The requested page could not be found.\n
\n\n
\n\n
\n
\n\n
\n\n \n \n\n\n\n\n \n\n", + "status": 404, + "statusText": "Not Found", + "headers": { + "content-type": "text/html; charset=UTF-8", + "cache-control": "must-revalidate, no-cache, private", + "content-language": "en", + "expires": "Sun, 19 Nov 1978 05:00:00 GMT" + }, + "config": { + "url": "/jsonapi/node/fake/e4ced3c1-e14b-48f1-8c0a-c909e808de68/field_media_image", + "method": "get", + "headers": { + "Accept": "application/json, text/plain, */*" + }, + "baseURL": "https://demo-api.druxtjs.org", + "transformRequest": [ + null + ], + "transformResponse": [ + null + ], + "timeout": 0, + "xsrfCookieName": "XSRF-TOKEN", + "xsrfHeaderName": "X-XSRF-TOKEN", + "maxContentLength": -1, + "maxBodyLength": -1 + }, + "request": {} +} \ No newline at end of file