From cecf183cd2b71a0eed39f94a34527ed4925e8d3d Mon Sep 17 00:00:00 2001 From: Alexey Lavinsky Date: Wed, 22 Apr 2020 17:10:14 +0300 Subject: [PATCH] test: appendData prependData, when they are string (#345) --- test/index.test.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/index.test.js b/test/index.test.js index 7595f086..3a6d211b 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -160,6 +160,24 @@ test('should prepend data', async () => { expect(css).toEqual('.background {\n color: red;\n}\n'); }); +test('should prepend data', async () => { + const loaderOptions = { + prependData: `@background: red;`, + }; + + let inspect; + + const rules = moduleRules.basic(loaderOptions, {}, (i) => { + inspect = i; + }); + + await compile('prepend-data', rules).catch((e) => e); + + const [css] = inspect.arguments; + + expect(css).toEqual('.background {\n color: red;\n}\n'); +}); + test('should append data', async () => { const loaderOptions = { appendData() { @@ -180,6 +198,24 @@ test('should append data', async () => { expect(css).toEqual('.background {\n color: coral;\n}\n'); }); +test('should append data', async () => { + const loaderOptions = { + appendData: `@color1: coral;`, + }; + + let inspect; + + const rules = moduleRules.basic(loaderOptions, {}, (i) => { + inspect = i; + }); + + await compile('append-data', rules).catch((e) => e); + + const [css] = inspect.arguments; + + expect(css).toEqual('.background {\n color: coral;\n}\n'); +}); + test('should allow a function to be passed through for `lessOptions`', async () => { await compileAndCompare('import-paths', { lessLoaderOptions: {