This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #491 PR: Srcset regex should match any valid image candidate st…
…ring.
- Loading branch information
1 parent
2e54488
commit fa26713
Showing
2 changed files
with
41 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -429,15 +429,53 @@ describe('FileProcessor', function () { | |
}); | ||
|
||
it('should replace img reference in srcset', function () { | ||
var content = '<img srcset="image.png" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<img srcset="' + filemapping['app/image.png'] + '" />'); | ||
}); | ||
|
||
it('should replace img reference in srcset with pixel density descriptor', function () { | ||
var content = '<img srcset="[email protected] 2x" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<img srcset="' + filemapping['app/[email protected]'] + ' 2x" />'); | ||
}); | ||
|
||
content = '<source srcset="[email protected] 2x" />'; | ||
replaced = fp.replaceWithRevved(content, ['app']); | ||
it('should replace img reference in srcset with width descriptor', function () { | ||
var content = '<img srcset="image.png 200w" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<img srcset="' + filemapping['app/image.png'] + ' 200w" />'); | ||
}); | ||
|
||
it('should replace img reference in srcset with pixel density descriptor and with width descriptor', function () { | ||
var content = '<img srcset="image.png 200w 2x" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<img srcset="' + filemapping['app/image.png'] + ' 200w 2x" />'); | ||
}); | ||
|
||
it('should replace source reference in srcset', function () { | ||
var content = '<source srcset="image.png" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<source srcset="' + filemapping['app/image.png'] + '" />'); | ||
}); | ||
|
||
it('should replace source reference in srcset with pixel density descriptor', function () { | ||
var content = '<source srcset="[email protected] 2x" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<source srcset="' + filemapping['app/[email protected]'] + ' 2x" />'); | ||
}); | ||
|
||
it('should replace source reference in srcset with width descriptor', function () { | ||
var content = '<source srcset="image.png 200w" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<source srcset="' + filemapping['app/image.png'] + ' 200w" />'); | ||
}); | ||
|
||
it('should replace source reference in srcset with pixel density descriptor and with width descriptor', function () { | ||
var content = '<source srcset="image.png 200w 2x" />'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
assert.equal(replaced, '<source srcset="' + filemapping['app/image.png'] + ' 200w 2x" />'); | ||
}); | ||
|
||
it('should replace svg src reference with revved version for img tag', function () { | ||
var content = '<img src="image.svg#symbol">'; | ||
var replaced = fp.replaceWithRevved(content, ['app']); | ||
|