Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: appendData prependData, when they are string #345

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,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 @@ -176,6 +194,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