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
d34cd873
Commit
d34cd873
authored
Mar 20, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mssql: convert tests to jest
parent
ae4c6e46
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
54 deletions
+49
-54
public/app/plugins/datasource/mssql/specs/datasource.jest.ts
+49
-54
No files found.
public/app/plugins/datasource/mssql/specs/datasource
_specs
.ts
→
public/app/plugins/datasource/mssql/specs/datasource
.jest
.ts
View file @
d34cd873
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
helpers
from
'test/specs/helpers'
;
import
{
MssqlDatasource
}
from
'../datasource'
;
import
{
MssqlDatasource
}
from
'../datasource'
;
import
{
TemplateSrvStub
}
from
'test/specs/helpers'
;
import
{
CustomVariable
}
from
'app/features/templating/custom_variable'
;
import
{
CustomVariable
}
from
'app/features/templating/custom_variable'
;
import
q
from
'q'
;
describe
(
'MSSQLDatasource'
,
function
()
{
describe
(
'MSSQLDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
const
ctx
:
any
=
{
var
instanceSettings
=
{
name
:
'mssql'
};
backendSrv
:
{},
templateSrv
:
new
TemplateSrvStub
(),
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
};
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
function
()
{
ctx
.
$q
=
q
;
beforeEach
(
ctx
.
instanceSettings
=
{
name
:
'mssql'
};
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
ctx
.
$q
=
$q
;
ctx
.
ds
=
new
MssqlDatasource
(
ctx
.
instanceSettings
,
ctx
.
backendSrv
,
ctx
.
$q
,
ctx
.
templateSrv
);
ctx
.
$httpBackend
=
$httpBackend
;
});
ctx
.
$rootScope
=
$rootScope
;
ctx
.
ds
=
$injector
.
instantiate
(
MssqlDatasource
,
{
instanceSettings
:
instanceSettings
});
$httpBackend
.
when
(
'GET'
,
/
\.
html$/
).
respond
(
''
);
})
);
describe
(
'When performing annotationQuery'
,
function
()
{
describe
(
'When performing annotationQuery'
,
function
()
{
let
results
;
let
results
;
...
@@ -46,9 +41,9 @@ describe('MSSQLDatasource', function() {
...
@@ -46,9 +41,9 @@ describe('MSSQLDatasource', function() {
{
{
columns
:
[{
text
:
'time'
},
{
text
:
'text'
},
{
text
:
'tags'
}],
columns
:
[{
text
:
'time'
},
{
text
:
'text'
},
{
text
:
'tags'
}],
rows
:
[
rows
:
[
[
152154
6171129
,
'some text'
,
'TagA,TagB'
],
[
152154
5610656
,
'some text'
,
'TagA,TagB'
],
[
1521546
531404
,
'some text2'
,
' TagB , TagC'
],
[
1521546
251185
,
'some text2'
,
' TagB , TagC'
],
[
1521546
901702
,
'some text3'
],
[
1521546
501378
,
'some text3'
],
],
],
},
},
],
],
...
@@ -56,27 +51,27 @@ describe('MSSQLDatasource', function() {
...
@@ -56,27 +51,27 @@ describe('MSSQLDatasource', function() {
},
},
};
};
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
options
=>
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
annotationQuery
(
options
).
then
(
function
(
data
)
{
return
ctx
.
ds
.
annotationQuery
(
options
).
then
(
data
=>
{
results
=
data
;
results
=
data
;
});
});
ctx
.
$rootScope
.
$apply
();
});
});
it
(
'should return annotation list'
,
function
()
{
it
(
'should return annotation list'
,
function
()
{
expect
(
results
.
length
).
to
.
b
e
(
3
);
expect
(
results
.
length
).
to
B
e
(
3
);
expect
(
results
[
0
].
text
).
to
.
b
e
(
'some text'
);
expect
(
results
[
0
].
text
).
to
B
e
(
'some text'
);
expect
(
results
[
0
].
tags
[
0
]).
to
.
b
e
(
'TagA'
);
expect
(
results
[
0
].
tags
[
0
]).
to
B
e
(
'TagA'
);
expect
(
results
[
0
].
tags
[
1
]).
to
.
b
e
(
'TagB'
);
expect
(
results
[
0
].
tags
[
1
]).
to
B
e
(
'TagB'
);
expect
(
results
[
1
].
tags
[
0
]).
to
.
b
e
(
'TagB'
);
expect
(
results
[
1
].
tags
[
0
]).
to
B
e
(
'TagB'
);
expect
(
results
[
1
].
tags
[
1
]).
to
.
b
e
(
'TagC'
);
expect
(
results
[
1
].
tags
[
1
]).
to
B
e
(
'TagC'
);
expect
(
results
[
2
].
tags
.
length
).
to
.
b
e
(
0
);
expect
(
results
[
2
].
tags
.
length
).
to
B
e
(
0
);
});
});
});
});
...
@@ -104,16 +99,16 @@ describe('MSSQLDatasource', function() {
...
@@ -104,16 +99,16 @@ describe('MSSQLDatasource', function() {
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
return
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
results
=
data
;
});
});
ctx
.
$rootScope
.
$apply
();
});
});
it
(
'should return list of all column values'
,
function
()
{
it
(
'should return list of all column values'
,
function
()
{
expect
(
results
.
length
).
to
.
b
e
(
6
);
expect
(
results
.
length
).
to
B
e
(
6
);
expect
(
results
[
0
].
text
).
to
.
b
e
(
'aTitle'
);
expect
(
results
[
0
].
text
).
to
B
e
(
'aTitle'
);
expect
(
results
[
5
].
text
).
to
.
b
e
(
'some text3'
);
expect
(
results
[
5
].
text
).
to
B
e
(
'some text3'
);
});
});
});
});
...
@@ -141,18 +136,18 @@ describe('MSSQLDatasource', function() {
...
@@ -141,18 +136,18 @@ describe('MSSQLDatasource', function() {
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
return
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
results
=
data
;
});
});
ctx
.
$rootScope
.
$apply
();
});
});
it
(
'should return list of as text, value'
,
function
()
{
it
(
'should return list of as text, value'
,
function
()
{
expect
(
results
.
length
).
to
.
b
e
(
3
);
expect
(
results
.
length
).
to
B
e
(
3
);
expect
(
results
[
0
].
text
).
to
.
b
e
(
'aTitle'
);
expect
(
results
[
0
].
text
).
to
B
e
(
'aTitle'
);
expect
(
results
[
0
].
value
).
to
.
b
e
(
'value1'
);
expect
(
results
[
0
].
value
).
to
B
e
(
'value1'
);
expect
(
results
[
2
].
text
).
to
.
b
e
(
'aTitle3'
);
expect
(
results
[
2
].
text
).
to
B
e
(
'aTitle3'
);
expect
(
results
[
2
].
value
).
to
.
b
e
(
'value3'
);
expect
(
results
[
2
].
value
).
to
B
e
(
'value3'
);
});
});
});
});
...
@@ -180,16 +175,16 @@ describe('MSSQLDatasource', function() {
...
@@ -180,16 +175,16 @@ describe('MSSQLDatasource', function() {
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
return
ctx
.
$q
.
when
({
data
:
response
,
status
:
200
});
};
};
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
return
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
data
)
{
results
=
data
;
results
=
data
;
});
});
ctx
.
$rootScope
.
$apply
();
});
});
it
(
'should return list of unique keys'
,
function
()
{
it
(
'should return list of unique keys'
,
function
()
{
expect
(
results
.
length
).
to
.
b
e
(
1
);
expect
(
results
.
length
).
to
B
e
(
1
);
expect
(
results
[
0
].
text
).
to
.
b
e
(
'aTitle'
);
expect
(
results
[
0
].
text
).
to
B
e
(
'aTitle'
);
expect
(
results
[
0
].
value
).
to
.
b
e
(
'same'
);
expect
(
results
[
0
].
value
).
to
B
e
(
'same'
);
});
});
});
});
...
@@ -200,33 +195,33 @@ describe('MSSQLDatasource', function() {
...
@@ -200,33 +195,33 @@ describe('MSSQLDatasource', function() {
describe
(
'and value is a string'
,
()
=>
{
describe
(
'and value is a string'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eq
l
(
'abc'
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
Equa
l
(
'abc'
);
});
});
});
});
describe
(
'and value is a number'
,
()
=>
{
describe
(
'and value is a number'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
(
1000
,
ctx
.
variable
)).
to
.
eq
l
(
1000
);
expect
(
ctx
.
ds
.
interpolateVariable
(
1000
,
ctx
.
variable
)).
to
Equa
l
(
1000
);
});
});
});
});
describe
(
'and value is an array of strings'
,
()
=>
{
describe
(
'and value is an array of strings'
,
()
=>
{
it
(
'should return comma separated quoted values'
,
()
=>
{
it
(
'should return comma separated quoted values'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
([
'a'
,
'b'
,
'c'
],
ctx
.
variable
)).
to
.
eq
l
(
"'a','b','c'"
);
expect
(
ctx
.
ds
.
interpolateVariable
([
'a'
,
'b'
,
'c'
],
ctx
.
variable
)).
to
Equa
l
(
"'a','b','c'"
);
});
});
});
});
describe
(
'and variable allows multi-value and value is a string'
,
()
=>
{
describe
(
'and variable allows multi-value and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
multi
=
true
;
ctx
.
variable
.
multi
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eq
l
(
"'abc'"
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
Equa
l
(
"'abc'"
);
});
});
});
});
describe
(
'and variable allows all and value is a string'
,
()
=>
{
describe
(
'and variable allows all and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
ctx
.
variable
.
includeAll
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eq
l
(
"'abc'"
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
Equa
l
(
"'abc'"
);
});
});
});
});
});
});
...
...
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