angular/packages/compiler-cli/test/ngtsc/docs_spec.ts
Jeremy Elbourn 7e82df45c5 feat(compiler): initial skeleton for API doc extraction (#51733)
This commit adds a barebones skeleton for extracting information to be used for extracting info that can be used for API reference generation. Subsequent PRs will expand on this with increasingly real extraction. I started with @alxhub's #51615 and very slightly polished to get to this minimal commit.

PR Close #51733
2023-09-18 12:29:19 +02:00

39 lines
1.1 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {DocEntry} from '@angular/compiler-cli/src/ngtsc/docs';
import {runInEachFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
import {loadStandardTestFiles} from '@angular/compiler-cli/src/ngtsc/testing';
import {NgtscTestEnvironment} from './env';
const testFiles = loadStandardTestFiles({fakeCore: true, fakeCommon: true});
runInEachFileSystem(os => {
let env!: NgtscTestEnvironment;
describe('ngtsc docs extraction', () => {
beforeEach(() => {
env = NgtscTestEnvironment.setup(testFiles);
env.tsconfig();
});
it('should extract classes', () => {
env.write('test.ts', `
class UserProfile {}
class CustomSlider {}
`);
const docs: DocEntry[] = env.driveDocsExtraction();
expect(docs.length).toBe(2);
expect(docs[0].name).toBe('UserProfile');
expect(docs[1].name).toBe('CustomSlider');
});
});
});