Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
263 additions
and
79 deletions.
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
packages/paste-core/components/label/__tests__/__snapshots__/label.test.tsx.snap
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,188 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Label render it should render 1`] = ` | ||
<DocumentFragment> | ||
.emotion-3 { | ||
color: rgb(40,42,43); | ||
font-size: 0.875rem; | ||
font-family: 'Whitney SSm A','Whitney SSm B','Helvetica Neue',Helvetica,Arial,sans-serif; | ||
line-height: 1.25rem; | ||
font-weight: 400; | ||
} | ||
.emotion-2 { | ||
box-sizing: border-box; | ||
border-bottom-width: 0; | ||
display: block; | ||
margin-bottom: 0.25rem; | ||
padding-left: 0; | ||
padding-right: 0; | ||
text-transform: none; | ||
} | ||
.emotion-1 { | ||
box-sizing: border-box; | ||
-webkit-box-pack: start; | ||
-webkit-justify-content: flex-start; | ||
-ms-flex-pack: start; | ||
justify-content: flex-start; | ||
-webkit-align-items: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
min-width: 0; | ||
} | ||
.emotion-0 { | ||
margin: 0; | ||
padding: 0; | ||
font-size: 0.875rem; | ||
font-weight: 500; | ||
line-height: 1.25rem; | ||
color: rgb(40,42,43); | ||
cursor: pointer; | ||
} | ||
<div | ||
class="emotion-3" | ||
> | ||
<label | ||
class="emotion-2" | ||
display="block" | ||
for="input" | ||
> | ||
<span | ||
class="emotion-1" | ||
display="flex" | ||
> | ||
<span | ||
class="emotion-0" | ||
color="colorText" | ||
cursor="pointer" | ||
font-size="fontSize30" | ||
font-weight="fontWeightSemibold" | ||
> | ||
child | ||
</span> | ||
</span> | ||
</label> | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`Label render it should render with required 1`] = ` | ||
<DocumentFragment> | ||
.emotion-5 { | ||
color: rgb(40,42,43); | ||
font-size: 0.875rem; | ||
font-family: 'Whitney SSm A','Whitney SSm B','Helvetica Neue',Helvetica,Arial,sans-serif; | ||
line-height: 1.25rem; | ||
font-weight: 400; | ||
} | ||
.emotion-4 { | ||
box-sizing: border-box; | ||
border-bottom-width: 0; | ||
display: block; | ||
margin-bottom: 0.25rem; | ||
padding-left: 0; | ||
padding-right: 0; | ||
text-transform: none; | ||
} | ||
.emotion-3 { | ||
box-sizing: border-box; | ||
-webkit-box-pack: start; | ||
-webkit-justify-content: flex-start; | ||
-ms-flex-pack: start; | ||
justify-content: flex-start; | ||
-webkit-align-items: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
min-width: 0; | ||
} | ||
.emotion-2 { | ||
margin: 0; | ||
padding: 0; | ||
font-size: 0.875rem; | ||
font-weight: 500; | ||
line-height: 1.25rem; | ||
color: rgb(40,42,43); | ||
cursor: pointer; | ||
} | ||
.emotion-1 { | ||
box-sizing: border-box; | ||
background-color: rgb(222,88,88); | ||
border-radius: 50%; | ||
cursor: pointer; | ||
display: block; | ||
height: 4px; | ||
line-height: 1.25rem; | ||
margin-right: 0.25rem; | ||
width: 4px; | ||
} | ||
.emotion-0 { | ||
position: absolute; | ||
margin: -1px; | ||
border: 0; | ||
padding: 0; | ||
width: 1px; | ||
height: 1px; | ||
overflow: hidden; | ||
-webkit-clip: rect(0 0 0 0); | ||
clip: rect(0 0 0 0); | ||
text-transform: none; | ||
white-space: nowrap; | ||
} | ||
<div | ||
class="emotion-5" | ||
> | ||
<label | ||
class="emotion-4" | ||
display="block" | ||
for="input" | ||
> | ||
<span | ||
class="emotion-3" | ||
display="flex" | ||
> | ||
<span | ||
class="emotion-1" | ||
cursor="pointer" | ||
display="block" | ||
height="4px" | ||
width="4px" | ||
> | ||
<span | ||
class="emotion-0" | ||
> | ||
Required: | ||
</span> | ||
</span> | ||
<span | ||
class="emotion-2" | ||
color="colorText" | ||
cursor="pointer" | ||
font-size="fontSize30" | ||
font-weight="fontWeightSemibold" | ||
> | ||
child | ||
</span> | ||
</span> | ||
</label> | ||
</div> | ||
</DocumentFragment> | ||
`; |
56 changes: 0 additions & 56 deletions
56
packages/paste-core/components/label/__tests__/formlabel.test.tsx
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
packages/paste-core/components/label/__tests__/label.test.tsx
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,53 @@ | ||
import * as React from 'react'; | ||
import {render, screen} from '@testing-library/react'; | ||
import {Theme} from '@twilio-paste/theme'; | ||
import {Label} from '../src'; | ||
|
||
describe('Label render', () => { | ||
it('it should render', (): void => { | ||
const {asFragment} = render( | ||
<Theme.Provider theme="console"> | ||
<Label htmlFor="input">child</Label> | ||
</Theme.Provider> | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('it should render with required', (): void => { | ||
const {asFragment} = render( | ||
<Theme.Provider theme="console"> | ||
<Label htmlFor="input" required> | ||
child | ||
</Label> | ||
</Theme.Provider> | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('Label for prop', () => { | ||
const initialProps = { | ||
htmlFor: 'input', | ||
}; | ||
|
||
it('should have a for prop on label', () => { | ||
render( | ||
<Label data-testid="test-label" {...initialProps}> | ||
Label | ||
</Label> | ||
); | ||
expect(screen.getByTestId('test-label').getAttribute('for')).toEqual('input'); | ||
}); | ||
}); | ||
|
||
describe('Label required prop', () => { | ||
const initialProps = { | ||
htmlFor: 'input', | ||
required: true, | ||
}; | ||
|
||
it('should have a required indicator', () => { | ||
render(<Label {...initialProps}>label</Label>); | ||
expect(screen.getByText('Required:')).not.toBeNull(); | ||
}); | ||
}); |
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