From 33889f04d580886444fab553e951d0ee30b88d36 Mon Sep 17 00:00:00 2001 From: Kevin Van Lierde Date: Wed, 28 Jun 2023 01:35:07 +0200 Subject: [PATCH] dev: adds tests for plugin import resolution --- test/index.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/index.js b/test/index.js index 3a792e5..d878ba3 100644 --- a/test/index.js +++ b/test/index.js @@ -223,6 +223,40 @@ describe('@metalsmith/postcss', function () { }) }) + it('should do proper plugin imports', function (done) { + Metalsmith(fixture('use-absolute-paths')) + .use( + postcss({ + plugins: { 'postcss-import': {}, autoprefixer: true } + }) + ) + .process((err) => { + try { + assert.strictEqual(err, null) + done() + } catch (err) { + done(err) + } + }) + }) + + it('should throw when a plugin can not be imported', function (done) { + Metalsmith(fixture('use-absolute-paths')) + .use( + postcss({ + plugins: ['postcss-import', 'autoprefixer', 'cssnano', 'inexistant'] + }) + ) + .process((err) => { + try { + assert.strictEqual(err.code, 'ERR_MODULE_NOT_FOUND') + done() + } catch (err) { + done(err) + } + }) + }) + it('should support the PostCSS syntax options', function (done) { const metalsmith = Metalsmith(fixture('scss-syntax')) metalsmith