Skip to content

Commit

Permalink
remove the old services test and use the extract schema loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Feb 25, 2017
1 parent fbab3a2 commit 63a7837
Showing 1 changed file with 5 additions and 51 deletions.
Expand Up @@ -2,7 +2,7 @@ describe('services', function() {
"use strict";

var $httpBackend, $q, $rootScope;
var columns, episodeData, records, list_schema, mockWindow;
var columns, $window;

var profile = {
readonly : false,
Expand Down Expand Up @@ -35,67 +35,21 @@ describe('services', function() {
}
}
};

records = columns.fields;

episodeData = {
id: 123,
date_of_admission: "19/11/2013",
active: true,
discharge_date: null,
date_of_episode: null,
tagging: [{
mine: true,
tropical: true
}],
demographics: [{
id: 101,
first_name: 'John',
surname: 'Smith',
date_of_birth: '31/071980',
hospital_number: '555'
}],
location: [{
category: 'Inepisode',
hospital: 'UCH',
ward: 'T10',
bed: '15',
date_of_admission: '01/08/2013',
}],
diagnosis: [{
id: 102,
condition: 'Dengue',
provisional: true,
date_of_diagnosis: '20/04/2007'
}, {
id: 103,
condition: 'Malaria',
provisional: false,
date_of_diagnosis: '19/03/2006'
}]
};
});

describe('extractSchemaLoader', function(){
var mock, extractSchemaLoader;

beforeEach(function(){
mock = { alert: jasmine.createSpy() };

module(function($provide) {
$provide.value('$window', mock);
});

module('opal.services', function($provide) {
$provide.value('UserProfile', function(){ return profile; });
});

inject(function($injector){
extractSchemaLoader = $injector.get('extractSchemaLoader');
$httpBackend = $injector.get('$httpBackend');
$rootScope = $injector.get('$rootScope');
$q = $injector.get('$q');
$window = $injector.get('$window');
});

spyOn($window, "alert");
});

it('should fetch the schema', function(){
Expand All @@ -118,7 +72,7 @@ describe('services', function() {
$rootScope.$apply();
$httpBackend.flush();

expect(mock.alert).toHaveBeenCalledWith(
expect($window.alert).toHaveBeenCalledWith(
'Extract schema could not be loaded');
});
});
Expand Down

0 comments on commit 63a7837

Please sign in to comment.