test(ngcc): use isNamedDeclaration() helper to simplify tests (#38959) (#39272)

Previously these tests were checking multiple specific expression
types. The new helper function is more general and will also support
`PropertyAccessExpression` nodes for `InlineDeclaration` types.

PR Close #38959

PR Close #39272
This commit is contained in:
Pete Bacon Darwin
2020-09-29 20:52:40 +01:00
committed by atscott
parent 26988f0d62
commit 8fa78d10ab
3 changed files with 10 additions and 9 deletions

View File

@ -10,8 +10,8 @@ import * as ts from 'typescript';
import {absoluteFrom, AbsoluteFsPath, getSourceFileOrError} from '../../../src/ngtsc/file_system';
import {runInEachFileSystem, TestFile} from '../../../src/ngtsc/file_system/testing';
import {MockLogger} from '../../../src/ngtsc/logging/testing';
import {DeclarationNode, isNamedClassDeclaration, isNamedVariableDeclaration} from '../../../src/ngtsc/reflection';
import {getDeclaration} from '../../../src/ngtsc/testing';
import {DeclarationNode} from '../../../src/ngtsc/reflection';
import {getDeclaration, isNamedDeclaration} from '../../../src/ngtsc/testing';
import {loadTestFiles} from '../../../test/helpers';
import {ModuleWithProvidersAnalyses, ModuleWithProvidersAnalyzer} from '../../src/analysis/module_with_providers_analyzer';
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
@ -661,9 +661,7 @@ runInEachFileSystem(() => {
}
function getName(node: DeclarationNode|null): string {
return node && (isNamedVariableDeclaration(node) || isNamedClassDeclaration(node)) ?
`${node.name.text}.` :
'';
return node && isNamedDeclaration(node) ? `${node.name.text}.` : '';
}
});
});