-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preserve asset's search and hash (#621)
- Loading branch information
1 parent
8667d2b
commit d7098ce
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const {strictEqual} = require('assert'); | ||
const Asset = require('../src/Asset'); | ||
|
||
describe('Asset', () => { | ||
describe('addURLDependency', () => { | ||
const bundleName = 'xyz'; | ||
const options = { | ||
rootDir: '/root/dir', | ||
parser: { | ||
getAsset: () => { | ||
return { | ||
generateBundleName: () => bundleName | ||
}; | ||
} | ||
} | ||
}; | ||
const asset = new Asset('test', undefined, options); | ||
|
||
it('should ignore urls', () => { | ||
const url = 'https://parceljs.org/assets.html'; | ||
strictEqual(asset.addURLDependency(url), url); | ||
}); | ||
|
||
it('should ignore empty string', () => { | ||
strictEqual(asset.addURLDependency(''), ''); | ||
}); | ||
|
||
it('should generate bundle name', () => { | ||
strictEqual(asset.addURLDependency('foo'), bundleName); | ||
}); | ||
|
||
it('should preserve query and hash', () => { | ||
strictEqual(asset.addURLDependency('foo#bar'), `${bundleName}#bar`); | ||
strictEqual(asset.addURLDependency('foo?bar'), `${bundleName}?bar`); | ||
strictEqual( | ||
asset.addURLDependency('foo?bar#baz'), | ||
`${bundleName}?bar#baz` | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters