import { join } from 'path'; import { combineLatest } from 'rxjs'; import { map, shareReplay, tap } from 'rxjs/operators'; import { getLayoutsForTypes } from '../src/utils/layout.utils'; import { getPageTypeDependencies } from '../src/utils/type.dependencies'; import { readWchTools } from '../src/utils/wchtools'; import { getAssetBaseDir } from './utils/test.utils'; describe('type.dependencies', () => { function _toNames(aTypes: any[]): string[] { return aTypes.map((type: any) => type.name); } it('should detect type dependencies', () => { const assetBase = getAssetBaseDir(); const srcData = join(assetBase, 'test', 'ryan-group'); // load wchtools const rxTools = readWchTools(srcData).pipe(shareReplay()); // map const rxDeps = rxTools.pipe( map(getPageTypeDependencies) ); const rxLayouts = combineLatest(rxDeps, rxTools).pipe( map(([deps, tools]) => deps.map(dep => getLayoutsForTypes(dep, tools))) ); return rxLayouts.toPromise(); }); });