fixed dashboard graph karma tests

This commit is contained in:
John Mitchell 2015-05-28 16:44:07 -04:00
parent 12af62f671
commit 55bd774867
3 changed files with 4 additions and 58 deletions

View File

@ -1,9 +1,10 @@
import Tower from 'tower/app';
import {describeModule} from 'tests/unit/describe-module';
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main'
var resizeHandler = sinon.spy();
describeModule('DashboardGraphs')
describeModule(JobStatusGraph.name)
.mockProvider('adjustGraphSize', resizeHandler)
.testDirective('jobStatusGraph', function(directive) {

View File

@ -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);
});
});
});

View File

@ -1,8 +1,9 @@
import {describeModule} from 'tests/unit/describe-module';
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main'
var processErrors = sinon.spy();
describeModule('DashboardGraphs')
describeModule(JobStatusGraph.name)
.mockProvider('ProcessErrors', processErrors)
.testService('jobStatusGraphData', function(test, restStub) {
var q;