1// Copyright 2025 The Pigweed Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4// use this file except in compliance with the License. You may obtain a copy of 5// the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12// License for the specific language governing permissions and limitations under 13// the License. 14 15import * as assert from 'assert'; 16 17import { loadLegacySettings } from './legacy'; 18 19suite('load legacy settings', () => { 20 test('successfully loads valid settings', async () => { 21 const settingsData = `config_title: pw_ide 22default_target: pw_strict_host_clang_debug 23compdb_gen_cmd: gn gen out`; 24 25 const settings = await loadLegacySettings(settingsData); 26 27 assert.ok(Object.prototype.hasOwnProperty.call(settings, 'default_target')); 28 assert.equal('pw_strict_host_clang_debug', settings?.default_target); 29 }); 30 31 test('returns null on invalid settings', async () => { 32 const settingsData = `default_target: 33 - pw_strict_host_clang_debug`; 34 35 const settings = await loadLegacySettings(settingsData); 36 37 assert.equal(null, settings); 38 }); 39 40 test('returns null on unparsable settings', async () => { 41 const settingsData = '- 2a05:4800:1:100::'; 42 43 const settings = await loadLegacySettings(settingsData); 44 45 assert.equal(null, settings); 46 }); 47}); 48