diff --git a/__tests__/preprocessor.test.js b/__tests__/preprocessor.test.js index 511240569c..bf3cf43973 100644 --- a/__tests__/preprocessor.test.js +++ b/__tests__/preprocessor.test.js @@ -55,7 +55,19 @@ const sources = [ '../media-box.component.scss', './media-box-h0.component.scss' ], -})` +})`, + // double quote + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: "./media-box-h0.component.html", + styleUrls: [ '../media-box.component.scss' ], +})`, + // backtick + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: \`./media-box-h0.component.html\`, + styleUrls: [ '../media-box.component.scss' ], +})`, ]; const config = { @@ -72,7 +84,7 @@ sources.forEach(source => { const result = process(source, '', config); expect(result).toMatch('styles: []'); expect(result).toMatch( - "template: require('./media-box-h0.component.html')" + /template: require\(['"`]\.\/media-box-h0\.component\.html['"`]\)/ ); }); }); diff --git a/preprocessor.js b/preprocessor.js index 6234c9fbce..0493dc4193 100644 --- a/preprocessor.js +++ b/preprocessor.js @@ -1,5 +1,5 @@ const process = require('ts-jest').process; -const TEMPLATE_URL_REGEX = /templateUrl\s*:\s*('|")(\.\/){0,}(.*)('|")/g; +const TEMPLATE_URL_REGEX = /templateUrl\s*:\s*('|"|`)(\.\/){0,}(.*)('|"|`)/g; const STYLE_URLS_REGEX = /styleUrls\s*:\s*\[[^\]]*\]/g; const ESCAPE_TEMPLATE_REGEX = /(\${|\`)/g;