Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
feat(tests): improove code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rosostolato committed Aug 17, 2018
1 parent 993011c commit 46eb968
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demo/restApi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class RestApi extends RestBase {
}

protected mapModel(method: HttpMethod, route: string, data: any) {
if (route === 'posts') {
if (method !== HttpMethod.DELETE && route === 'posts') {
return new Post(data);
}

Expand Down
5 changes: 3 additions & 2 deletions src/restModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class RestModelBase<T> extends RestRoute {
}

delete(params?: HttpParams): Observable<any> {
return this.createModelHttpRequest('DELETE', params);
return this.createModelHttpRequest('DELETE', params)
.pipe(map(response => this.makeRest<T>(HttpMethod.PUT, response)));
}

getPlain(): T {
Expand All @@ -56,7 +57,7 @@ export class RestModelBase<T> extends RestRoute {
];

for (const key of methods) {
if (key) { delete proto[key]; }
delete proto[key];
}

Object.setPrototypeOf(plain, proto);
Expand Down
4 changes: 2 additions & 2 deletions test/restModel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TestBed, async } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { RestApi } from '../demo/restApi.service';
import { expect } from 'chai';
import { RestModel, RestRoute } from '../src';
import { RestModel, RestRoute, RestModelBase } from '../src';
import { Post } from '../demo/models/Post';

describe('RestModel', () => {
Expand Down Expand Up @@ -30,7 +30,7 @@ describe('RestModel', () => {

it('should delete', async(() => {
post.delete().subscribe(res => {
expect(res).to.be.eql({});
expect(res).to.be.an.instanceof(RestModelBase);
});
}));

Expand Down

0 comments on commit 46eb968

Please sign in to comment.