test: cms urls (#23)

This commit is contained in:
Raymond Zhou
2022-02-25 19:24:05 -05:00
committed by GitHub
parent 7ccba63a85
commit f3d80995c5

View File

@@ -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`);
});
});
});