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
74b4d2ef
Unverified
Commit
74b4d2ef
authored
Jul 24, 2018
by
Marcus Efraimsson
Committed by
GitHub
Jul 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12704 from dehrax/12224-completer
Karma to Jest: completer
parents
1c4dd6f2
27c08134
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
39 deletions
+34
-39
public/app/plugins/datasource/prometheus/specs/completer.jest.ts
+34
-39
No files found.
public/app/plugins/datasource/prometheus/specs/completer
_specs
.ts
→
public/app/plugins/datasource/prometheus/specs/completer
.jest
.ts
View file @
74b4d2ef
import
{
describe
,
it
,
sinon
,
expect
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
{
PromCompleter
}
from
'../completer'
;
import
{
PrometheusDatasource
}
from
'../datasource'
;
import
{
BackendSrv
}
from
'app/core/services/backend_srv'
;
jest
.
mock
(
'../datasource'
);
jest
.
mock
(
'app/core/services/backend_srv'
);
describe
(
'Prometheus editor completer'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
beforeEach
(
ctx
.
providePhase
([
'templateSrv'
]));
//beforeEach(ctx.providePhase(['templateSrv']));
function
getSessionStub
(
data
)
{
return
{
getTokenAt
:
sinon
.
stub
().
returns
(
data
.
currentToken
),
getTokens
:
sinon
.
stub
().
returns
(
data
.
tokens
),
getLine
:
sinon
.
stub
().
returns
(
data
.
line
),
getTokenAt
:
jest
.
fn
(()
=>
data
.
currentToken
),
getTokens
:
jest
.
fn
(()
=>
data
.
tokens
),
getLine
:
jest
.
fn
(()
=>
data
.
line
),
};
}
let
editor
=
{};
let
datasourceStub
=
<
PrometheusDatasource
>
{
performInstantQuery
:
sinon
.
stub
()
.
withArgs
({
expr
:
'{__name__="node_cpu"'
})
.
returns
(
Promise
.
resolve
({
data
:
{
data
:
{
result
:
[
{
metric
:
{
job
:
'node'
,
instance
:
'localhost:9100'
,
},
},
],
let
backendSrv
=
<
BackendSrv
>
{};
let
datasourceStub
=
new
PrometheusDatasource
({},
{},
backendSrv
,
{},
{});
datasourceStub
.
performInstantQuery
=
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{
data
:
{
result
:
[
{
metric
:
{
job
:
'node'
,
instance
:
'localhost:9100'
,
},
},
},
})
),
performSuggestQuery
:
sinon
.
stub
()
.
withArgs
(
'node'
,
true
)
.
returns
(
Promise
.
resolve
([
'node_cpu'
])),
};
],
},
},
})
);
datasourceStub
.
performSuggestQuery
=
jest
.
fn
(()
=>
Promise
.
resolve
([
'node_cpu'
]));
let
templateSrv
=
{
variables
:
[
...
...
@@ -62,9 +57,9 @@ describe('Prometheus editor completer', function() {
});
return
completer
.
getCompletions
(
editor
,
session
,
{
row
:
0
,
column
:
10
},
'['
,
(
s
,
res
)
=>
{
expect
(
res
[
0
].
caption
).
to
.
eq
l
(
'$__interval'
);
expect
(
res
[
0
].
value
).
to
.
eq
l
(
'[$__interval'
);
expect
(
res
[
0
].
meta
).
to
.
eq
l
(
'range vector'
);
expect
(
res
[
0
].
caption
).
to
Equa
l
(
'$__interval'
);
expect
(
res
[
0
].
value
).
to
Equa
l
(
'[$__interval'
);
expect
(
res
[
0
].
meta
).
to
Equa
l
(
'range vector'
);
});
});
});
...
...
@@ -93,7 +88,7 @@ describe('Prometheus editor completer', function() {
});
return
completer
.
getCompletions
(
editor
,
session
,
{
row
:
0
,
column
:
10
},
'j'
,
(
s
,
res
)
=>
{
expect
(
res
[
0
].
meta
).
to
.
eq
l
(
'label name'
);
expect
(
res
[
0
].
meta
).
to
Equa
l
(
'label name'
);
});
});
});
...
...
@@ -125,7 +120,7 @@ describe('Prometheus editor completer', function() {
});
return
completer
.
getCompletions
(
editor
,
session
,
{
row
:
0
,
column
:
23
},
'j'
,
(
s
,
res
)
=>
{
expect
(
res
[
0
].
meta
).
to
.
eq
l
(
'label name'
);
expect
(
res
[
0
].
meta
).
to
Equa
l
(
'label name'
);
});
});
});
...
...
@@ -156,7 +151,7 @@ describe('Prometheus editor completer', function() {
});
return
completer
.
getCompletions
(
editor
,
session
,
{
row
:
0
,
column
:
15
},
'n'
,
(
s
,
res
)
=>
{
expect
(
res
[
0
].
meta
).
to
.
eq
l
(
'label value'
);
expect
(
res
[
0
].
meta
).
to
Equa
l
(
'label value'
);
});
});
});
...
...
@@ -192,7 +187,7 @@ describe('Prometheus editor completer', function() {
});
return
completer
.
getCompletions
(
editor
,
session
,
{
row
:
0
,
column
:
23
},
'm'
,
(
s
,
res
)
=>
{
expect
(
res
[
0
].
meta
).
to
.
eq
l
(
'label name'
);
expect
(
res
[
0
].
meta
).
to
Equa
l
(
'label name'
);
});
});
});
...
...
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