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
8af1326a
Unverified
Commit
8af1326a
authored
Mar 19, 2019
by
Torkel Ödegaard
Committed by
GitHub
Mar 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16075 from grafana/fix-thresholds-tests
Fix for Thresholds tests
parents
d9db457b
d075af2b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
17 deletions
+34
-17
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.story.tsx
+16
-0
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.test.tsx
+16
-15
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx
+2
-2
packages/grafana-ui/src/components/ThresholdsEditor/__snapshots__/ThresholdsEditor.test.tsx.snap
+0
-0
No files found.
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.story.tsx
0 → 100644
View file @
8af1326a
import
React
from
'react'
;
import
{
storiesOf
}
from
'@storybook/react'
;
import
{
action
}
from
'@storybook/addon-actions'
;
import
{
ThresholdsEditor
}
from
'./ThresholdsEditor'
;
const
ThresholdsEditorStories
=
storiesOf
(
'UI/ThresholdsEditor'
,
module
);
const
thresholds
=
[{
index
:
0
,
value
:
-
Infinity
,
color
:
'green'
},
{
index
:
1
,
value
:
50
,
color
:
'red'
}];
ThresholdsEditorStories
.
add
(
'default'
,
()
=>
{
return
<
ThresholdsEditor
thresholds=
{
[]
}
onChange=
{
action
(
'Thresholds changed'
)
}
/>;
});
ThresholdsEditorStories
.
add
(
'with thresholds'
,
()
=>
{
return
<
ThresholdsEditor
thresholds=
{
thresholds
}
onChange=
{
action
(
'Thresholds changed'
)
}
/>;
});
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.test.tsx
View file @
8af1326a
import
React
,
{
ChangeEvent
}
from
'react'
;
import
React
,
{
ChangeEvent
}
from
'react'
;
import
{
mount
}
from
'enzyme'
;
import
{
mount
}
from
'enzyme'
;
import
{
ThresholdsEditor
,
Props
}
from
'./ThresholdsEditor'
;
import
{
ThresholdsEditor
,
Props
}
from
'./ThresholdsEditor'
;
import
{
colors
}
from
'../../utils'
;
const
setup
=
(
propOverrides
?:
Partial
<
Props
>
)
=>
{
const
setup
=
(
propOverrides
?:
Partial
<
Props
>
)
=>
{
const
props
:
Props
=
{
const
props
:
Props
=
{
...
@@ -31,7 +32,7 @@ describe('Initialization', () => {
...
@@ -31,7 +32,7 @@ describe('Initialization', () => {
it
(
'should add a base threshold if missing'
,
()
=>
{
it
(
'should add a base threshold if missing'
,
()
=>
{
const
{
instance
}
=
setup
();
const
{
instance
}
=
setup
();
expect
(
instance
.
state
.
thresholds
).
toEqual
([{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
}]);
expect
(
instance
.
state
.
thresholds
).
toEqual
([{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
}]);
});
});
});
});
...
@@ -41,7 +42,7 @@ describe('Add threshold', () => {
...
@@ -41,7 +42,7 @@ describe('Add threshold', () => {
instance
.
onAddThreshold
(
0
);
instance
.
onAddThreshold
(
0
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
}]);
expect
(
instance
.
state
.
thresholds
).
toEqual
([{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
}]);
});
});
it
(
'should add threshold'
,
()
=>
{
it
(
'should add threshold'
,
()
=>
{
...
@@ -50,41 +51,41 @@ describe('Add threshold', () => {
...
@@ -50,41 +51,41 @@ describe('Add threshold', () => {
instance
.
onAddThreshold
(
1
);
instance
.
onAddThreshold
(
1
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
},
{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
},
{
index
:
1
,
value
:
50
,
color
:
'#EAB839'
},
{
index
:
1
,
value
:
50
,
color
:
colors
[
2
]
},
]);
]);
});
});
it
(
'should add another threshold above a first'
,
()
=>
{
it
(
'should add another threshold above a first'
,
()
=>
{
const
{
instance
}
=
setup
({
const
{
instance
}
=
setup
({
thresholds
:
[{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
},
{
index
:
1
,
value
:
50
,
color
:
'#EAB839'
}],
thresholds
:
[{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
},
{
index
:
1
,
value
:
50
,
color
:
colors
[
2
]
}],
});
});
instance
.
onAddThreshold
(
2
);
instance
.
onAddThreshold
(
2
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
},
{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
},
{
index
:
1
,
value
:
50
,
color
:
'#EAB839'
},
{
index
:
1
,
value
:
50
,
color
:
colors
[
2
]
},
{
index
:
2
,
value
:
75
,
color
:
'#6ED0E0'
},
{
index
:
2
,
value
:
75
,
color
:
colors
[
3
]
},
]);
]);
});
});
it
(
'should add another threshold between first and second index'
,
()
=>
{
it
(
'should add another threshold between first and second index'
,
()
=>
{
const
{
instance
}
=
setup
({
const
{
instance
}
=
setup
({
thresholds
:
[
thresholds
:
[
{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
},
{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
},
{
index
:
1
,
value
:
50
,
color
:
'#EAB839'
},
{
index
:
1
,
value
:
50
,
color
:
colors
[
2
]
},
{
index
:
2
,
value
:
75
,
color
:
'#6ED0E0'
},
{
index
:
2
,
value
:
75
,
color
:
colors
[
3
]
},
],
],
});
});
instance
.
onAddThreshold
(
2
);
instance
.
onAddThreshold
(
2
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
value
:
-
Infinity
,
color
:
'#7EB26D'
},
{
index
:
0
,
value
:
-
Infinity
,
color
:
colors
[
0
]
},
{
index
:
1
,
value
:
50
,
color
:
'#EAB839'
},
{
index
:
1
,
value
:
50
,
color
:
colors
[
2
]
},
{
index
:
2
,
value
:
62.5
,
color
:
'#EF843C'
},
{
index
:
2
,
value
:
62.5
,
color
:
colors
[
4
]
},
{
index
:
3
,
value
:
75
,
color
:
'#6ED0E0'
},
{
index
:
3
,
value
:
75
,
color
:
colors
[
3
]
},
]);
]);
});
});
});
});
...
...
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx
View file @
8af1326a
...
@@ -3,8 +3,8 @@ import { Threshold } from '../../types';
...
@@ -3,8 +3,8 @@ import { Threshold } from '../../types';
import
{
ColorPicker
}
from
'..'
;
import
{
ColorPicker
}
from
'..'
;
import
{
PanelOptionsGroup
}
from
'..'
;
import
{
PanelOptionsGroup
}
from
'..'
;
import
{
colors
}
from
'../../utils'
;
import
{
colors
}
from
'../../utils'
;
import
{
ThemeContext
}
from
'../../themes
/ThemeContext
'
;
import
{
ThemeContext
}
from
'../../themes'
;
import
{
getColorFromHexRgbOrName
}
from
'../../utils
/namedColorsPalette
'
;
import
{
getColorFromHexRgbOrName
}
from
'../../utils'
;
export
interface
Props
{
export
interface
Props
{
thresholds
:
Threshold
[];
thresholds
:
Threshold
[];
...
...
packages/grafana-ui/src/components/ThresholdsEditor/__snapshots__/ThresholdsEditor.test.tsx.snap
View file @
8af1326a
This diff is collapsed.
Click to expand it.
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