-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix toTokenizedValue() execution with URL values (#1066)
* changed toTokenizedValue.js * add tests for issue #986 Co-authored-by: wicaksa <wicaksa_r@yahoo.com> Co-authored-by: sarahhling <sarahling1103@gmail.com> Co-authored-by: hnadrian <hngt.adrian@gmail.com> Co-authored-by: wicaksa <wicaksa_r@yahoo.com> Co-authored-by: Mingjie Jiang <jiang@mingjie.dev> Co-authored-by: hnadrian <hngt.adrian@gmail.com>
- Loading branch information
1 parent
241e87e
commit aa59b01
Showing
2 changed files
with
34 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { toTokenizedValue } from '../src/convert/toTokenizedValue.js' | ||
|
||
describe('Issue #986', () => { | ||
const sampleURL = 'https://example.com/images/some-url-string-1--Version-6.jpg' | ||
|
||
test('url only', () => { | ||
const tokenizedUrlOnly = toTokenizedValue(`url(${sampleURL})`, '', '') | ||
expect(tokenizedUrlOnly).toBe(`url(${sampleURL})`) | ||
}) | ||
|
||
test('url with additional properties before or after', () => { | ||
const tokenizedConstantSuffix = toTokenizedValue(`url(${sampleURL}) fixed`, '', '') | ||
expect(tokenizedConstantSuffix).toBe(`url(${sampleURL}) fixed`) | ||
|
||
const tokenizedConstantPrefix = toTokenizedValue(`repeat url(${sampleURL})`, '', '') | ||
expect(tokenizedConstantPrefix).toBe(`repeat url(${sampleURL})`) | ||
|
||
const tokenizedVariableSuffix = toTokenizedValue(`url(${sampleURL}) -1--Version-6`, '', '') | ||
expect(tokenizedVariableSuffix).toBe(`url(${sampleURL}) calc(var(--Version-6)*-1)`) | ||
|
||
const tokenizedVariablePrefix = toTokenizedValue(`-1--Version-6 url(${sampleURL})`, '', '') | ||
expect(tokenizedVariablePrefix).toBe(`calc(var(--Version-6)*-1) url(${sampleURL})`) | ||
}) | ||
|
||
test('url with additional properties both before and after', () => { | ||
const tokenizedConstantPrePostfix = toTokenizedValue(`repeat url(${sampleURL}) fixed`, '', '') | ||
expect(tokenizedConstantPrePostfix).toBe(`repeat url(${sampleURL}) fixed`) | ||
|
||
const tokenizedVariablePrePostfix = toTokenizedValue(`-1--Version-6 url(${sampleURL}) -1--Version-7`, '', '') | ||
expect(tokenizedVariablePrePostfix).toBe(`calc(var(--Version-6)*-1) url(${sampleURL}) calc(var(--Version-7)*-1)`) | ||
|
||
}) | ||
}) |