Skip to content

Commit

Permalink
Refactor lib/utils/__tests__/* test files to migrate to ESM (#7022)
Browse files Browse the repository at this point in the history
- `.js` -> `.mjs`
- `require` -> `import`
  • Loading branch information
ybiquitous committed Jul 1, 2023
1 parent 2ffa442 commit 1d145f9
Show file tree
Hide file tree
Showing 66 changed files with 118 additions and 238 deletions.
@@ -1,9 +1,8 @@
'use strict';
import checkAgainstRule from '../checkAgainstRule.js';
import report from '../report.js';
import validateOptions from '../validateOptions.js';

const report = require('../report');
const validateOptions = require('../validateOptions');
const checkAgainstRule = require('../checkAgainstRule');
const postcss = require('postcss');
import postcss from 'postcss';

const mockRuleName = 'custom/no-empty-source';
const mockResult = {
Expand Down
@@ -1,6 +1,6 @@
'use strict';
import functionArgumentsSearch from '../functionArgumentsSearch.js';

const functionArgumentsSearch = require('../functionArgumentsSearch');
import { jest } from '@jest/globals';

it('passes function arguments to callback', () => {
expect.assertions(4);
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const getDimension = require('../getDimension');
const valueParser = require('postcss-value-parser');
import getDimension from '../getDimension.js';
import valueParser from 'postcss-value-parser';

it('getDimension', () => {
expect(getDimension().number).toBeNull();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const getFormatterOptionsText = require('../getFormatterOptionsText');
import getFormatterOptionsText from '../getFormatterOptionsText.js';

it('getFormatterOptionsText', () => {
expect(getFormatterOptionsText(', ')).toBe('compact, github, json, string, tap, unix, verbose');
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const getImportantPosition = require('../getImportantPosition');
import getImportantPosition from '../getImportantPosition.js';

describe('getImportantPosition', () => {
it('returns a position of "!important"', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const getNextNonSharedLineCommentNode = require('../getNextNonSharedLineCommentNode');
const postcss = require('postcss');
import getNextNonSharedLineCommentNode from '../getNextNonSharedLineCommentNode.js';
import postcss from 'postcss';

describe('getNextNonSharedLineCommentNode', () => {
it('returns undefined if there is no next node', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const getPreviousNonSharedLineCommentNode = require('../getPreviousNonSharedLineCommentNode');
const postcss = require('postcss');
import getPreviousNonSharedLineCommentNode from '../getPreviousNonSharedLineCommentNode.js';
import postcss from 'postcss';

describe('getPreviousNonSharedLineCommentNode', () => {
it('returns undefined if there is no node before', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const getSchemeFromUrl = require('../getSchemeFromUrl');
import getSchemeFromUrl from '../getSchemeFromUrl.js';

it('getSchemeFromUrl', () => {
expect(getSchemeFromUrl('')).toBeNull();
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const hasBlock = require('../hasBlock');
const postcss = require('postcss');
import hasBlock from '../hasBlock.js';
import postcss from 'postcss';

it('hasBlock', () => {
expect(postcssCheck('a {}')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const hasEmptyLine = require('../hasEmptyLine');
import hasEmptyLine from '../hasEmptyLine.js';

it('hasEmptyLine', () => {
expect(hasEmptyLine('\n\n')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const hasInterpolation = require('../hasInterpolation');
import hasInterpolation from '../hasInterpolation.js';

it('hasInterpolation', () => {
expect(hasInterpolation('(min-width#{$value}: 10px)')).toBeTruthy();
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isAfterComment = require('../isAfterComment');
const postcss = require('postcss');
import isAfterComment from '../isAfterComment.js';
import postcss from 'postcss';

describe('isAfterComment', () => {
it('returns true when after a single-line comment', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isAfterSingleLineComment = require('../isAfterSingleLineComment');
const postcss = require('postcss');
import isAfterSingleLineComment from '../isAfterSingleLineComment.js';
import postcss from 'postcss';

describe('isAfterSingleLineComment', () => {
it('returns true when after a single-line comment', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isAutoprefixable = require('../isAutoprefixable');
import isAutoprefixable from '../isAutoprefixable.js';

describe('isAutoprefixable.atRuleName()', () => {
it('returns true', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isBlocklessAtRuleAfterBlocklessAtRule = require('../isBlocklessAtRuleAfterBlocklessAtRule');
const postcss = require('postcss');
import isBlocklessAtRuleAfterBlocklessAtRule from '../isBlocklessAtRuleAfterBlocklessAtRule.js';
import postcss from 'postcss';

describe('isBlocklessAtRuleAfterBlocklessAtRule', () => {
it('returns false with the first node', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isBlocklessAtRuleAfterSameNameBlocklessAtRule = require('../isBlocklessAtRuleAfterSameNameBlocklessAtRule');
const postcss = require('postcss');
import isBlocklessAtRuleAfterSameNameBlocklessAtRule from '../isBlocklessAtRuleAfterSameNameBlocklessAtRule.js';
import postcss from 'postcss';

describe('isBlocklessAtRuleAfterSameNameBlocklessAtRule', () => {
it('returns false with the first node', () => {
Expand Down
@@ -1,8 +1,6 @@
'use strict';

const isContextFunctionalPseudoClass = require('../isContextFunctionalPseudoClass');
const parseSelector = require('postcss-selector-parser');
const postcss = require('postcss');
import isContextFunctionalPseudoClass from '../isContextFunctionalPseudoClass.js';
import parseSelector from 'postcss-selector-parser';
import postcss from 'postcss';

function pseudo(css) {
const pseudos = [];
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCounterIncrementCustomIdentValue = require('../isCounterIncrementCustomIdentValue');
import isCounterIncrementCustomIdentValue from '../isCounterIncrementCustomIdentValue.js';

it('isCustomIdents', () => {
expect(isCounterIncrementCustomIdentValue('counter')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCounterResetCustomIdentValue = require('../isCounterResetCustomIdentValue');
import isCounterResetCustomIdentValue from '../isCounterResetCustomIdentValue.js';

it('isCustomIdents', () => {
expect(isCounterResetCustomIdentValue('counter')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCustomElement = require('../isCustomElement');
import isCustomElement from '../isCustomElement.js';

describe('isCustomElement', () => {
it('custom element', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCustomFunction = require('../isCustomFunction');
import isCustomFunction from '../isCustomFunction.js';

it('isCustomFunction', () => {
expect(isCustomFunction('--custom-function')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCustomMediaQuery = require('../isCustomMediaQuery');
import isCustomMediaQuery from '../isCustomMediaQuery.js';

it('isCustomMediaQuery', () => {
expect(isCustomMediaQuery('--custom-media-query')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCustomProperty = require('../isCustomProperty');
import isCustomProperty from '../isCustomProperty.js';

it('isCustomProperty', () => {
expect(isCustomProperty('--custom-property')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isCustomSelector = require('../isCustomSelector');
import isCustomSelector from '../isCustomSelector.js';

it('isCustomSelector', () => {
expect(isCustomSelector(':--custom-selector')).toBeTruthy();
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isFirstNested = require('../isFirstNested');
const postcss = require('postcss');
import isFirstNested from '../isFirstNested.js';
import postcss from 'postcss';

describe('isFirstNested', () => {
it('returns false with the first node', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isKeyframeRule = require('../isKeyframeRule');
const postcss = require('postcss');
import isKeyframeRule from '../isKeyframeRule.js';
import postcss from 'postcss';

describe('isKeyframeRule', () => {
it('detects a standard keyframe rule', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isKeyframeSelector = require('../isKeyframeSelector');
import isKeyframeSelector from '../isKeyframeSelector.js';

it('isKeyframeSelector', () => {
expect(isKeyframeSelector('to')).toBeTruthy();
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isMathFunction = require('../isMathFunction');
const valueParser = require('postcss-value-parser');
import isMathFunction from '../isMathFunction.js';
import valueParser from 'postcss-value-parser';

describe('isMathFunction', () => {
it('matches calc', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isNonNegativeInteger = require('../isNonNegativeInteger');
import isNonNegativeInteger from '../isNonNegativeInteger.js';

describe('isNonNegativeInteger', () => {
it('returns true', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isNumbery = require('../isNumbery');
import isNumbery from '../isNumbery.js';

test('isNumbery', () => {
expect(isNumbery('1')).toBe(true);
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isOnlyWhitespace = require('../isOnlyWhitespace');
import isOnlyWhitespace from '../isOnlyWhitespace.js';

it('isOnlyWhitespace', () => {
expect(isOnlyWhitespace('\r\n \t \n ')).toBeTruthy();
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isScssVariable = require('../isScssVariable');
import isScssVariable from '../isScssVariable.js';

describe('isScssVariable', () => {
it('sass variable', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isSharedLineComment = require('../isSharedLineComment');
const postcss = require('postcss');
import isSharedLineComment from '../isSharedLineComment.js';
import postcss from 'postcss';

describe('isSharedLineComment', () => {
it('returns false for the first node', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isSingleLineString = require('../isSingleLineString');
import isSingleLineString from '../isSingleLineString.js';

const multiLineTemplate = `foo
bar`;
Expand Down
@@ -1,10 +1,8 @@
'use strict';

const isStandardSyntaxAtRule = require('../isStandardSyntaxAtRule');
const postcss = require('postcss');
const postcssLess = require('postcss-less');
const postcssSass = require('postcss-sass');
const postcssScss = require('postcss-scss');
import isStandardSyntaxAtRule from '../isStandardSyntaxAtRule.js';
import postcss from 'postcss';
import postcssLess from 'postcss-less';
import postcssSass from 'postcss-sass';
import postcssScss from 'postcss-scss';

describe('isStandardSyntaxAtRule', () => {
it('non nested at-rules without quotes', () => {
Expand Down
@@ -1,8 +1,6 @@
'use strict';

const isStandardSyntaxColorFunction = require('../isStandardSyntaxColorFunction');
const postcss = require('postcss');
const valueParser = require('postcss-value-parser');
import isStandardSyntaxColorFunction from '../isStandardSyntaxColorFunction.js';
import postcss from 'postcss';
import valueParser from 'postcss-value-parser';

describe('isStandardSyntaxColorFunction', () => {
it('legacy syntax', () => {
Expand Down
@@ -1,8 +1,6 @@
'use strict';

const isStandardSyntaxCombinator = require('../isStandardSyntaxCombinator');
const postcss = require('postcss');
const selectorParser = require('postcss-selector-parser');
import isStandardSyntaxCombinator from '../isStandardSyntaxCombinator.js';
import postcss from 'postcss';
import selectorParser from 'postcss-selector-parser';

describe('isStandardSyntaxCombinator', () => {
it('tag', () => {
Expand Down
@@ -1,11 +1,9 @@
'use strict';
import isStandardSyntaxComment from '../isStandardSyntaxComment.js';

const isStandardSyntaxComment = require('../isStandardSyntaxComment');

const postcss = require('postcss');
const postcssLess = require('postcss-less');
const postcssSass = require('postcss-sass');
const postcssScss = require('postcss-scss');
import postcss from 'postcss';
import postcssLess from 'postcss-less';
import postcssSass from 'postcss-sass';
import postcssScss from 'postcss-scss';

describe('isStandardSyntaxComment', () => {
test('standard single-line comment', () => {
Expand Down
@@ -1,10 +1,8 @@
'use strict';

const isStandardSyntaxDeclaration = require('../isStandardSyntaxDeclaration');
const postcss = require('postcss');
const postcssLess = require('postcss-less');
const postcssSass = require('postcss-sass');
const postcssScss = require('postcss-scss');
import isStandardSyntaxDeclaration from '../isStandardSyntaxDeclaration.js';
import postcss from 'postcss';
import postcssLess from 'postcss-less';
import postcssSass from 'postcss-sass';
import postcssScss from 'postcss-scss';

describe('isStandardSyntaxDeclaration', () => {
it('standard prop and value', () => {
Expand Down
@@ -1,7 +1,5 @@
'use strict';

const isStandardSyntaxFunction = require('../isStandardSyntaxFunction');
const valueParser = require('postcss-value-parser');
import isStandardSyntaxFunction from '../isStandardSyntaxFunction.js';
import valueParser from 'postcss-value-parser';

describe('isStandardSyntaxFunction', () => {
it('calc', () => {
Expand Down
@@ -1,6 +1,4 @@
'use strict';

const isStandardSyntaxHexColor = require('../isStandardSyntaxHexColor');
import isStandardSyntaxHexColor from '../isStandardSyntaxHexColor.js';

describe('isStandardSyntaxHexColor', () => {
it('default hex', () => {
Expand Down

0 comments on commit 1d145f9

Please sign in to comment.