diff --git a/front/src/helpers/__snapshots__/zotero/group-collection.bib b/front/src/helpers/__snapshots__/zotero/group-collection.bib index f71a52e9f..3d0af5f6f 100644 --- a/front/src/helpers/__snapshots__/zotero/group-collection.bib +++ b/front/src/helpers/__snapshots__/zotero/group-collection.bib @@ -17,113 +17,3 @@ @misc{grossetie_test_nodate journal = {How to}, author = {GROSSETIE, guillaume}, } - -@unpublished{noauthor_notitle_nodate, -} - -@misc{noauthor_notitle_nodate-1, -} - -@misc{noauthor_notitle_nodate-2, -} - -@book{noauthor_test19_nodate, - title = {test19}, -} - -@book{noauthor_test26_nodate, - title = {test26}, -} - -@book{noauthor_test25_nodate, - title = {test25}, -} - -@book{noauthor_test24_nodate, - title = {test24}, -} - -@book{noauthor_test23_nodate, - title = {test23}, -} - -@book{noauthor_test22_nodate, - title = {test22}, -} - -@book{noauthor_test21_nodate, - title = {test21}, -} - -@book{noauthor_test20_nodate, - title = {test20}, -} - -@book{noauthor_test9_nodate, - title = {test9}, -} - -@book{noauthor_test8_nodate, - title = {test8}, -} - -@book{noauthor_test5_nodate, - title = {test5}, -} - -@book{noauthor_test7_nodate, - title = {test7}, -} - -@book{noauthor_test6_nodate, - title = {test6}, -} - -@book{noauthor_test4_nodate, - title = {test4}, -} - -@book{noauthor_test16_nodate, - title = {test16}, -} - -@book{noauthor_test15_nodate, - title = {test15}, -} - -@book{noauthor_test14_nodate, - title = {test14}, -} - -@book{noauthor_test12_nodate, - title = {test12}, -} - -@book{noauthor_test11_nodate, - title = {test11}, -} - - -@book{noauthor_test3_nodate, - title = {test3}, -} - -@book{noauthor_test2_nodate, - title = {test2}, -} - -@book{noauthor_test18_nodate, - title = {test18}, -} - -@book{noauthor_test17_nodate, - title = {test17}, -} - -@book{noauthor_test13_nodate, - title = {test13}, -} - -@book{noauthor_test10_nodate, - title = {test10}, -} diff --git a/front/src/helpers/zotero.test.js b/front/src/helpers/zotero.test.js index 2e384c082..d930e492a 100644 --- a/front/src/helpers/zotero.test.js +++ b/front/src/helpers/zotero.test.js @@ -1,10 +1,41 @@ -import { describe, test, expect } from 'vitest' +import { describe, test, expect, vi } from 'vitest' import { fetchBibliographyFromCollectionHref } from './zotero' describe('fetchBibliographyFromCollection', () => { + fetch + .mockResolvedValueOnce({ + headers: new Headers({ Link: '; rel="next"' }), + text: vi.fn().mockResolvedValue(` +@book{grossetie_test1_nodate, + title = {test1}, + publisher = {Moi}, + author = {Grossetie, Guillaume}, +} + +@misc{grossetie_hello_nodate, + title = {Hello}, + shorttitle = {Hi}, + author = {Grossetie, Guillaume}, +}`) + }) + .mockResolvedValueOnce({ + headers: new Headers({ Link: '; rel="next"' }), + text: vi.fn().mockResolvedValue('') + }) + .mockResolvedValueOnce({ + headers:new Headers({}), + text: vi.fn().mockResolvedValue(` +@misc{grossetie_test_nodate, + type = {yuzutech.fr}, + title = {test}, + journal = {How to}, + author = {GROSSETIE, guillaume}, +}`) + }) + + test('fetches a paginated collection of more than 25 elements', async () => { const zoteroId = '2478772/collections/UGF4W4PZ' - const bib = await fetchBibliographyFromCollectionHref({ collectionHref: `https://api.zotero.org/groups/${zoteroId}`, }) diff --git a/front/tests/setup.js b/front/tests/setup.js index 4aeb6d828..b47d0cb9a 100644 --- a/front/tests/setup.js +++ b/front/tests/setup.js @@ -4,4 +4,7 @@ import '@testing-library/jest-dom/vitest' vi.mock('react-router-dom') +// mock Fetch requests +globalThis.fetch = vi.fn() + afterEach(() => cleanup())