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

Commit

Permalink
fix(test): Fixed tests for new work item types JSON API compaitability
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbornsen authored and joshuawilson committed Mar 4, 2017
1 parent 1e280ec commit 4a55fc2
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 74 deletions.
1 change: 1 addition & 0 deletions src/app/shared/mock-data/schema-mock-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class SchemaMockGenerator {
'id' : '86af5178-9b41-469b-9096-57e5155c3f31',
'attributes' : {
'name' : 'Planner Item',
'icon': 'fa-question',
'fields' : {
'system.created_at' : {
'type' : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,84 @@ 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'
let wiTypes = [
{
'id' : '86af5178-9b41-469b-9096-57e5155c3f31',
'attributes' : {
'name' : 'Planner Item',
'icon': 'fa-question',
'fields' : {
'system.created_at' : {
'type' : {
'kind' : 'instant'
},
'required' : false
},
'system.remote_item_id' : {
'required' : false,
'type' : {
'kind' : 'string'
}
]
}
],
'defaultTeam': {
'name': 'Team Project 1',
'members': [
{
'attributes': {
'fullName': 'Example User 0',
'imageURL': 'https://avatars.githubusercontent.com/u/2410471?v=3'
},
'system.area' : {
'type' : {
'kind' : 'area'
},
'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'
}
}
}
}];
'required' : false
},
'system.title' : {
'required' : true,
'type' : {
'kind' : 'string'
}
},
'system.creator' : {
'type' : {
'kind' : 'user'
},
'required' : true
},
'system.assignees' : {
'type' : {
'kind' : 'list',
'componentType' : 'user'
},
'required' : false
},
'system.state' : {
'required' : true,
'type' : {
'kind' : 'enum',
'values' : [
'new',
'open',
'in progress',
'resolved',
'closed'
],
'baseType' : 'string'
}
},
'system.description' : {
'required' : false,
'type' : {
'kind' : 'markup'
}
},
'system.iteration' : {
'type' : {
'kind' : 'iteration'
},
'required' : false
}
},
'description' : 'Description for Planner Item',
'version' : 0
},
'type' : 'workitemtypes'
}
];

beforeEach(() => {
fakeWorkItem = [
Expand Down Expand Up @@ -118,18 +137,8 @@ describe('Quick add work item component - ', () => {
resolve(workItem);
// reject('Title is empty');
});
}
};

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

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

Expand Down
87 changes: 81 additions & 6 deletions src/app/work-item/work-item.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,84 @@ describe('Work Item Service - ', () => {
}
}];

let wiTypes = [
{
'id' : '86af5178-9b41-469b-9096-57e5155c3f31',
'attributes' : {
'name' : 'Planner Item',
'icon': 'fa-question',
'fields' : {
'system.created_at' : {
'type' : {
'kind' : 'instant'
},
'required' : false
},
'system.remote_item_id' : {
'required' : false,
'type' : {
'kind' : 'string'
}
},
'system.area' : {
'type' : {
'kind' : 'area'
},
'required' : false
},
'system.title' : {
'required' : true,
'type' : {
'kind' : 'string'
}
},
'system.creator' : {
'type' : {
'kind' : 'user'
},
'required' : true
},
'system.assignees' : {
'type' : {
'kind' : 'list',
'componentType' : 'user'
},
'required' : false
},
'system.state' : {
'required' : true,
'type' : {
'kind' : 'enum',
'values' : [
'new',
'open',
'in progress',
'resolved',
'closed'
],
'baseType' : 'string'
}
},
'system.description' : {
'required' : false,
'type' : {
'kind' : 'markup'
}
},
'system.iteration' : {
'type' : {
'kind' : 'iteration'
},
'required' : false
}
},
'description' : 'Description for Planner Item',
'version' : 0
},
'type' : 'workitemtypes'
}
];

beforeEach(() => {
fakeAuthService = {
getToken: function () {
Expand All @@ -122,10 +200,6 @@ describe('Work Item Service - ', () => {
provide: AuthenticationService,
useValue: fakeAuthService
},
{
provide: AuthenticationService,
useValue: fakeAuthService
},
// MockDataService should be removed at some point
MockDataService,
WorkItemService,
Expand All @@ -149,6 +223,7 @@ describe('Work Item Service - ', () => {
mockService = mock;
iterationService = iService;
(apiService as any)._currentSpace = spaces[0];
(apiService as any).workItemTypes = wiTypes;
}
));
let resp: WorkItem[] = [
Expand All @@ -171,7 +246,7 @@ describe('Work Item Service - ', () => {
},
'baseType': {
'data': {
'id': 'system.userstory',
'id': '86af5178-9b41-469b-9096-57e5155c3f31',
'type': 'workitemtypes'
}
},
Expand All @@ -183,7 +258,7 @@ describe('Work Item Service - ', () => {
let response = {data: resp, links: {}};
let checkResp = cloneDeep(resp);
checkResp.forEach((item) => item['relationalData'] = Object(
{ assignees: [], creator: null, iteration: null }));
{ assignees: [], creator: null, iteration: null, wiType: wiTypes[0] }));

it('Get work items', async(() => {
mockService.connections.subscribe((connection: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/work-item/work-item.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class WorkItemService {
private workItemIdIndexMap = {};
private prevFilters: any = [];
private iterations: IterationModel[] = [];
private _currentSpace;
public _currentSpace;

constructor(private http: Http,
private broadcaster: Broadcaster,
Expand Down

0 comments on commit 4a55fc2

Please sign in to comment.