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
931b944c
Commit
931b944c
authored
Jul 25, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Almost all tests passing
parent
7d51c152
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
33 deletions
+10
-33
public/app/features/templating/specs/variable_srv_init.jest.ts
+10
-32
public/app/features/templating/variable_srv.ts
+0
-1
No files found.
public/app/features/templating/specs/variable_srv_init.jest.ts
View file @
931b944c
//import { describe, beforeEach, it, sinon, expect, angularMocks } from 'test/lib/common';
import
'../all'
;
import
_
from
'lodash'
;
// import helpers from 'test/specs/helpers';
// import { Emitter } from 'app/core/core';
import
{
VariableSrv
}
from
'../variable_srv'
;
import
$q
from
'q'
;
// import {
model } from 'mobx-state-tree/dist/internal
';
// import {
TemplateSrv } from '../template_srv
';
describe
(
'VariableSrv init'
,
function
()
{
let
templateSrv
=
{
...
...
@@ -16,8 +12,9 @@ describe('VariableSrv init', function() {
},
variableInitialized
:
()
=>
{},
updateTemplateData
:
()
=>
{},
replace
:
str
=>
str
,
replace
:
()
=>
' /pee$/'
,
};
// let templateSrv = new TemplateSrv();
let
$injector
=
<
any
>
{};
let
$rootscope
=
{
$on
:
()
=>
{},
...
...
@@ -29,29 +26,8 @@ describe('VariableSrv init', function() {
dashboard
:
{},
};
// beforeEach(angularMocks.module('grafana.core'));
// beforeEach(angularMocks.module('grafana.controllers'));
// beforeEach(angularMocks.module('grafana.services'));
// beforeEach(
// angularMocks.module(function($compileProvider) {
// $compileProvider.preAssignBindingsEnabled(true);
// })
// );
// beforeEach(ctx.providePhase(['datasourceSrv', 'timeSrv', 'templateSrv', '$location']));
// beforeEach(
// angularMocks.inject(($rootScope, $q, $location, $injector) => {
// ctx.$q = $q;
// ctx.$rootScope = $rootScope;
// ctx.$location = $location;
// ctx.variableSrv = $injector.get('variableSrv');
// ctx.$rootScope.$digest();
// })
// );
function
describeInitScenario
(
desc
,
fn
)
{
describe
(
desc
,
function
()
{
// events: new Emitter(),
var
scenario
:
any
=
{
urlParams
:
{},
setup
:
setupFn
=>
{
...
...
@@ -81,14 +57,12 @@ describe('VariableSrv init', function() {
ctx
.
variableSrv
.
datasource
=
ctx
.
datasource
;
ctx
.
variableSrv
.
datasourceSrv
=
ctx
.
datasourceSrv
;
ctx
.
variableSrv
.
$location
.
search
=
()
=>
Promise
.
resolve
(
scenario
.
urlParams
)
;
ctx
.
variableSrv
.
$location
.
search
=
()
=>
scenario
.
urlParams
;
ctx
.
variableSrv
.
dashboard
=
{
templating
:
{
list
:
scenario
.
variables
},
// events: new Emitter(),
};
await
ctx
.
variableSrv
.
init
(
ctx
.
variableSrv
.
dashboard
);
// ctx.$rootScope.$digest();
scenario
.
variables
=
ctx
.
variableSrv
.
variables
;
});
...
...
@@ -113,6 +87,7 @@ describe('VariableSrv init', function() {
});
it
(
'should update current value'
,
()
=>
{
console
.
log
(
type
);
expect
(
scenario
.
variables
[
0
].
current
.
value
).
toBe
(
'new'
);
expect
(
scenario
.
variables
[
0
].
current
.
text
).
toBe
(
'new'
);
});
...
...
@@ -176,6 +151,7 @@ describe('VariableSrv init', function() {
});
it
(
'should update current value'
,
function
()
{
console
.
log
(
ctx
.
variableSrv
.
variables
[
0
].
options
);
var
variable
=
ctx
.
variableSrv
.
variables
[
0
];
expect
(
variable
.
options
.
length
).
toBe
(
2
);
});
...
...
@@ -251,14 +227,16 @@ describe('VariableSrv init', function() {
});
function
getVarMockConstructor
(
variable
,
model
,
ctx
)
{
console
.
log
(
model
.
model
.
type
);
//
console.log(model.model.type);
switch
(
model
.
model
.
type
)
{
case
'datasource'
:
return
new
variable
(
model
.
model
,
ctx
.
datasourceSrv
,
ctx
.
templateSrv
,
ctx
.
variabl
eSrv
);
return
new
variable
(
model
.
model
,
ctx
.
datasourceSrv
,
ctx
.
variableSrv
,
ctx
.
templat
eSrv
);
case
'query'
:
return
new
variable
(
model
.
model
,
ctx
.
datasourceSrv
,
ctx
.
templateSrv
,
ctx
.
variableSrv
);
case
'interval'
:
return
new
variable
(
model
.
model
,
{},
ctx
.
templateSrv
,
ctx
.
variableSrv
);
case
'custom'
:
return
new
variable
(
model
.
model
,
ctx
.
variableSrv
);
default
:
return
new
variable
(
model
.
model
);
}
...
...
public/app/features/templating/variable_srv.ts
View file @
931b944c
...
...
@@ -23,7 +23,6 @@ export class VariableSrv {
// init variables
for
(
let
variable
of
this
.
variables
)
{
console
.
log
(
variable
);
variable
.
initLock
=
this
.
$q
.
defer
();
}
...
...
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