Skip to content

Commit

Permalink
Sort diagnostics in the test case to avoid false negatives in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilsapa committed Jul 15, 2024
1 parent 4f66a1e commit 2540ff6
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'

import noSegmentsOnSlicedLayers from './index.js'
import { joinFromRoot, parseIntoFsdRoot } from '../_lib/prepare-test.js'
import { joinFromRoot, parseIntoFsdRoot, compareMessages } from '../_lib/prepare-test.js'

describe('no-segments-on-sliced-layers rule', () => {
it('reports no errors on a project where the sliced layers has no segments in direct children', () => {
Expand Down Expand Up @@ -71,29 +71,29 @@ describe('no-segments-on-sliced-layers rule', () => {
📄 index.ts
`)

const diagnostics = noSegmentsOnSlicedLayers.check(root).diagnostics
const diagnostics = noSegmentsOnSlicedLayers.check(root).diagnostics.toSorted(compareMessages)

expect(diagnostics).toEqual([
{
message:
'Conventional segment "ui" found as a direct child of a sliced layer. Consider moving it inside a slice or to another layer.',
location: { path: joinFromRoot('entities', 'ui') },
},
{
message:
'Conventional segment "api" found as a direct child of a sliced layer. Consider moving it inside a slice or to another layer.',
'Conventional segment "api" should not be a direct child of a sliced layer. Consider moving it inside a slice or, if that is a slice, consider a different name for it to avoid confusion with segments.',
location: { path: joinFromRoot('features', 'api') },
},
{
message:
'Conventional segment "config" found as a direct child of a sliced layer. Consider moving it inside a slice or to another layer.',
'Conventional segment "config" should not be a direct child of a sliced layer. Consider moving it inside a slice or, if that is a slice, consider a different name for it to avoid confusion with segments.',
location: { path: joinFromRoot('widgets', 'config') },
},
{
message:
'Conventional segment "lib" found as a direct child of a sliced layer. Consider moving it inside a slice or to another layer.',
'Conventional segment "lib" should not be a direct child of a sliced layer. Consider moving it inside a slice or, if that is a slice, consider a different name for it to avoid confusion with segments.',
location: { path: joinFromRoot('pages', 'lib') },
},
{
message:
'Conventional segment "ui" should not be a direct child of a sliced layer. Consider moving it inside a slice or, if that is a slice, consider a different name for it to avoid confusion with segments.',
location: { path: joinFromRoot('entities', 'ui') },
},
])
})
})

0 comments on commit 2540ff6

Please sign in to comment.