1+ /**
2+ * Copyright 2018 The AMP HTML Authors. All Rights Reserved.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS-IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ import test from 'ava' ;
18+ import { defaultCompileOptions } from '../dist/index' ;
19+ import { readFileSync } from 'fs' ;
20+
21+ test ( 'with no rollup configuration defaults are valid' , t => {
22+ const options = defaultCompileOptions ( { } ) ;
23+ t . deepEqual ( options , {
24+ language_out : 'NO_TRANSPILE' ,
25+ assume_function_wrapper : false ,
26+ warning_level : 'QUIET' ,
27+ } ) ;
28+ } ) ;
29+
30+ test ( 'when rollup configuration specifies format iife with a name, an extern is generated' , t => {
31+ const options = defaultCompileOptions ( {
32+ format : 'iife' ,
33+ name : 'Wrapper'
34+ } ) ;
35+
36+ t . not ( options . externs , undefined ) ;
37+
38+ const externs = readFileSync ( options . externs , 'utf8' ) ;
39+ t . is ( externs , `function Wrapper(){}` ) ;
40+ } ) ;
41+
42+ test ( 'when rollup configuration specifies format es, assume_function_wrapper is true' , t => {
43+ const options = defaultCompileOptions ( {
44+ format : 'es' ,
45+ } ) ;
46+
47+ t . true ( options . assume_function_wrapper ) ;
48+ } ) ;
0 commit comments