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
710566e1
Unverified
Commit
710566e1
authored
Jul 27, 2018
by
Marcus Efraimsson
Committed by
GitHub
Jul 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12742 from dehrax/12224-backend-srv
Karma to Jest: backend_srv
parents
86d75a64
c11d0f5c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
31 deletions
+25
-31
public/app/core/specs/backend_srv.jest.ts
+25
-0
public/app/core/specs/backend_srv_specs.ts
+0
-31
No files found.
public/app/core/specs/backend_srv.jest.ts
0 → 100644
View file @
710566e1
import
{
BackendSrv
}
from
'app/core/services/backend_srv'
;
jest
.
mock
(
'app/core/store'
);
describe
(
'backend_srv'
,
function
()
{
let
_httpBackend
=
options
=>
{
if
(
options
.
url
===
'gateway-error'
)
{
return
Promise
.
reject
({
status
:
502
});
}
return
Promise
.
resolve
({});
};
let
_backendSrv
=
new
BackendSrv
(
_httpBackend
,
{},
{},
{},
{});
describe
(
'when handling errors'
,
()
=>
{
it
(
'should return the http status code'
,
async
()
=>
{
try
{
await
_backendSrv
.
datasourceRequest
({
url
:
'gateway-error'
,
});
}
catch
(
err
)
{
expect
(
err
.
status
).
toBe
(
502
);
}
});
});
});
public/app/core/specs/backend_srv_specs.ts
deleted
100644 → 0
View file @
86d75a64
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
'app/core/services/backend_srv'
;
describe
(
'backend_srv'
,
function
()
{
var
_backendSrv
;
var
_httpBackend
;
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
inject
(
function
(
$httpBackend
,
$http
,
backendSrv
)
{
_httpBackend
=
$httpBackend
;
_backendSrv
=
backendSrv
;
})
);
describe
(
'when handling errors'
,
function
()
{
it
(
'should return the http status code'
,
function
(
done
)
{
_httpBackend
.
whenGET
(
'gateway-error'
).
respond
(
502
);
_backendSrv
.
datasourceRequest
({
url
:
'gateway-error'
,
})
.
catch
(
function
(
err
)
{
expect
(
err
.
status
).
to
.
be
(
502
);
done
();
});
_httpBackend
.
flush
();
});
});
});
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