Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
76ba7d1f
Commit
76ba7d1f
authored
Dec 21, 2017
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Add snapshot tests for UserPicker and UserPickerOption (#10289)
parent
68d43b86
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
172 additions
and
18 deletions
+172
-18
public/app/core/components/EmptyListCTA/EmptyListCTA.jest.tsx
+10
-11
public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.jest.tsx.snap
+1
-1
public/app/core/components/UserPicker/UserPicker.jest.tsx
+20
-0
public/app/core/components/UserPicker/UserPickerOption.jest.tsx
+22
-0
public/app/core/components/UserPicker/UserPickerOption.tsx
+4
-6
public/app/core/components/UserPicker/__snapshots__/UserPicker.jest.tsx.snap
+98
-0
public/app/core/components/UserPicker/__snapshots__/UserPickerOption.jest.tsx.snap
+17
-0
No files found.
public/app/core/components/EmptyListCTA/EmptyListCTA.jest.tsx
View file @
76ba7d1f
...
...
@@ -3,19 +3,18 @@ import renderer from 'react-test-renderer';
import
EmptyListCTA
from
'./EmptyListCTA'
;
const
model
=
{
title
:
'Title'
,
buttonIcon
:
'ga css class'
,
buttonLink
:
'http://url/to/destination'
,
buttonTitle
:
'Click me'
,
proTip
:
'This is a tip'
,
proTipLink
:
'http://url/to/tip/destination'
,
proTipLinkTitle
:
'Learn more'
,
proTipTarget
:
'_blank'
title
:
'Title'
,
buttonIcon
:
'ga css class'
,
buttonLink
:
'http://url/to/destination'
,
buttonTitle
:
'Click me'
,
proTip
:
'This is a tip'
,
proTipLink
:
'http://url/to/tip/destination'
,
proTipLinkTitle
:
'Learn more'
,
proTipTarget
:
'_blank'
,
};
describe
(
'CollorPalette'
,
()
=>
{
it
(
'renders correctly'
,
()
=>
{
describe
(
'EmptyListCTA'
,
()
=>
{
it
(
'renders correctly'
,
()
=>
{
const
tree
=
renderer
.
create
(<
EmptyListCTA
model=
{
model
}
/>).
toJSON
();
expect
(
tree
).
toMatchSnapshot
();
});
...
...
public/app/core/components/EmptyListCTA/__snapshots__/EmptyListCTA.jest.tsx.snap
View file @
76ba7d1f
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`
CollorPalette
renders correctly 1`] = `
exports[`
EmptyListCTA
renders correctly 1`] = `
<div
className="empty-list-cta"
>
...
...
public/app/core/components/UserPicker/UserPicker.jest.tsx
0 → 100644
View file @
76ba7d1f
import
React
from
'react'
;
import
renderer
from
'react-test-renderer'
;
import
UserPicker
from
'./UserPicker'
;
const
model
=
{
backendSrv
:
{
get
:
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{});
},
},
refreshList
:
()
=>
{},
teamId
:
'1'
,
};
describe
(
'UserPicker'
,
()
=>
{
it
(
'renders correctly'
,
()
=>
{
const
tree
=
renderer
.
create
(<
UserPicker
{
...
model
}
/>).
toJSON
();
expect
(
tree
).
toMatchSnapshot
();
});
});
public/app/core/components/UserPicker/UserPickerOption.jest.tsx
0 → 100644
View file @
76ba7d1f
import
React
from
'react'
;
import
renderer
from
'react-test-renderer'
;
import
UserPickerOption
from
'./UserPickerOption'
;
const
model
=
{
onSelect
:
()
=>
{},
onFocus
:
()
=>
{},
isFocused
:
()
=>
{},
option
:
{
title
:
'Model title'
,
avatarUrl
:
'url/to/avatar'
,
label
:
'User picker label'
,
},
className
:
'class-for-user-picker'
,
};
describe
(
'UserPickerOption'
,
()
=>
{
it
(
'renders correctly'
,
()
=>
{
const
tree
=
renderer
.
create
(<
UserPickerOption
{
...
model
}
/>).
toJSON
();
expect
(
tree
).
toMatchSnapshot
();
});
});
public/app/core/components/UserPicker/UserPickerOption.tsx
View file @
76ba7d1f
import
React
,
{
Component
}
from
"react"
;
import
React
,
{
Component
}
from
'react'
;
export
interface
IProps
{
onSelect
:
any
;
onFocus
:
any
;
...
...
@@ -19,9 +19,11 @@ class UserPickerOption extends Component<IProps, any> {
event
.
stopPropagation
();
this
.
props
.
onSelect
(
this
.
props
.
option
,
event
);
}
handleMouseEnter
(
event
)
{
this
.
props
.
onFocus
(
this
.
props
.
option
,
event
);
}
handleMouseMove
(
event
)
{
if
(
this
.
props
.
isFocused
)
{
return
;
...
...
@@ -40,11 +42,7 @@ class UserPickerOption extends Component<IProps, any> {
title=
{
option
.
title
}
className=
{
`user-picker-option__button btn btn-link ${className}`
}
>
<
img
src=
{
option
.
avatarUrl
}
alt=
{
option
.
label
}
className=
"user-picker-option__avatar"
/>
<
img
src=
{
option
.
avatarUrl
}
alt=
{
option
.
label
}
className=
"user-picker-option__avatar"
/>
{
children
}
</
button
>
);
...
...
public/app/core/components/UserPicker/__snapshots__/UserPicker.jest.tsx.snap
0 → 100644
View file @
76ba7d1f
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UserPicker renders correctly 1`] = `
<div
className="user-picker"
>
<div
className="Select width-8 gf-form-input gf-form-input--form-dropdown Select--single is-clearable is-loading is-searchable"
style={undefined}
>
<div
className="Select-control"
onKeyDown={[Function]}
onMouseDown={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
style={undefined}
>
<span
className="Select-multi-value-wrapper"
id="react-select-2--value"
>
<div
className="Select-placeholder"
>
Loading...
</div>
<div
className="Select-input"
style={
Object {
"display": "inline-block",
}
}
>
<input
aria-activedescendant="react-select-2--value"
aria-describedby={undefined}
aria-expanded="false"
aria-haspopup="false"
aria-label={undefined}
aria-labelledby={undefined}
aria-owns=""
className={undefined}
id={undefined}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
required={false}
role="combobox"
style={
Object {
"boxSizing": "content-box",
"width": "5px",
}
}
tabIndex={undefined}
value=""
/>
<div
style={
Object {
"height": 0,
"left": 0,
"overflow": "scroll",
"position": "absolute",
"top": 0,
"visibility": "hidden",
"whiteSpace": "pre",
}
}
>
</div>
</div>
</span>
<span
aria-hidden="true"
className="Select-loading-zone"
>
<span
className="Select-loading"
/>
</span>
<span
className="Select-arrow-zone"
onMouseDown={[Function]}
>
<span
className="Select-arrow"
onMouseDown={[Function]}
/>
</span>
</div>
</div>
</div>
`;
public/app/core/components/UserPicker/__snapshots__/UserPickerOption.jest.tsx.snap
0 → 100644
View file @
76ba7d1f
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UserPickerOption renders correctly 1`] = `
<button
className="user-picker-option__button btn btn-link class-for-user-picker"
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseMove={[Function]}
title="Model title"
>
<img
alt="User picker label"
className="user-picker-option__avatar"
src="url/to/avatar"
/>
</button>
`;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment