-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the correct serializer based on the direction value (#350)
- Loading branch information
1 parent
0590bc0
commit dcd6f12
Showing
5 changed files
with
57 additions
and
10 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
37 changes: 37 additions & 0 deletions
37
packages/pigment-css-react/tests/utils/preprocessor.test.ts
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,37 @@ | ||
import { expect } from 'chai'; | ||
import { preprocessor } from '@pigment-css/react/utils'; | ||
|
||
describe('preprocessor', () => { | ||
it('should preprocess selector and css by default to ltr', () => { | ||
const res = preprocessor('.hello', 'padding-left: 10px; transform: translate(10px, 20px)'); | ||
expect(res).to.equal('.hello{padding-left:10px;transform:translate(10px, 20px);}'); | ||
}); | ||
|
||
it('should preprocess selector and css to rtl when specified', () => { | ||
const res = preprocessor('.hello', 'padding-left: 10px; transform: translate(10px, 20px)', { | ||
defaultDirection: 'rtl', | ||
generateForBothDir: false, | ||
}); | ||
expect(res).to.equal('.hello{padding-right:10px;transform:translate(-10px, 20px);}'); | ||
}); | ||
|
||
it('should generate both rtl and ltr css when "generateForBothDir" is true', () => { | ||
expect( | ||
preprocessor('.hello', 'padding-left: 10px; transform: translate(10px, 20px)', { | ||
defaultDirection: 'ltr', | ||
generateForBothDir: true, | ||
}), | ||
).to.equal( | ||
'.hello{padding-left:10px;transform:translate(10px, 20px);}[dir=rtl] .hello{padding-right:10px;transform:translate(-10px, 20px);}', | ||
); | ||
|
||
expect( | ||
preprocessor('.hello', 'padding-right: 10px; transform: translate(-10px, 20px)', { | ||
defaultDirection: 'rtl', | ||
generateForBothDir: true, | ||
}), | ||
).to.equal( | ||
'.hello{padding-left:10px;transform:translate(10px, 20px);}[dir=ltr] .hello{padding-right:10px;transform:translate(-10px, 20px);}', | ||
); | ||
}); | ||
}); |
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