Skip to content

Commit

Permalink
test: appendData prependData, when they are string (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed Apr 22, 2020
1 parent a1cf249 commit cecf183
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/index.test.js
Expand Up @@ -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() {
Expand All @@ -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: {
Expand Down

0 comments on commit cecf183

Please sign in to comment.