@@ -63,6 +63,7 @@ const mockEditorContentHtml = `
63
63
</img>
64
64
</p>
65
65
` ;
66
+ const baseAssetUrl = 'asset-v1:org+test+run+type@asset+block' ;
66
67
67
68
const mockImagesRef = { current : [ mockImage ] } ;
68
69
@@ -182,17 +183,17 @@ describe('TinyMceEditor hooks', () => {
182
183
} ) ;
183
184
184
185
describe ( 'replaceStaticWithAsset' , ( ) => {
185
- 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@asset+block@ correct.png" />' ;
186
+ const initialContent = ` <img src="/static/soMEImagEURl1.jpeg"/><a href="/assets/v1/${ baseAssetUrl } /test.pdf">test</a><img src="/${ baseAssetUrl } @ correct.png" />` ;
186
187
const learningContextId = 'course-v1:org+test+run' ;
187
188
const lmsEndpointUrl = 'sOmEvaLue.cOm' ;
188
189
it ( 'returns updated src for text editor to update content' , ( ) => {
189
- const expected = ' <img src="/asset-v1:org+test+run+type@asset+block@ soMEImagEURl1.jpeg"/><a href="/asset-v1:org+test+run+type@asset+block@ test.pdf">test</a><img src="/asset-v1:org+test+run+type@asset+block@ correct.png" />' ;
190
+ const expected = ` <img src="/${ baseAssetUrl } @ soMEImagEURl1.jpeg"/><a href="/${ baseAssetUrl } @ test.pdf">test</a><img src="/${ baseAssetUrl } @ correct.png" />` ;
190
191
const actual = module . replaceStaticWithAsset ( { initialContent, learningContextId } ) ;
191
192
expect ( actual ) . toEqual ( expected ) ;
192
193
} ) ;
193
194
it ( 'returns updated src with absolute url for expandable editor to update content' , ( ) => {
194
195
const editorType = 'expandable' ;
195
- const expected = `<img src="${ lmsEndpointUrl } /asset-v1:org+test+run+type@asset+block@ soMEImagEURl1.jpeg"/><a href="${ lmsEndpointUrl } /asset-v1:org+test+run+type@asset+block@ test.pdf">test</a><img src="${ lmsEndpointUrl } /asset-v1:org+test+run+type@asset+block @correct.png" />` ;
196
+ const expected = `<img src="${ lmsEndpointUrl } /${ baseAssetUrl } @ soMEImagEURl1.jpeg"/><a href="${ lmsEndpointUrl } /${ baseAssetUrl } @ test.pdf">test</a><img src="${ lmsEndpointUrl } /${ baseAssetUrl } @correct.png" />` ;
196
197
const actual = module . replaceStaticWithAsset ( {
197
198
initialContent,
198
199
editorType,
@@ -209,7 +210,7 @@ describe('TinyMceEditor hooks', () => {
209
210
} ) ;
210
211
describe ( 'setAssetToStaticUrl' , ( ) => {
211
212
it ( 'returns content with updated img links' , ( ) => {
212
- const editorValue = ' <img src="/asset@ /soME_ImagE_URl1"/> <a href="/asset @soMEImagEURl">testing link</a>' ;
213
+ const editorValue = ` <img src="/${ baseAssetUrl } /soME_ImagE_URl1"/> <a href="/${ baseAssetUrl } @soMEImagEURl">testing link</a>` ;
213
214
const lmsEndpointUrl = 'sOmEvaLue.cOm' ;
214
215
const content = module . setAssetToStaticUrl ( { editorValue, lmsEndpointUrl } ) ;
215
216
expect ( content ) . toEqual ( '<img src="/static/soME_ImagE_URl1"/> <a href="/static/soMEImagEURl">testing link</a>' ) ;
0 commit comments