Skip to content

Commit

Permalink
Migrate jest to node:test/node:assert (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Feb 25, 2024
1 parent 32a40e8 commit 0b553f9
Show file tree
Hide file tree
Showing 5 changed files with 951 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["stylelint", "stylelint/jest"],
"extends": ["stylelint"],
"globals": {
"module": true,
"require": true
Expand Down
70 changes: 0 additions & 70 deletions __tests__/index.js

This file was deleted.

68 changes: 68 additions & 0 deletions __tests__/index.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { beforeEach, describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';

import stylelint from 'stylelint';

import config from '../index.js';

const validScss = readFileSync('./__tests__/valid.scss', 'utf-8');
const invalidScss = readFileSync('./__tests__/invalid.scss', 'utf-8');

describe('flags no warnings with valid scss', () => {
let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('flags no warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});

describe('flags warnings with invalid scss', () => {
let result;

beforeEach(async () => {
result = await stylelint.lint({
code: invalidScss,
config,
});
});

it('did error', () => {
assert.equal(result.errored, true);
});

it('flags one warning', () => {
assert.equal(result.results[0].warnings.length, 1);
});

it('correct warning text', () => {
assert.equal(result.results[0].warnings[0].text, 'Expected variable to be kebab-case');
});

it('correct rule flagged', () => {
assert.equal(result.results[0].warnings[0].rule, 'scss/dollar-variable-pattern');
});

it('correct severity flagged', () => {
assert.equal(result.results[0].warnings[0].severity, 'error');
});

it('correct line number', () => {
assert.equal(result.results[0].warnings[0].line, 1);
});

it('correct column number', () => {
assert.equal(result.results[0].warnings[0].column, 1);
});
});

0 comments on commit 0b553f9

Please sign in to comment.