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
94b8cbdc
Commit
94b8cbdc
authored
Jun 13, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Karma to Jest: exporter
parent
ff3db60e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
77 deletions
+83
-77
public/app/features/dashboard/specs/exporter.jest.ts
+83
-77
No files found.
public/app/features/dashboard/specs/exporter
_specs
.ts
→
public/app/features/dashboard/specs/exporter
.jest
.ts
View file @
94b8cbdc
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
}
from
'test/lib/common'
;
jest
.
mock
(
'app/core/store'
,
()
=>
{
return
{
getBool
:
jest
.
fn
(),
};
});
import
_
from
'lodash'
;
import
config
from
'app/core/config'
;
import
{
DashboardExporter
}
from
'../export/exporter'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
describe
(
'given dashboard with repeated panels'
,
function
()
{
describe
(
'given dashboard with repeated panels'
,
()
=>
{
var
dash
,
exported
;
beforeEach
(
done
=>
{
...
...
@@ -65,41 +69,43 @@ describe('given dashboard with repeated panels', function() {
});
dash
.
panels
.
push
({
id
:
3
,
repeat
:
null
,
repeatPanelId
:
2
});
var
datasourceSrvStub
=
{
get
:
sinon
.
stub
()
};
datasourceSrvStub
.
get
.
withArgs
(
'gfdb'
).
returns
(
Promise
.
resolve
({
name
:
'gfdb'
,
meta
:
{
id
:
'testdb'
,
info
:
{
version
:
'1.2.1'
},
name
:
'TestDB'
},
})
);
datasourceSrvStub
.
get
.
withArgs
(
'other'
).
returns
(
Promise
.
resolve
({
name
:
'other'
,
meta
:
{
id
:
'other'
,
info
:
{
version
:
'1.2.1'
},
name
:
'OtherDB'
},
})
);
datasourceSrvStub
.
get
.
withArgs
(
'-- Mixed --'
).
returns
(
Promise
.
resolve
({
name
:
'mixed'
,
meta
:
{
id
:
'mixed'
,
info
:
{
version
:
'1.2.1'
},
name
:
'Mixed'
,
builtIn
:
true
,
},
})
);
datasourceSrvStub
.
get
.
withArgs
(
'-- Grafana --'
).
returns
(
Promise
.
resolve
({
name
:
'-- Grafana --'
,
meta
:
{
id
:
'grafana'
,
info
:
{
version
:
'1.2.1'
},
name
:
'grafana'
,
builtIn
:
true
,
},
})
);
//Mock test function calls
var
datasourceSrvStub
=
{
get
:
jest
.
fn
(
arg
=>
{
if
(
arg
===
'gfdb'
)
{
return
Promise
.
resolve
({
name
:
'gfdb'
,
meta
:
{
id
:
'testdb'
,
info
:
{
version
:
'1.2.1'
},
name
:
'TestDB'
},
});
}
else
if
(
arg
===
'other'
)
{
return
Promise
.
resolve
({
name
:
'other'
,
meta
:
{
id
:
'other'
,
info
:
{
version
:
'1.2.1'
},
name
:
'OtherDB'
},
});
}
else
if
(
arg
===
'-- Mixed --'
)
{
return
Promise
.
resolve
({
name
:
'mixed'
,
meta
:
{
id
:
'mixed'
,
info
:
{
version
:
'1.2.1'
},
name
:
'Mixed'
,
builtIn
:
true
,
},
});
}
else
if
(
arg
===
'-- Grafana --'
)
{
return
Promise
.
resolve
({
name
:
'-- Grafana --'
,
meta
:
{
id
:
'grafana'
,
info
:
{
version
:
'1.2.1'
},
name
:
'grafana'
,
builtIn
:
true
,
},
});
}
return
0
;
}),
};
config
.
panels
[
'graph'
]
=
{
id
:
'graph'
,
...
...
@@ -115,73 +121,73 @@ describe('given dashboard with repeated panels', function() {
});
});
it
(
'should replace datasource refs'
,
function
()
{
it
(
'should replace datasource refs'
,
()
=>
{
var
panel
=
exported
.
panels
[
0
];
expect
(
panel
.
datasource
).
to
.
b
e
(
'${DS_GFDB}'
);
expect
(
panel
.
datasource
).
to
B
e
(
'${DS_GFDB}'
);
});
it
(
'should replace datasource in variable query'
,
function
()
{
expect
(
exported
.
templating
.
list
[
0
].
datasource
).
to
.
b
e
(
'${DS_GFDB}'
);
expect
(
exported
.
templating
.
list
[
0
].
options
.
length
).
to
.
b
e
(
0
);
expect
(
exported
.
templating
.
list
[
0
].
current
.
value
).
to
.
b
e
(
undefined
);
expect
(
exported
.
templating
.
list
[
0
].
current
.
text
).
to
.
b
e
(
undefined
);
it
(
'should replace datasource in variable query'
,
()
=>
{
expect
(
exported
.
templating
.
list
[
0
].
datasource
).
to
B
e
(
'${DS_GFDB}'
);
expect
(
exported
.
templating
.
list
[
0
].
options
.
length
).
to
B
e
(
0
);
expect
(
exported
.
templating
.
list
[
0
].
current
.
value
).
to
B
e
(
undefined
);
expect
(
exported
.
templating
.
list
[
0
].
current
.
text
).
to
B
e
(
undefined
);
});
it
(
'should replace datasource in annotation query'
,
function
()
{
expect
(
exported
.
annotations
.
list
[
1
].
datasource
).
to
.
b
e
(
'${DS_GFDB}'
);
it
(
'should replace datasource in annotation query'
,
()
=>
{
expect
(
exported
.
annotations
.
list
[
1
].
datasource
).
to
B
e
(
'${DS_GFDB}'
);
});
it
(
'should add datasource as input'
,
function
()
{
expect
(
exported
.
__inputs
[
0
].
name
).
to
.
b
e
(
'DS_GFDB'
);
expect
(
exported
.
__inputs
[
0
].
pluginId
).
to
.
b
e
(
'testdb'
);
expect
(
exported
.
__inputs
[
0
].
type
).
to
.
b
e
(
'datasource'
);
it
(
'should add datasource as input'
,
()
=>
{
expect
(
exported
.
__inputs
[
0
].
name
).
to
B
e
(
'DS_GFDB'
);
expect
(
exported
.
__inputs
[
0
].
pluginId
).
to
B
e
(
'testdb'
);
expect
(
exported
.
__inputs
[
0
].
type
).
to
B
e
(
'datasource'
);
});
it
(
'should add datasource to required'
,
function
()
{
it
(
'should add datasource to required'
,
()
=>
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'TestDB'
});
expect
(
require
.
name
).
to
.
b
e
(
'TestDB'
);
expect
(
require
.
id
).
to
.
b
e
(
'testdb'
);
expect
(
require
.
type
).
to
.
b
e
(
'datasource'
);
expect
(
require
.
version
).
to
.
b
e
(
'1.2.1'
);
expect
(
require
.
name
).
to
B
e
(
'TestDB'
);
expect
(
require
.
id
).
to
B
e
(
'testdb'
);
expect
(
require
.
type
).
to
B
e
(
'datasource'
);
expect
(
require
.
version
).
to
B
e
(
'1.2.1'
);
});
it
(
'should not add built in datasources to required'
,
function
()
{
it
(
'should not add built in datasources to required'
,
()
=>
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'Mixed'
});
expect
(
require
).
to
.
b
e
(
undefined
);
expect
(
require
).
to
B
e
(
undefined
);
});
it
(
'should add datasources used in mixed mode'
,
function
()
{
it
(
'should add datasources used in mixed mode'
,
()
=>
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'OtherDB'
});
expect
(
require
).
to
.
not
.
b
e
(
undefined
);
expect
(
require
).
not
.
toB
e
(
undefined
);
});
it
(
'should add panel to required'
,
function
()
{
it
(
'should add panel to required'
,
()
=>
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'Graph'
});
expect
(
require
.
name
).
to
.
b
e
(
'Graph'
);
expect
(
require
.
id
).
to
.
b
e
(
'graph'
);
expect
(
require
.
version
).
to
.
b
e
(
'1.1.0'
);
expect
(
require
.
name
).
to
B
e
(
'Graph'
);
expect
(
require
.
id
).
to
B
e
(
'graph'
);
expect
(
require
.
version
).
to
B
e
(
'1.1.0'
);
});
it
(
'should add grafana version'
,
function
()
{
it
(
'should add grafana version'
,
()
=>
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'Grafana'
});
expect
(
require
.
type
).
to
.
b
e
(
'grafana'
);
expect
(
require
.
id
).
to
.
b
e
(
'grafana'
);
expect
(
require
.
version
).
to
.
b
e
(
'3.0.2'
);
expect
(
require
.
type
).
to
B
e
(
'grafana'
);
expect
(
require
.
id
).
to
B
e
(
'grafana'
);
expect
(
require
.
version
).
to
B
e
(
'3.0.2'
);
});
it
(
'should add constant template variables as inputs'
,
function
()
{
it
(
'should add constant template variables as inputs'
,
()
=>
{
var
input
=
_
.
find
(
exported
.
__inputs
,
{
name
:
'VAR_PREFIX'
});
expect
(
input
.
type
).
to
.
b
e
(
'constant'
);
expect
(
input
.
label
).
to
.
b
e
(
'prefix'
);
expect
(
input
.
value
).
to
.
b
e
(
'collectd'
);
expect
(
input
.
type
).
to
B
e
(
'constant'
);
expect
(
input
.
label
).
to
B
e
(
'prefix'
);
expect
(
input
.
value
).
to
B
e
(
'collectd'
);
});
it
(
'should templatize constant variables'
,
function
()
{
it
(
'should templatize constant variables'
,
()
=>
{
var
variable
=
_
.
find
(
exported
.
templating
.
list
,
{
name
:
'prefix'
});
expect
(
variable
.
query
).
to
.
b
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
current
.
text
).
to
.
b
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
current
.
value
).
to
.
b
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
options
[
0
].
text
).
to
.
b
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
options
[
0
].
value
).
to
.
b
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
query
).
to
B
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
current
.
text
).
to
B
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
current
.
value
).
to
B
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
options
[
0
].
text
).
to
B
e
(
'${VAR_PREFIX}'
);
expect
(
variable
.
options
[
0
].
value
).
to
B
e
(
'${VAR_PREFIX}'
);
});
});
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