@@ -40,23 +40,81 @@ const props = {
4040 compilers : "goodCompiler:&badCompiler"
4141} ;
4242
43+ const noOptionsAtAll = {
44+ compilers : "goodCompiler"
45+ } ;
46+
47+ const noBaseOptions = {
48+ compilers : "goodCompiler" ,
49+ options : "bar"
50+ } ;
51+
52+ const onlyBaseOptions = {
53+ compilers : "goodCompiler" ,
54+ baseOptions : "foo"
55+ } ;
56+
57+ const bothOptions = {
58+ compilers : "goodCompiler" ,
59+ baseOptions : "foo" ,
60+ options : "bar"
61+ } ;
62+
4363describe ( 'Compiler-finder' , function ( ) {
4464 let compilerProps ;
4565
66+ let noOptionsAtAllProps ;
67+ let noBaseOptionsProps ;
68+ let onlyBaseOptionsProps ;
69+ let bothOptionsProps ;
70+
71+ let optionsHandler ;
72+
4673 before ( ( ) => {
4774 compilerProps = new properties . CompilerProps ( languages , properties . fakeProps ( props ) ) ;
48- } ) ;
4975
50- it ( 'should not hang for undefined groups (Bug #860)' , ( ) => {
51- const optionsHandler = {
76+ noOptionsAtAllProps = new properties . CompilerProps ( languages , properties . fakeProps ( noOptionsAtAll ) ) ;
77+ noBaseOptionsProps = new properties . CompilerProps ( languages , properties . fakeProps ( noBaseOptions ) ) ;
78+ onlyBaseOptionsProps = new properties . CompilerProps ( languages , properties . fakeProps ( onlyBaseOptions ) ) ;
79+ bothOptionsProps = new properties . CompilerProps ( languages , properties . fakeProps ( bothOptions ) ) ;
80+
81+ optionsHandler = {
5282 get : ( ) => {
5383 return {
5484 libs : { } ,
5585 tools : { }
5686 } ;
5787 }
5888 } ;
89+ } ) ;
90+
91+ it ( 'should not hang for undefined groups (Bug #860)' , ( ) => {
92+
5993 const finder = new CompilerFinder ( { } , compilerProps , properties . fakeProps ( { } ) , { } , optionsHandler ) ;
6094 return finder . getCompilers ( ) . should . eventually . have . lengthOf ( 2 ) ;
61- } )
95+ } ) ;
96+
97+ it ( 'should behave properly if no options are provided at all' , async ( ) => {
98+ const finder = new CompilerFinder ( { } , noOptionsAtAllProps , properties . fakeProps ( { } ) , { } , optionsHandler ) ;
99+ const compilers = await finder . getCompilers ( ) ;
100+ compilers [ 0 ] . options . should . equal ( '' ) ;
101+ } ) ;
102+
103+ it ( 'should behave properly if no base options are provided' , async ( ) => {
104+ const finder = new CompilerFinder ( { } , noBaseOptionsProps , properties . fakeProps ( { } ) , { } , optionsHandler ) ;
105+ const compilers = await finder . getCompilers ( ) ;
106+ compilers [ 0 ] . options . should . equal ( 'bar' ) ;
107+ } ) ;
108+
109+ it ( 'should behave properly if only base options are provided' , async ( ) => {
110+ const finder = new CompilerFinder ( { } , onlyBaseOptionsProps , properties . fakeProps ( { } ) , { } , optionsHandler ) ;
111+ const compilers = await finder . getCompilers ( ) ;
112+ compilers [ 0 ] . options . should . equal ( 'foo' ) ;
113+ } ) ;
114+
115+ it ( 'should behave properly if both options are provided' , async ( ) => {
116+ const finder = new CompilerFinder ( { } , bothOptionsProps , properties . fakeProps ( { } ) , { } , optionsHandler ) ;
117+ const compilers = await finder . getCompilers ( ) ;
118+ compilers [ 0 ] . options . should . equal ( 'foo bar' ) ;
119+ } ) ;
62120} ) ;
0 commit comments