Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(test): Unit test fixed for astronaut space service
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbornsen authored and michaelkleinhenz committed Mar 3, 2017
1 parent a63d620 commit 44dbeb5
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/app/iteration/iterations.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe ('Iteration service - ', () => {

fakeSpaceService = {
getCurrentSpace: function() {
return Promise.resolve({
return {
'links': {
'self': 'http://localhost:8080/api/'
},
Expand All @@ -59,7 +59,7 @@ describe ('Iteration service - ', () => {
}
},
name: 'Project 1',
});
};
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
tick
} from '@angular/core/testing';

import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { DebugElement } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
Expand All @@ -15,6 +16,7 @@ import { Logger } from 'ngx-login-client';

import { WorkItem } from '../../models/work-item';
import { WorkItemService } from '../work-item.service';
import { AstronautService } from './../../shared/astronaut.service';

import { WorkItemQuickAddComponent } from './work-item-quick-add.component';

Expand All @@ -24,6 +26,65 @@ describe('Quick add work item component - ', () => {
let el: DebugElement;
let fakeWorkItem: WorkItem[];
let fakeService: any;
let fakeSpcaeService: any;

let spaces = [{
'name': 'Project 1',
'path': '',
'description': '',
'teams': [
{
'name': 'Team Project 1',
'members': [
{
'attributes': {
'fullName': 'Example User 0',
'imageURL': 'https://avatars.githubusercontent.com/u/2410471?v=3'
},
'id': 'user0',
'type': 'identities'
}
]
}
],
'defaultTeam': {
'name': 'Team Project 1',
'members': [
{
'attributes': {
'fullName': 'Example User 0',
'imageURL': 'https://avatars.githubusercontent.com/u/2410471?v=3'
},
'id': 'user0',
'type': 'identities'
}
]
},
'process': {

},
'privateSpace': false,
'id': '1f669678-ca2c-4cbb-b46d-5b70a98dde3c',
'attributes': {

},
'type': 'spaces',
'links': {
'self': 'http://localhost:8080/api/'
},
'relationships': {
'areas': {
'links': {
'related': 'http://localhost:8080/api/spaces/1f669678-ca2c-4cbb-b46d-5b70a98dde3c/areas'
}
},
'iterations': {
'links': {
'related': 'http://localhost:8080/api/spaces/1f669678-ca2c-4cbb-b46d-5b70a98dde3c/iterations'
}
}
}
}];

beforeEach(() => {
fakeWorkItem = [
Expand Down Expand Up @@ -60,6 +121,17 @@ describe('Quick add work item component - ', () => {
});
}
};

fakeSpcaeService = {
getCurrentSpaceBus: function() {
let currentSpaceSubjectSource = new BehaviorSubject<any>(spaces[0]);
return currentSpaceSubjectSource.asObservable();
},

getCurrentSpace: function() {
return Promise.resolve(spaces[0]);
}
};
});

beforeEach(async(() => {
Expand All @@ -73,6 +145,10 @@ describe('Quick add work item component - ', () => {
{
provide: WorkItemService,
useValue: fakeService
},
{
provide: AstronautService,
useValue: fakeSpcaeService
}
]
})
Expand Down
26 changes: 1 addition & 25 deletions src/app/work-item/work-item.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Work Item Service - ', () => {

let fakeAuthService: any;
let fakeSpcaeService: any;
let fakeSpaceService: any;

let spaces = [{
'name': 'Project 1',
Expand Down Expand Up @@ -116,30 +115,7 @@ describe('Work Item Service - ', () => {
},

getCurrentSpace: function() {
return Promise.resolve(spaces[0]);
}
};

fakeSpaceService = {
getCurrentSpace: function() {
return Promise.resolve({
'links': {
'self': 'http://localhost:8080/api/'
},
'relationships': {
'areas': {
'links': {
'related': 'http://localhost:8080/api/spaces/1f669678-ca2c-4cbb-b46d-5b70a98dde3c/areas'
}
},
'iterations': {
'links': {
'related': 'http://localhost:8080/api/spaces/1f669678-ca2c-4cbb-b46d-5b70a98dde3c/iterations'
}
}
},
name: 'Project 1'
});
return spaces[0];
}
};

Expand Down

0 comments on commit 44dbeb5

Please sign in to comment.