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
7d51c152
Commit
7d51c152
authored
Jul 25, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Two passing tests
parent
f3504612
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
12 deletions
+40
-12
public/app/features/templating/specs/variable_srv_init.jest.ts
+39
-12
public/app/features/templating/variable_srv.ts
+1
-0
No files found.
public/app/features/templating/specs/variable_srv_init.jest.ts
View file @
7d51c152
...
@@ -7,16 +7,18 @@ import _ from 'lodash';
...
@@ -7,16 +7,18 @@ import _ from 'lodash';
// import { Emitter } from 'app/core/core';
// import { Emitter } from 'app/core/core';
import
{
VariableSrv
}
from
'../variable_srv'
;
import
{
VariableSrv
}
from
'../variable_srv'
;
import
$q
from
'q'
;
import
$q
from
'q'
;
// import { model } from 'mobx-state-tree/dist/internal';
describe
(
'VariableSrv init'
,
function
()
{
describe
(
'VariableSrv init'
,
function
()
{
let
templateSrv
=
{
let
templateSrv
=
{
init
:
()
=>
{},
init
:
vars
=>
{
};
this
.
variables
=
vars
;
let
$injector
=
{
instantiate
:
(
vars
,
model
)
=>
{
return
new
vars
(
model
.
model
);
},
},
variableInitialized
:
()
=>
{},
updateTemplateData
:
()
=>
{},
replace
:
str
=>
str
,
};
};
let
$injector
=
<
any
>
{};
let
$rootscope
=
{
let
$rootscope
=
{
$on
:
()
=>
{},
$on
:
()
=>
{},
};
};
...
@@ -57,24 +59,35 @@ describe('VariableSrv init', function() {
...
@@ -57,24 +59,35 @@ describe('VariableSrv init', function() {
},
},
};
};
beforeEach
(
function
()
{
beforeEach
(
async
()
=>
{
scenario
.
setupFn
();
scenario
.
setupFn
();
ctx
.
variableSrv
=
new
VariableSrv
(
$rootscope
,
$q
,
{},
$injector
,
templateSrv
);
ctx
=
{
ctx
.
variableSrv
.
datasource
=
{};
datasource
:
{
ctx
.
variableSrv
.
datasource
.
metricFindQuery
=
jest
.
fn
(()
=>
Promise
.
resolve
(
scenario
.
queryResult
));
metricFindQuery
:
jest
.
fn
(()
=>
Promise
.
resolve
(
scenario
.
queryResult
)),
},
ctx
.
variableSrv
.
datasourceSrv
=
{
datasourceSrv
:
{
get
:
()
=>
Promise
.
resolve
(
ctx
.
datasource
),
get
:
()
=>
Promise
.
resolve
(
ctx
.
datasource
),
getMetricSources
:
()
=>
Promise
.
resolve
(
scenario
.
metricSources
),
getMetricSources
:
()
=>
Promise
.
resolve
(
scenario
.
metricSources
),
},
templateSrv
,
};
ctx
.
variableSrv
=
new
VariableSrv
(
$rootscope
,
$q
,
{},
$injector
,
templateSrv
);
$injector
.
instantiate
=
(
variable
,
model
)
=>
{
return
getVarMockConstructor
(
variable
,
model
,
ctx
);
};
};
ctx
.
variableSrv
.
datasource
=
ctx
.
datasource
;
ctx
.
variableSrv
.
datasourceSrv
=
ctx
.
datasourceSrv
;
ctx
.
variableSrv
.
$location
.
search
=
()
=>
Promise
.
resolve
(
scenario
.
urlParams
);
ctx
.
variableSrv
.
$location
.
search
=
()
=>
Promise
.
resolve
(
scenario
.
urlParams
);
ctx
.
variableSrv
.
dashboard
=
{
ctx
.
variableSrv
.
dashboard
=
{
templating
:
{
list
:
scenario
.
variables
},
templating
:
{
list
:
scenario
.
variables
},
// events: new Emitter(),
// events: new Emitter(),
};
};
ctx
.
variableSrv
.
init
(
ctx
.
variableSrv
.
dashboard
);
await
ctx
.
variableSrv
.
init
(
ctx
.
variableSrv
.
dashboard
);
// ctx.$rootScope.$digest();
// ctx.$rootScope.$digest();
scenario
.
variables
=
ctx
.
variableSrv
.
variables
;
scenario
.
variables
=
ctx
.
variableSrv
.
variables
;
...
@@ -236,3 +249,17 @@ describe('VariableSrv init', function() {
...
@@ -236,3 +249,17 @@ describe('VariableSrv init', function() {
});
});
});
});
});
});
function
getVarMockConstructor
(
variable
,
model
,
ctx
)
{
console
.
log
(
model
.
model
.
type
);
switch
(
model
.
model
.
type
)
{
case
'datasource'
:
return
new
variable
(
model
.
model
,
ctx
.
datasourceSrv
,
ctx
.
templateSrv
,
ctx
.
variableSrv
);
case
'query'
:
return
new
variable
(
model
.
model
,
ctx
.
datasourceSrv
,
ctx
.
templateSrv
,
ctx
.
variableSrv
);
case
'interval'
:
return
new
variable
(
model
.
model
,
{},
ctx
.
templateSrv
,
ctx
.
variableSrv
);
default
:
return
new
variable
(
model
.
model
);
}
}
public/app/features/templating/variable_srv.ts
View file @
7d51c152
...
@@ -23,6 +23,7 @@ export class VariableSrv {
...
@@ -23,6 +23,7 @@ export class VariableSrv {
// init variables
// init variables
for
(
let
variable
of
this
.
variables
)
{
for
(
let
variable
of
this
.
variables
)
{
console
.
log
(
variable
);
variable
.
initLock
=
this
.
$q
.
defer
();
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