Add default value for HalLink.$source on instantiation

pull/4338/head
Alex Dik 9 years ago
parent fcfd320a81
commit e3139d2150
  1. 4
      frontend/app/components/api/api-v3/hal-resources/hal-resource.service.test.ts
  2. 4
      frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts

@ -46,6 +46,10 @@ describe('HalResource service', () => {
expect(HalResource).to.exist;
});
it('should be instantiable using a default object', () => {
expect(new HalResource().href).to.equal(null);
});
it('should set its source to _plain if _plain is a property of the source', () => {
let source = {
_plain: {

@ -50,7 +50,7 @@ export default class HalResource {
}
protected static getEmptyResource():any {
return {_links: {self: null}};
return {_links: {self: {}}};
}
public get name():string {
@ -86,7 +86,7 @@ export default class HalResource {
});
}
constructor(public $source:any, public $loaded:boolean = true) {
constructor(public $source:any = HalResource.getEmptyResource(), public $loaded:boolean = true) {
this.$source = $source._plain || $source;
this.proxyProperties();

Loading…
Cancel
Save