Skip to content

Commit

Permalink
test: simplify config assertions (#197)
Browse files Browse the repository at this point in the history
A quick change to dumb the config tests down so they basically assert
against the exported structure rather than an integration-like test.

May still be worth an integration test in future.

Previously, the 2nd test case was actually passing due to an unrelated
error (parse error, too low of an ecma version), which was satisfying
the later assertion.
  • Loading branch information
43081j committed Apr 8, 2024
1 parent 31b701d commit 4f0a8bd
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions src/test/configs_test.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
import {Linter} from 'eslint';
import type {ESLint, Linter} from 'eslint';
import {expect} from 'chai';
import {configs} from '../index';

describe('configs', () => {
it('should load flat configs correctly', () => {
const linter = new Linter({
configType: 'flat'
});

const result = linter.verify(
'html`<x-foo bar bar>`',
[
{
files: ['*.js'],
...configs['flat/recommended']
}
],
'foo.js'
);
type ConfigLike = Linter.FlatConfig | ESLint.ConfigData;

expect(result.length).to.equal(1);
});
const isFlatConfig = (config: ConfigLike): config is Linter.FlatConfig =>
!Array.isArray(config.plugins);

it('should load legacy configs correctly', () => {
const linter = new Linter();

const result = linter.verify(
'html`<x-foo bar bar>`',
{
extends: ['plugin:lit/recommended']
},
'foo.js'
);
describe('configs', () => {
it('should define configs correctly', () => {
expect(configs['recommended']).to.be.ok;
expect(configs['all']).to.be.ok;
expect(configs['flat/recommended']).to.be.ok;
expect(configs['flat/all']).to.be.ok;

expect(result.length).to.equal(1);
expect(isFlatConfig(configs['flat/recommended'])).to.equal(true);
expect(isFlatConfig(configs['flat/all'])).to.equal(true);
expect(isFlatConfig(configs['recommended'])).to.equal(false);
expect(isFlatConfig(configs['all'])).to.equal(false);
});
});

0 comments on commit 4f0a8bd

Please sign in to comment.