File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11import cases from 'jest-in-case' ;
2-
32import plugin from '../../' ;
43import { getHTML , shouldTransform } from '../../transformers/CodePen' ;
5-
64import { cache , getMarkdownASTForFile , mdastToHtml } from '../helpers' ;
75
86cases (
@@ -79,13 +77,24 @@ cases(
7977) ;
8078
8179test ( 'Gets the correct CodePen iframe' , ( ) => {
82- const html = getHTML ( 'https://codepen.io/team/codepen/pen/PNaGbb' ) ;
80+ const html = getHTML ( 'https://codepen.io/team/codepen/pen/PNaGbb' , { } ) ;
8381
8482 expect ( html ) . toMatchInlineSnapshot (
8583 `<iframe src="https://codepen.io/team/codepen/embed/preview/PNaGbb" style="width:100%; height:300px;"></iframe>`
8684 ) ;
8785} ) ;
8886
87+ test ( 'Gets the correct CodePen iframe with custom dimensions' , ( ) => {
88+ const html = getHTML ( 'https://codepen.io/team/codepen/pen/PNaGbb' , {
89+ width : '50%' ,
90+ height : '50%' ,
91+ } ) ;
92+
93+ expect ( html ) . toMatchInlineSnapshot (
94+ `<iframe src="https://codepen.io/team/codepen/embed/preview/PNaGbb" style="width:50%; height:50%;"></iframe>`
95+ ) ;
96+ } ) ;
97+
8998test ( 'Plugin can transform CodePen links' , async ( ) => {
9099 const markdownAST = getMarkdownASTForFile ( 'CodePen' ) ;
91100
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export const shouldTransform = (url) => {
77 ) ;
88} ;
99
10- export const getHTML = ( url ) => {
10+ export const getHTML = ( url , { width = '100%' , height = '300px' } ) => {
1111 const iframeUrl = url . replace ( '/pen/' , '/embed/preview/' ) ;
1212
13- return `<iframe src="${ iframeUrl } " style="width:100% ; height:300px ;"></iframe>` ;
13+ return `<iframe src="${ iframeUrl } " style="width:${ width } ; height:${ height } ;"></iframe>` ;
1414} ;
You can’t perform that action at this time.
0 commit comments