Skip to content

Commit

Permalink
chore: increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki committed Jun 28, 2024
1 parent 5448482 commit 6b12726
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/editors/sharedComponents/TinyMceWidget/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ describe('TinyMceEditor hooks', () => {
});

describe('replaceStaticWithAsset', () => {
const initialContent = '<img src="/static/soMEImagEURl1.jpeg"/><a href="/assets/v1/some-key/test.pdf">test</a>';
const learningContextId = 'course+test+run';
const initialContent = '<img src="/static/soMEImagEURl1.jpeg"/><a href="/assets/v1/some-key/test.pdf">test</a><img src="/asset-v1:org+test+run+type@[email protected]" />';
const learningContextId = 'course-v1:org+test+run';
const lmsEndpointUrl = 'sOmEvaLue.cOm';
it('it returns updated src for text editor to update content', () => {
const expected = '<img src="/asset+test+run+type@[email protected]"/><a href="/asset+test+run+type@[email protected]">test</a>';
it('returns updated src for text editor to update content', () => {
const expected = '<img src="/asset-v1:org+test+run+type@[email protected]"/><a href="/asset-v1:org+test+run+type@[email protected]">test</a><img src="/asset-v1:org+test+run+type@[email protected]" />';
const actual = module.replaceStaticWithAsset({ initialContent, learningContextId });
expect(actual).toEqual(expected);
});
it('it returs updated src with absolute url for expandable editor to update content', () => {
it('returns updated src with absolute url for expandable editor to update content', () => {
const editorType = 'expandable';
const expected = `<img src="${lmsEndpointUrl}/asset+test+run+type@[email protected]"/><a href="${lmsEndpointUrl}/asset+test+run+type@[email protected]">test</a>`;
const expected = `<img src="${lmsEndpointUrl}/asset-v1:org+test+run+type@[email protected]"/><a href="${lmsEndpointUrl}/asset-v1:org+test+run+type@[email protected]">test</a><img src="${lmsEndpointUrl}/asset-v1:org+test+run+type@[email protected]" />`;
const actual = module.replaceStaticWithAsset({
initialContent,
editorType,
Expand All @@ -201,6 +201,11 @@ describe('TinyMceEditor hooks', () => {
});
expect(actual).toEqual(expected);
});
it('returns false when there are no srcs to update', () => {
const content = '<div>Hello world!</div>';
const actual = module.replaceStaticWithAsset({ initialContent: content, learningContextId });
expect(actual).toBeFalsy();
});
});
describe('setAssetToStaticUrl', () => {
it('returns content with updated img links', () => {
Expand Down

0 comments on commit 6b12726

Please sign in to comment.