Skip to content

Commit

Permalink
fix: update test case for template.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JuniorTour committed Sep 10, 2023
1 parent eadd42a commit 483e7dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/command-line-config/dist/resource-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Add resource hint link element, eg: <link rel="prefetch" href="${targetPath}">
*/
try {
(function (prefetchFilesPath, preconnectDomains) {
const crossOriginAttrVal = undefined || '';
const CDN_HOST = 'https://a.com/static/' || window.cdnPath;
const crossOriginAttrVal = undefined;
const CDN_HOST = 'https://a.com/static/';
if (!prefetchFilesPath || !prefetchFilesPath.length) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions test/command-line-config/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('Basic resource hint generator', () => {

const fileContent = getFileContent(resourceHintJSFilePath)
expect(fileContent).toMatch(`'/a.js','/b.css','first/first.js','second/second.js',`)
expect(fileContent).toMatch(`const CDN_HOST = '' || window.cdnPath;`)
expect(fileContent).toMatch(`const crossOriginAttrVal = undefined || '';`)
expect(fileContent).toMatch(`const CDN_HOST = ''`)
expect(fileContent).toMatch(`const crossOriginAttrVal = undefined;`)
});

test('should generate preconnect resource hint', async () => {
Expand All @@ -57,8 +57,8 @@ describe('Basic resource hint generator', () => {

const fileContent = getFileContent(resourceHintJSFilePath)
expect(fileContent).toMatch(`['/${includeFiles}',]`)
expect(fileContent).toMatch(`const CDN_HOST = '${publicPath}' || window.cdnPath;`)
expect(fileContent).toMatch(`const CDN_HOST = '${publicPath}'`)
expect(fileContent).toMatch(`['${preconnectDomains}',]`)
expect(fileContent).toMatch(`const crossOriginAttrVal = undefined || '';`)
expect(fileContent).toMatch(`const crossOriginAttrVal = undefined`)
});
});
4 changes: 2 additions & 2 deletions test/file-config/dist/resource-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Add resource hint link element, eg: <link rel="prefetch" href="${targetPath}">
*/
try {
(function (prefetchFilesPath, preconnectDomains) {
const crossOriginAttrVal = '' || '';
const CDN_HOST = 'https://config.com/static/' || window.cdnPath;
const crossOriginAttrVal = '';
const CDN_HOST = 'https://config.com/static/';
if (!prefetchFilesPath || !prefetchFilesPath.length) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/file-config/file-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ describe('Resource hint generator file config', () => {
expect(fileContent).toMatch(name);
})
expect(fileContent).toMatch(
`const CDN_HOST = '${config.publicPath}' || window.cdnPath;`
`const CDN_HOST = '${config.publicPath}'`
);
expect(fileContent).toMatch(`['${config.preconnectDomains}',]`);
const crossOriginValue = typeof config.crossOriginValue === 'string'
? `'${config.crossOriginValue}'`
: config.crossOriginValue
expect(fileContent).toMatch(
`const crossOriginAttrVal = ${crossOriginValue} || '';`
`const crossOriginAttrVal = ${crossOriginValue}`
);
});
});

0 comments on commit 483e7dd

Please sign in to comment.