From f15e2a762b3326b7287f7ea28d987927dedc1d4a Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 5 Apr 2022 17:43:20 -0700 Subject: [PATCH] Add a regression test for sass/embedded-host-node#120 --- js-api-spec/legacy/importer.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/js-api-spec/legacy/importer.test.ts b/js-api-spec/legacy/importer.test.ts index f9efe07b53..1ba84eab8d 100644 --- a/js-api-spec/legacy/importer.test.ts +++ b/js-api-spec/legacy/importer.test.ts @@ -520,6 +520,27 @@ describe('the previous URL', () => { expect(importer1).toHaveBeenCalledTimes(2); expect(importer2).toHaveBeenCalled(); }); + + // Regression test for sass/embedded-host-node#120 + it('is passed after a relative import', () => + sandbox(dir => { + dir.write({ + 'test.scss': ` + @import "relative"; + @import "importer"; + `, + '_relative.scss': 'a {b: relative}', + }); + + const importer = jest.fn((url, prev) => { + expect(url).toBe('importer'); + expect(prev).toBe(dir('test.scss')); + return {contents: 'a {b: importer}'}; + }); + + expect(sass.renderSync({file: dir('test.scss'), importer}).css.toString()).toEqualIgnoringWhitespace('a { b: relative; } a { b: importer; }'); + expect(importer).toHaveBeenCalledTimes(1); + })); }); describe('this', () => {