-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create appearence and margins tests.
- Loading branch information
1 parent
3ae2cb5
commit 13c1711
Showing
4 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/style-value-parser/src/properties/__tests__/appearance.test.js
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,35 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
*/ | ||
import { Appearance } from '../appearance'; | ||
describe('Test CSS property: `appearance`', () => { | ||
test('CSS Basic User Interface Module Level 4 values', () => { | ||
expect(Appearance.parse.parseToEnd('auto')).toEqual(new Appearance('auto')); | ||
expect(Appearance.parse.parseToEnd('none')).toEqual(new Appearance('none')); | ||
expect(Appearance.parse.parseToEnd('menulist-button')).toEqual( | ||
new Appearance('menulist-button'), | ||
); | ||
expect(Appearance.parse.parseToEnd('textfield')).toEqual( | ||
new Appearance('textfield'), | ||
); | ||
}); | ||
test('CSS wide keyword values', () => { | ||
expect(Appearance.parse.parseToEnd('inherit')).toEqual( | ||
new Appearance('inherit'), | ||
); | ||
expect(Appearance.parse.parseToEnd('initial')).toEqual( | ||
new Appearance('initial'), | ||
); | ||
expect(Appearance.parse.parseToEnd('revert')).toEqual( | ||
new Appearance('revert'), | ||
); | ||
expect(Appearance.parse.parseToEnd('unset')).toEqual( | ||
new Appearance('auto'), | ||
); | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
packages/style-value-parser/src/properties/__tests__/margins.test.js
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,72 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
*/ | ||
import { Percentage } from '../../css-types/common-types'; | ||
import { Ch, Em, In, Px, Rem, Vh, Vw } from '../../css-types/length'; | ||
import { | ||
MarginDir, | ||
marginBlock, | ||
marginBlockEnd, | ||
marginBlockStart, | ||
marginBottom, | ||
marginInline, | ||
marginInlineEnd, | ||
marginInlineStart, | ||
marginLeft, | ||
marginRight, | ||
marginTop, | ||
} from '../margins'; | ||
describe('Test CSS property: `margin`', () => { | ||
test('Test all margin CSS shorthand properties', () => { | ||
expect(marginTop.parse.parseToEnd('25px')).toEqual( | ||
new MarginDir(new Px(25)), | ||
); | ||
expect(marginLeft.parse.parseToEnd('5%')).toEqual( | ||
new MarginDir(new Percentage(5)), | ||
); | ||
expect(marginRight.parse.parseToEnd('5em')).toEqual( | ||
new MarginDir(new Em(5)), | ||
); | ||
expect(marginBottom.parse.parseToEnd('5vh')).toEqual( | ||
new MarginDir(new Vh(5)), | ||
); | ||
expect(marginBlock.parse.parseToEnd('5in')).toEqual( | ||
new MarginDir(new In(5)), | ||
); | ||
expect(marginBlockEnd.parse.parseToEnd('5vw')).toEqual( | ||
new MarginDir(new Vw(5)), | ||
); | ||
expect(marginBlockStart.parse.parseToEnd('5ch')).toEqual( | ||
new MarginDir(new Ch(5)), | ||
); | ||
expect(marginInline.parse.parseToEnd('5%')).toEqual( | ||
new MarginDir(new Percentage(5)), | ||
); | ||
expect(marginInlineEnd.parse.parseToEnd('5px')).toEqual( | ||
new MarginDir(new Px(5)), | ||
); | ||
expect(marginInlineStart.parse.parseToEnd('5rem')).toEqual( | ||
new MarginDir(new Rem(5)), | ||
); | ||
}); | ||
|
||
test('CSS wide keyword values', () => { | ||
expect(marginTop.parse.parseToEnd('inherit')).toEqual( | ||
new MarginDir('inherit'), | ||
); | ||
expect(marginLeft.parse.parseToEnd('initial')).toEqual( | ||
new MarginDir('initial'), | ||
); | ||
expect(marginRight.parse.parseToEnd('revert')).toEqual( | ||
new MarginDir('revert'), | ||
); | ||
expect(marginBottom.parse.parseToEnd('unset')).toEqual( | ||
new MarginDir('unset'), | ||
); | ||
}); | ||
}); |
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