From f3d80995c527ca7db5532b4cfabbb468ec4e6d29 Mon Sep 17 00:00:00 2001 From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com> Date: Fri, 25 Feb 2022 19:24:05 -0500 Subject: [PATCH] test: cms urls (#23) --- src/editors/data/services/cms/urls.test.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/editors/data/services/cms/urls.test.js diff --git a/src/editors/data/services/cms/urls.test.js b/src/editors/data/services/cms/urls.test.js new file mode 100644 index 000000000..5e3e20b46 --- /dev/null +++ b/src/editors/data/services/cms/urls.test.js @@ -0,0 +1,37 @@ +import { + unit, + block, + blockAncestor, +} from './urls'; + +describe('cms url methods', () => { + const studioEndpointUrl = 'urLgoeStOstudiO'; + const blockId = 'blOckIDTeST123'; + describe('unit', () => { + const unitUrl = { + data: { + ancestors: [ + { + id: 'unItUrlTEST', + }, + ], + }, + }; + it('returns url with studioEndpointUrl and unitUrl', () => { + expect(unit({ studioEndpointUrl, unitUrl })) + .toEqual(`${studioEndpointUrl}/container/${unitUrl.data.ancestors[0].id}`); + }); + }); + describe('block', () => { + it('returns url with studioEndpointUrl and blockId', () => { + expect(block({ studioEndpointUrl, blockId })) + .toEqual(`${studioEndpointUrl}/xblock/${blockId}`); + }); + }); + describe('blockAncestor', () => { + it('returns url with studioEndpointUrl, blockId and ancestor query', () => { + expect(blockAncestor({ studioEndpointUrl, blockId })) + .toEqual(`${block({ studioEndpointUrl, blockId })}?fields=ancestorInfo`); + }); + }); +}); \ No newline at end of file