From 37e290a599b157d939111a50dfec630e18fd07b6 Mon Sep 17 00:00:00 2001 From: Pierre Cavin Date: Thu, 12 Oct 2023 01:50:39 +0200 Subject: [PATCH] test: restore 100% branch coverage --- test/load-parser-config.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/load-parser-config.test.js b/test/load-parser-config.test.js index 6c3de649..46da4248 100644 --- a/test/load-parser-config.test.js +++ b/test/load-parser-config.test.js @@ -1,4 +1,6 @@ import test from "ava"; +import importFrom from "import-from-esm"; +import sinon from "sinon"; import loadParserConfig from "../lib/load-parser-config.js"; const cwd = process.cwd(); @@ -100,3 +102,12 @@ test('Throw error if "config" doesn`t exist', async (t) => { test('Throw error if "preset" doesn`t exist', async (t) => { await t.throwsAsync(loadParserConfig({ preset: "unknown-preset" }, { cwd }), { code: "MODULE_NOT_FOUND" }); }); + +test.serial("Load preset and config correctly when importFrom.silent fails", async (t) => { + sinon.stub(importFrom, "silent").returns(undefined); + + await loadPreset(t, "angular"); + await loadConfig(t, "angular"); + + sinon.restore(); +});