File tree Expand file tree Collapse file tree 6 files changed +354
-18
lines changed Expand file tree Collapse file tree 6 files changed +354
-18
lines changed Original file line number Diff line number Diff line change
1
+ // This file is needed because it is used by vscode and other tools that
2
+ // call `jest` directly. However, unless you are doing anything special
3
+ // do not edit this file
4
+
5
+ const standard = require ( '@grafana/toolkit/src/config/jest.plugin.config' ) ;
6
+
7
+ // This process will use the same config that `yarn test` is using
8
+ module . exports = standard . jestConfig ( ) ;
9
+ module . exports . setupFiles . push ( './src/jest.setup.ts' ) ;
Original file line number Diff line number Diff line change 17
17
},
18
18
"devDependencies" : {
19
19
"@grafana/data" : " next" ,
20
+ "@grafana/runtime" : " next" ,
20
21
"@grafana/toolkit" : " next" ,
21
22
"@grafana/ui" : " next" ,
22
- "@grafana/runtime" : " next" ,
23
- "emotion" : " 10.0.27"
23
+ "emotion" : " 10.0.27" ,
24
+ "enzyme" : " ^3.11.0" ,
25
+ "enzyme-adapter-react-16" : " 1.15.2"
24
26
}
25
27
}
Original file line number Diff line number Diff line change
1
+ import {
2
+ DefaultTimeRange ,
3
+ DefaultTimeZone ,
4
+ LoadingState ,
5
+ PanelProps ,
6
+ } from '@grafana/data' ;
7
+ import { mount } from 'enzyme' ;
8
+ import React from 'react' ;
9
+ import { Options } from 'types' ;
10
+ import { ButtonPanel } from './buttonPanel' ;
11
+
12
+ describe ( 'button panel' , ( ) => {
13
+ test ( 'panel' , ( ) => {
14
+ let props : PanelProps < Options > = {
15
+ id : 1 ,
16
+ data : {
17
+ timeRange : DefaultTimeRange ,
18
+ state : LoadingState . Done ,
19
+ series : [ ] ,
20
+ } ,
21
+ fieldConfig : { defaults : { } , overrides : [ ] } ,
22
+ height : 1 ,
23
+ transparent : false ,
24
+ width : 2 ,
25
+ onChangeTimeRange : ( ) => { } ,
26
+ onFieldConfigChange : ( ) => { } ,
27
+ onOptionsChange : ( ) => { } ,
28
+ renderCounter : 1 ,
29
+ replaceVariables : ( ) => '' ,
30
+ timeRange : DefaultTimeRange ,
31
+ timeZone : DefaultTimeZone ,
32
+ options : {
33
+ buttons : [ ] ,
34
+ orientation : 'horizontal' ,
35
+ } as Options ,
36
+ } ;
37
+
38
+ mount ( < ButtonPanel { ...props } /> ) ;
39
+ } ) ;
40
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import Enzyme from 'enzyme' ;
2
+ import Adapter from 'enzyme-adapter-react-16' ;
3
+ Enzyme . configure ( { adapter : new Adapter ( ) } ) ;
Original file line number Diff line number Diff line change 1
- // Just a stub test
2
- describe ( 'placeholder test' , ( ) => {
3
- it ( 'should return true' , ( ) => {
4
- expect ( true ) . toBeTruthy ( ) ;
1
+ import { standardEditorsRegistry } from '@grafana/data' ;
2
+ import { plugin } from './module' ;
3
+
4
+ describe ( 'button plugin' , ( ) => {
5
+ test ( 'editor options' , ( ) => {
6
+ standardEditorsRegistry . setInit ( ( ) => {
7
+ return [ { id : 'radio' } ] as any ;
8
+ } ) ;
9
+ expect ( plugin . optionEditors ) . toBeDefined ( ) ;
10
+ expect ( plugin . optionEditors ?. list ( ) ) . toHaveLength ( 2 ) ;
5
11
} ) ;
6
12
} ) ;
You can’t perform that action at this time.
0 commit comments