/**
 * Copyright (C) Oranda - All Rights Reserved (January 2021 - January 2021)
 */ import { HaliaCore , HaliaPlugin , OptionalDependencies , OptionalDependenciesPatch } from "../src" ; import { haliaCoreAPI , HaliaStack } from "../src/halia" ; import { expect } from "chai" ; describe ( "Extensions" , ( ) => { it ( "should have no registered elements" , async ( ) => { expect ( haliaCoreAPI . importRegister . size ( ) ) . equals ( 0 ) ; } ) ; it ( "should not inject optional dependencies" , async ( ) => { const stack = new HaliaStack < HaliaPlugin & OptionalDependenciesPatch > ( ) ; stack . register ( { name : "P1" , install : ( ) => "P1" , id : "p1" } ) ; stack . register ( { name : "P2" , install : ( { p1 } ) => expect ( p1 ) . equals ( undefined ) , id : "p2" , optionalDependencies : [ "p1" ] } ) ; await stack . build ( ) ; } ) ; it ( "should build with optional dependencies" , async ( ) => { const coreStack = new HaliaStack ( ) ; coreStack . register ( HaliaCore ) ; coreStack . register ( OptionalDependencies ) ; await coreStack . build ( ) ; expect ( haliaCoreAPI . importRegister . size ( ) ) . equals ( 1 ) ; } ) ; it ( "should inject optional dependencies" , async ( ) => { const stack = new HaliaStack < HaliaPlugin & OptionalDependenciesPatch > ( ) ; stack . register ( { name : "P1" , install : ( ) => "P1" , id : "p1" } ) ; stack . register ( { name : "P2" , install : ( { p1 } ) => expect ( p1 ) . equals ( "P1" ) , id : "p2" , optionalDependencies : [ "p1" ] } ) ; await stack . build ( ) ; } ) ; } ) ;