UNPKG

@storybook/angular

Version:

Storybook for Angular: Develop Angular components in isolation with hot reloading.

23 lines (22 loc) 1.02 kB
import { Component, NgModule } from '@angular/core'; import { describe, expect, it } from 'vitest'; import { isComponentAlreadyDeclared } from './NgModulesAnalyzer'; const FooComponent = Component({})(class { }); const BarComponent = Component({})(class { }); const BetaModule = NgModule({ declarations: [FooComponent] })(class { }); const AlphaModule = NgModule({ imports: [BetaModule] })(class { }); describe('isComponentAlreadyDeclaredInModules', () => { it('should return true when the component is already declared in one of modules', () => { expect(isComponentAlreadyDeclared(FooComponent, [], [AlphaModule])).toEqual(true); }); it('should return true if the component is in moduleDeclarations', () => { expect(isComponentAlreadyDeclared(BarComponent, [BarComponent], [AlphaModule])).toEqual(true); }); it('should return false if the component is not declared', () => { expect(isComponentAlreadyDeclared(BarComponent, [], [AlphaModule])).toEqual(false); }); });