<commit_before>import test from 'ava';
import fs from 'fs';
import path from 'path';
import postcss from 'postcss';
import sass from 'node-sass';
import { SourceMapConsumer } from 'source-map';
import perfectionist from 'perfectionist';
import postcssNPM from '../src/index';

function read(file) {
  return fs.readFileSync(`./expected/${file}.css`, 'utf8').trim();
}

function runNPM(input, opts, parserOpts = {}) {
  return postcss([
    postcssNPM(opts),
    perfectionist({ indentSize: 2, maxAtRuleLength: false, maxSelectorLength: 1 }),
  ]).process(input, parserOpts);
}

test('Import relative source file', (t) => {
  const input = '@import "./test";';
  return runNPM(input, {}, { from: 'file.css' })
  .then(result => {
    t.deepEqual(result.css.trim(), '.test {\n  content: "Test file";\n}');
  });
});

test('Import package', (t) => {
  const input = '@import "test";';
  return runNPM(input, {}, { from: 'index.css' })
  .then(result => {
    t.deepEqual(result.css.trim(), '.test {\n  content: "Test package";\n}');
  });
});

test('Import package with custom style file', (t) => {
  const input = '@import "custom";';
  return runNPM(input, {}, { from: 'index.css' })
  .then(result => {<commit_msg>started new test for import parsing<commit_after>import test from 'ava';
import fs from 'fs';
import path from 'path';
import postcss from 'postcss';
import sass from 'node-sass';
import { SourceMapConsumer } from 'source-map';
import perfectionist from 'perfectionist';
import postcssNPM from '../src/index';

function read(file) {
  return fs.readFileSync(`./expected/${file}.css`, 'utf8').trim();
}

function runNPM(input, opts, parserOpts = {}) {
  return postcss([
    postcssNPM(opts),
    perfectionist({ indentSize: 2, maxAtRuleLength: false, maxSelectorLength: 1 }),
  ]).process(input, parserOpts);
}

test('Import relative source file', (t) => {
  const input = '@import "./test";';
  return runNPM(input, {}, { from: 'file.css' })
  .then(result => {
    t.deepEqual(result.css.trim(), '.test {\n  content: "Test file";\n}');
  });
});

test('Use the same parsing options on imports', (t) => {
  const input = '@import "./test";';
  return runNPM(input, {}, { from: 'index.css' })
  .then(result => {
    t.deepEqual(result.css.trim(), '.test {\n  content: "Test file";\n}');
  });
});

test('Import package', (t) => {
  const input = '@import "test";';
  return runNPM(input, {}, { from: 'index.css' })
  .then(result => {
    t.deepEqual(result.css.trim(), '.test {\n  content: "Test package";\n}');
  });
});

test('Import package with custom style file', (t) => {
  const input = '@import "custom";';
  return runNPM(input, {}, { from: 'index.css' })
  .then(result => {
{'fraction_non_alphanumeric': 0.20444444444444446, 'fraction_numerical': 0.0022222222222222222, 'mean_word_length': 4.224371373307544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2916918', 'n_tokens_mistral': 909, 'n_tokens_neox': 911, 'n_words': 242}