Skip to content

Commit

Permalink
fix: better types
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Feb 11, 2021
1 parent 07b7d18 commit bd7f72b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions libs/ng-mocks/src/lib/common/ng-mocks-universe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ ngMocksUniverse.getResolution = (def: any): undefined | 'mock' | 'keep' | 'repla
return set.get(def);
}

if (!ngMocksUniverse.getDefaults().has(def)) {
const defValue = ngMocksUniverse.getDefaults().get(def);
if (!defValue) {
return undefined;
}

const [value] = ngMocksUniverse.getDefaults().get(def);
const [value] = defValue;

return value;
};
Expand All @@ -77,11 +78,13 @@ ngMocksUniverse.getBuildDeclaration = (def: any): undefined | null | any => {
if (ngMocksUniverse.builtDeclarations.has(def)) {
return ngMocksUniverse.builtDeclarations.get(def);
}
if (!ngMocksUniverse.getDefaults().has(def)) {

const defValue = ngMocksUniverse.getDefaults().get(def);
if (!defValue) {
return;
}

const [mode, replacement] = ngMocksUniverse.getDefaults().get(def);
const [mode, replacement] = defValue;

if (mode === 'exclude') {
return null;
Expand All @@ -98,11 +101,13 @@ ngMocksUniverse.hasBuildDeclaration = (def: any): boolean => {
if (ngMocksUniverse.builtDeclarations.has(def)) {
return true;
}
if (!ngMocksUniverse.getDefaults().has(def)) {

const defValue = ngMocksUniverse.getDefaults().get(def);
if (!defValue) {
return false;
}

const [mode] = ngMocksUniverse.getDefaults().get(def);
const [mode] = defValue;

return mode !== 'mock';
};
Expand Down

0 comments on commit bd7f72b

Please sign in to comment.