Skip to content

Commit cecf183

Browse files
test: appendData prependData, when they are string (#345)
1 parent a1cf249 commit cecf183

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/index.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,24 @@ test('should prepend data', async () => {
160160
expect(css).toEqual('.background {\n color: red;\n}\n');
161161
});
162162

163+
test('should prepend data', async () => {
164+
const loaderOptions = {
165+
prependData: `@background: red;`,
166+
};
167+
168+
let inspect;
169+
170+
const rules = moduleRules.basic(loaderOptions, {}, (i) => {
171+
inspect = i;
172+
});
173+
174+
await compile('prepend-data', rules).catch((e) => e);
175+
176+
const [css] = inspect.arguments;
177+
178+
expect(css).toEqual('.background {\n color: red;\n}\n');
179+
});
180+
163181
test('should append data', async () => {
164182
const loaderOptions = {
165183
appendData() {
@@ -180,6 +198,24 @@ test('should append data', async () => {
180198
expect(css).toEqual('.background {\n color: coral;\n}\n');
181199
});
182200

201+
test('should append data', async () => {
202+
const loaderOptions = {
203+
appendData: `@color1: coral;`,
204+
};
205+
206+
let inspect;
207+
208+
const rules = moduleRules.basic(loaderOptions, {}, (i) => {
209+
inspect = i;
210+
});
211+
212+
await compile('append-data', rules).catch((e) => e);
213+
214+
const [css] = inspect.arguments;
215+
216+
expect(css).toEqual('.background {\n color: coral;\n}\n');
217+
});
218+
183219
test('should allow a function to be passed through for `lessOptions`', async () => {
184220
await compileAndCompare('import-paths', {
185221
lessLoaderOptions: {

0 commit comments

Comments
 (0)