This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if object matches interface including type of property | |
* Nested propertys not supported for now | |
*/ | |
function checkInterface(originalObject, interfaceObject, disableTypeChecking) { | |
for (var key in interfaceObject) { | |
// If original object does not contain property of interface | |
if (!originalObject.hasOwnProperty(key)) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TestBed, inject } from '@angular/core/testing'; | |
import { Mock } from 'ts-mocks'; | |
import { MainService } from './main.service'; | |
import { SubService } from './sub.service'; | |
describe('MainService using useValue', () => { | |
let mockService: Mock<SubService>; | |
let systemUnderTest: MainService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from "lodash"; | |
/** This method can be used to simplify objects with empty properties. propX: undefined of propX: {} will be removed */ | |
const compact = (obj: any): any => { | |
return _(obj) | |
.mapValues((propertyValue) => { | |
if (!_.isObject(propertyValue)) { | |
return propertyValue; | |
} else if (_.isArray(propertyValue)) { | |
return propertyValue.map((arrayItem) => { |