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