Repository: angular/angular
File: packages/compiler-cli/test/ngtsc/doc_extraction/directive_doc_extraction_spec.ts (TypeScript)

Code before:

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['ngComboboxPopupContainer']);
      });

      it('should extract multiple aliases from multiple attribute selectors', () => {
        env.write(
          'index.ts',
          `
          import {Directive} from '@angular/core';
          @Directive({
            selector: '[attr1][attr2]',
          })
          export class MultiAttr { }
        `,
        );

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['attr1', 'attr2']);
      });

      it('should extract aliases from complex selector with element and multiple attributes', () => {
        env.write(
          'index.ts',
          `
          import {Directive} from '@angular/core';
          @Directive({
            selector: 'button[cdkButton]',
          })
          export class CdkButton { }
        `,
        );

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['cdkButton']);
      });

      it('should not extract aliases from element-only selector', () => {
        env.write(
          'index.ts',
          `
          import {Component} from '@angular/core';

Review comment (suggestion):
I'm not sure I would agree with this test case.  `[attr1][attr2]` requires both attributes to be present. `[attr1],[attr2]` would be the correct selector for a directive that accepts either of those attributes. 

Code after:

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['ngComboboxPopupContainer']);
      });

      it('should extract multiple aliases from multiple attribute selectors', () => {
        env.write(
          'index.ts',
          `
          import {Directive} from '@angular/core';
          @Directive({
            selector: '[attr1],[attr2]',
          })
          export class MultiAttr { }
        `,
        );

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['attr1', 'attr2']);
      });

      it('should extract aliases from complex selector with element and multiple attributes', () => {
        env.write(
          'index.ts',
          `
          import {Directive} from '@angular/core';
          @Directive({
            selector: 'button[cdkButton]',
          })
          export class CdkButton { }
        `,
        );

        const docs: DocEntry[] = env.driveDocsExtraction('index.ts');
        expect(docs.length).toBe(1);

        const directiveEntry = docs[0];
        expect(directiveEntry.aliases).toEqual(['cdkButton']);
      });

      it('should not extract aliases from element-only selector', () => {
        env.write(
          'index.ts',
          `
          import {Component} from '@angular/core';