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
ed8568f0
Commit
ed8568f0
authored
Jul 23, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add graph_ctrl jest
parent
ae935bf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
91 deletions
+29
-91
public/app/plugins/panel/graph/specs/graph_ctrl.jest.ts
+29
-13
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
+0
-78
No files found.
public/app/plugins/panel/graph/specs/graph_ctrl.jest.ts
View file @
ed8568f0
// import { describe, beforeEach, it, expect, angularMocks } from '../../../../../test/lib/common';
import
moment
from
'moment'
;
import
{
GraphCtrl
}
from
'../module'
;
jest
.
mock
(
'../graph'
,
()
=>
({}));
describe
(
'GraphCtrl'
,
function
()
{
let
injector
=
{
get
:
()
=>
{
return
{
timeRange
:
()
=>
{
return
{
from
:
''
,
to
:
''
,
};
},
};
},
};
let
scope
=
{
$on
:
function
()
{},
};
GraphCtrl
.
prototype
.
panel
=
{
events
:
{
on
:
function
()
{},
},
gridPos
:
{
w
:
100
,
},
};
let
ctx
=
<
any
>
{};
beforeEach
(()
=>
{
ctx
.
ctrl
=
new
GraphCtrl
(
{},
{}
,
{});
ctx
.
ctrl
=
new
GraphCtrl
(
scope
,
injector
,
{});
});
// beforeEach(angularMocks.module('grafana.services'));
// beforeEach(angularMocks.module('grafana.controllers'));
// beforeEach(
// angularMocks.module(function($compileProvider) {
// $compileProvider.preAssignBindingsEnabled(true);
// })
// );
// beforeEach(ctx.providePhase());
// beforeEach(ctx.createPanelController(GraphCtrl));
beforeEach
(()
=>
{
ctx
.
ctrl
.
annotationsPromise
=
Promise
.
resolve
({});
ctx
.
ctrl
.
updateTimeRange
();
...
...
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
deleted
100644 → 0
View file @
ae935bf0
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'../../../../../test/lib/common'
;
import
moment
from
'moment'
;
import
{
GraphCtrl
}
from
'../module'
;
import
helpers
from
'../../../../../test/specs/helpers'
;
describe
(
'GraphCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
module
(
'grafana.controllers'
));
beforeEach
(
angularMocks
.
module
(
function
(
$compileProvider
)
{
$compileProvider
.
preAssignBindingsEnabled
(
true
);
})
);
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
createPanelController
(
GraphCtrl
));
beforeEach
(()
=>
{
ctx
.
ctrl
.
annotationsPromise
=
Promise
.
resolve
({});
ctx
.
ctrl
.
updateTimeRange
();
});
describe
(
'when time series are outside range'
,
function
()
{
beforeEach
(
function
()
{
var
data
=
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
45
,
1234567890
],
[
60
,
1234567899
]],
},
];
ctx
.
ctrl
.
range
=
{
from
:
moment
().
valueOf
(),
to
:
moment
().
valueOf
()
};
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
.
be
(
'Data points outside time range'
);
});
});
describe
(
'when time series are inside range'
,
function
()
{
beforeEach
(
function
()
{
var
range
=
{
from
:
moment
()
.
subtract
(
1
,
'days'
)
.
valueOf
(),
to
:
moment
().
valueOf
(),
};
var
data
=
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
45
,
range
.
from
+
1000
],
[
60
,
range
.
from
+
10000
]],
},
];
ctx
.
ctrl
.
range
=
range
;
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
).
to
.
be
(
null
);
});
});
describe
(
'datapointsCount given 2 series'
,
function
()
{
beforeEach
(
function
()
{
var
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[]
},
{
target
:
'test.cpu2'
,
datapoints
:
[]
}];
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsCount warning'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
.
be
(
'No data points'
);
});
});
});
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