mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
fixed dashboard graph karma tests
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import Tower from 'tower/app';
|
import Tower from 'tower/app';
|
||||||
import {describeModule} from 'tests/unit/describe-module';
|
import {describeModule} from 'tests/unit/describe-module';
|
||||||
|
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main'
|
||||||
|
|
||||||
var resizeHandler = sinon.spy();
|
var resizeHandler = sinon.spy();
|
||||||
|
|
||||||
describeModule('DashboardGraphs')
|
describeModule(JobStatusGraph.name)
|
||||||
.mockProvider('adjustGraphSize', resizeHandler)
|
.mockProvider('adjustGraphSize', resizeHandler)
|
||||||
.testDirective('jobStatusGraph', function(directive) {
|
.testDirective('jobStatusGraph', function(directive) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
import {describeModule} from 'tests/unit/describe-module';
|
|
||||||
|
|
||||||
var processErrors = sinon.spy();
|
|
||||||
|
|
||||||
describeModule('DashboardGraphs')
|
|
||||||
.mockProvider('ProcessErrors', processErrors)
|
|
||||||
.testService('hostCountGraphData', function(test, restStub) {
|
|
||||||
|
|
||||||
var q;
|
|
||||||
var service;
|
|
||||||
|
|
||||||
beforeEach(inject(['$q', function($q) {
|
|
||||||
q = $q;
|
|
||||||
}]));
|
|
||||||
|
|
||||||
|
|
||||||
test.withService(function(_service_) {
|
|
||||||
service = _service_;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns a promise to be fulfilled when data comes in', function() {
|
|
||||||
var license = "license";
|
|
||||||
var hostData = "hosts";
|
|
||||||
|
|
||||||
var result = service.get();
|
|
||||||
|
|
||||||
restStub.succeedAt('/config/', { data: {
|
|
||||||
license_info: {
|
|
||||||
instance_count: license
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
restStub.succeedAt('/dashboard/graphs/inventory/', { data: hostData });
|
|
||||||
|
|
||||||
restStub.flush();
|
|
||||||
|
|
||||||
return expect(result).to.eventually.eql({ license: license, hosts: hostData });;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('processes errors through error handler', function() {
|
|
||||||
var expected = { data: "blah", status: "bad" };
|
|
||||||
var actual = service.get();
|
|
||||||
|
|
||||||
restStub.failAt('/config/', expected);
|
|
||||||
|
|
||||||
restStub.flush();
|
|
||||||
|
|
||||||
return actual.catch(function() {
|
|
||||||
expect(processErrors).to
|
|
||||||
.have.been.calledWith(null, expected.data, expected.status);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import {describeModule} from 'tests/unit/describe-module';
|
import {describeModule} from 'tests/unit/describe-module';
|
||||||
|
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main'
|
||||||
|
|
||||||
var processErrors = sinon.spy();
|
var processErrors = sinon.spy();
|
||||||
|
|
||||||
describeModule('DashboardGraphs')
|
describeModule(JobStatusGraph.name)
|
||||||
.mockProvider('ProcessErrors', processErrors)
|
.mockProvider('ProcessErrors', processErrors)
|
||||||
.testService('jobStatusGraphData', function(test, restStub) {
|
.testService('jobStatusGraphData', function(test, restStub) {
|
||||||
var q;
|
var q;
|
||||||
|
|||||||
Reference in New Issue
Block a user