16a23e08bSopenharmony_ci/*
26a23e08bSopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
36a23e08bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
46a23e08bSopenharmony_ci * you may not use this file except in compliance with the License.
56a23e08bSopenharmony_ci * You may obtain a copy of the License at
66a23e08bSopenharmony_ci *
76a23e08bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
86a23e08bSopenharmony_ci *
96a23e08bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
106a23e08bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
116a23e08bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126a23e08bSopenharmony_ci * See the License for the specific language governing permissions and
136a23e08bSopenharmony_ci * limitations under the License.
146a23e08bSopenharmony_ci */
156a23e08bSopenharmony_ci
166a23e08bSopenharmony_ciconst assert = require('chai').assert;
176a23e08bSopenharmony_ciconst fn = require('./compile');
186a23e08bSopenharmony_ciconst argv = require('yargs').argv;
196a23e08bSopenharmony_ciconst argvSelect = {
206a23e08bSopenharmony_ci  key1: {},
216a23e08bSopenharmony_ci  key2: { buildMode: 'release' },
226a23e08bSopenharmony_ci  key3: { buildMode: 'debug' },
236a23e08bSopenharmony_ci  key4: { buildMode: 'develope' },
246a23e08bSopenharmony_ci};
256a23e08bSopenharmony_ciconst compileResult = {
266a23e08bSopenharmony_ci  key1: true,
276a23e08bSopenharmony_ci  key2: false,
286a23e08bSopenharmony_ci  key3: true,
296a23e08bSopenharmony_ci  key4: true,
306a23e08bSopenharmony_ci};
316a23e08bSopenharmony_ci/**
326a23e08bSopenharmony_ci * Test whether the existence of the sourcemap file is reasonable when different 'buildMode' is passed in.
336a23e08bSopenharmony_ci * Only when the 'buildMode' is 'release', the sourcemap does not exist, otherwise it exists
346a23e08bSopenharmony_ci */
356a23e08bSopenharmony_cidescribe('Compilation result test', () => {
366a23e08bSopenharmony_ci  it('sourcemap', (done) => {
376a23e08bSopenharmony_ci    const key = argv.buildMode ? argv.buildMode : 'key1';
386a23e08bSopenharmony_ci    fn(argvSelect[key])
396a23e08bSopenharmony_ci        .then((flag) => {
406a23e08bSopenharmony_ci          assert.equal(flag, compileResult[key], 'result pass');
416a23e08bSopenharmony_ci          done();
426a23e08bSopenharmony_ci        })
436a23e08bSopenharmony_ci        .catch(done);
446a23e08bSopenharmony_ci  });
456a23e08bSopenharmony_ci});
46