|
| 1 | +/* eslint-disable global-require */ |
| 2 | +/* eslint-disable @typescript-eslint/no-require-imports */ |
| 3 | + |
1 | 4 | import { resolve } from 'path';
|
2 | 5 |
|
3 | 6 | import autoPreprocess from '../../src';
|
@@ -30,22 +33,34 @@ const implementation: Options.Sass['implementation'] = {
|
30 | 33 | };
|
31 | 34 |
|
32 | 35 | describe('transformer - scss', () => {
|
33 |
| - it('should prepend scss content via `data` option property - via default async render', async () => { |
34 |
| - const template = `<style lang="scss"></style>`; |
| 36 | + it('should return @imported files as dependencies - via default async render', async () => { |
| 37 | + const template = `<style lang="scss">@import "fixtures/style.scss";</style>`; |
35 | 38 | const opts = autoPreprocess({
|
36 | 39 | scss: {
|
37 |
| - prependData: '$color:red;div{color:$color}', |
| 40 | + // we force the node-sass implementation here because of |
| 41 | + // https://github.com/sveltejs/svelte-preprocess/issues/163#issuecomment-639694477 |
| 42 | + implementation: require('node-sass'), |
38 | 43 | },
|
39 | 44 | });
|
40 | 45 |
|
41 | 46 | const preprocessed = await preprocess(template, opts);
|
42 | 47 |
|
43 |
| - expect(preprocessed.toString()).toContain('red'); |
| 48 | + expect(preprocessed.dependencies).toContain( |
| 49 | + resolve(__dirname, '..', 'fixtures', 'style.scss').replace(/[\\/]/g, '/'), |
| 50 | + ); |
44 | 51 | });
|
45 | 52 |
|
46 |
| - it('should return @imported files as dependencies - via default async render', async () => { |
| 53 | + it('should return @imported files as dependencies - via renderSync', async () => { |
47 | 54 | const template = `<style lang="scss">@import "fixtures/style.scss";</style>`;
|
48 |
| - const opts = autoPreprocess(); |
| 55 | + const opts = autoPreprocess({ |
| 56 | + scss: { |
| 57 | + // we force the node-sass implementation here because of |
| 58 | + // https://github.com/sveltejs/svelte-preprocess/issues/163#issuecomment-639694477 |
| 59 | + implementation: require('node-sass'), |
| 60 | + renderSync: true, |
| 61 | + }, |
| 62 | + }); |
| 63 | + |
49 | 64 | const preprocessed = await preprocess(template, opts);
|
50 | 65 |
|
51 | 66 | expect(preprocessed.dependencies).toContain(
|
@@ -80,21 +95,6 @@ describe('transformer - scss', () => {
|
80 | 95 | expect(preprocessed.toString()).toContain('blue');
|
81 | 96 | });
|
82 | 97 |
|
83 |
| - it('should return @imported files as dependencies - via renderSync', async () => { |
84 |
| - const template = `<style lang="scss">@import "fixtures/style.scss";</style>`; |
85 |
| - const opts = autoPreprocess({ |
86 |
| - scss: { |
87 |
| - renderSync: true, |
88 |
| - }, |
89 |
| - }); |
90 |
| - |
91 |
| - const preprocessed = await preprocess(template, opts); |
92 |
| - |
93 |
| - expect(preprocessed.dependencies).toContain( |
94 |
| - resolve(__dirname, '..', 'fixtures', 'style.scss').replace(/[\\/]/g, '/'), |
95 |
| - ); |
96 |
| - }); |
97 |
| - |
98 | 98 | it('should use the specified implementation via the `implementation` option property - via renderSync', async () => {
|
99 | 99 | const template = `<style lang="scss">h1{}</style>`;
|
100 | 100 | const opts = autoPreprocess({
|
|
0 commit comments