import { expect } from 'chai'; import { isPathAngularComponent, extractComponentInlineTemplate } from '../../src/utils/utils'; describe('Utils', () => { it('should recognize js extension as angular component', () => { const result = isPathAngularComponent('test.js'); expect(result).to.equal(true); }); it('should recognize ts extension as angular component', () => { const result = isPathAngularComponent('test.ts'); expect(result).to.equal(true); }); it('should not recognize html extension as angular component', () => { const result = isPathAngularComponent('test.html'); expect(result).to.equal(false); }); it('should extract inline template', () => { const contents = ` @Component({ selector: 'test', template: '
Hello World
' }) export class TestComponent { } `; const template = extractComponentInlineTemplate(contents); expect(template).to.equal('Hello World
'); }); it('should extract inline template without html', () => { const contents = ` @Component({ selector: 'test', template: 'Hello World' }) export class TestComponent { } `; const template = extractComponentInlineTemplate(contents); expect(template).to.equal('Hello World'); }); it('should extract inline template spanning multiple lines', () => { const contents = ` @Component({ selector: 'test', template: 'Hello World
', styles: [' p { color: red; } '] }) export class TestComponent { } `; const template = extractComponentInlineTemplate(contents); expect(template).to.equal('\n\t\t\t\t\t\n\t\t\t\t\t\tHello World\n\t\t\t\t\t
\n\t\t\t\t'); }); });