1- import 'jest-enzyme ' ;
1+ import '@testing-library/ jest-dom ' ;
22
33import { RootNode } from '@stoplight/json-schema-tree' ;
4- import { Icon } from '@stoplight/mosaic' ;
5- import { mount } from 'enzyme' ;
4+ import { render } from '@testing-library/react' ;
65import { JSONSchema4 } from 'json-schema' ;
76import * as React from 'react' ;
7+ import { describe , expect , it } from 'vitest' ;
88
99import { TopLevelSchemaRow } from '../SchemaRow/TopLevelSchemaRow' ;
1010import { buildTree } from '../shared/__tests__/utils' ;
@@ -40,11 +40,10 @@ describe('resolving permission error', () => {
4040 } ;
4141
4242 tree = buildTree ( schema ) ;
43- const wrapper = mount ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
44- expect ( wrapper . find ( Icon ) . at ( 0 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
45- expect ( wrapper . find ( Icon ) . at ( 1 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
46- expect ( wrapper . find ( Icon ) . at ( 2 ) ) . not . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
47- expect ( wrapper . find ( Icon ) . at ( 3 ) ) . not . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
43+ const wrapper = render ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
44+ const icons = wrapper . queryAllByLabelText ( 'You do not have permission to view this reference' ) ;
45+ expect ( icons ) . toHaveLength ( 2 ) ;
46+
4847 wrapper . unmount ( ) ;
4948 } ) ;
5049
@@ -73,10 +72,9 @@ describe('resolving permission error', () => {
7372 } ;
7473
7574 tree = buildTree ( schema ) ;
76- const wrapper = mount ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
77- expect ( wrapper . find ( Icon ) . at ( 0 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
78- expect ( wrapper . find ( Icon ) . at ( 1 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
79- expect ( wrapper . find ( Icon ) . at ( 2 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
75+ const wrapper = render ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
76+ const icons = wrapper . queryAllByLabelText ( 'You do not have permission to view this reference' ) ;
77+ expect ( icons ) . toHaveLength ( 3 ) ;
8078 wrapper . unmount ( ) ;
8179 } ) ;
8280
@@ -87,8 +85,10 @@ describe('resolving permission error', () => {
8785 'x-sl-internally-excluded' : true ,
8886 } ;
8987 tree = buildTree ( schema ) ;
90- const wrapper = mount ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
91- expect ( wrapper . find ( Icon ) . at ( 0 ) ) . toHaveProp ( 'aria-label' , `You do not have permission to view this reference` ) ;
88+ const wrapper = render ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
89+ const icons = wrapper . queryAllByLabelText ( 'You do not have permission to view this reference' ) ;
90+ expect ( icons ) . toHaveLength ( 1 ) ;
91+ expect ( icons [ 0 ] ) . toBeInTheDocument ( ) ;
9292 wrapper . unmount ( ) ;
9393 } ) ;
9494
@@ -126,10 +126,9 @@ describe('resolving permission error', () => {
126126 } ;
127127
128128 tree = buildTree ( schema ) ;
129- const wrapper = mount ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
130- expect ( wrapper . find ( Icon ) . at ( 1 ) ) . not . toHaveProp ( 'title' , `You do not have permission to view this reference` ) ;
131- expect ( wrapper . find ( Icon ) . at ( 2 ) ) . not . toHaveProp ( 'title' , `You do not have permission to view this reference` ) ;
132- expect ( wrapper . find ( Icon ) . at ( 3 ) ) . not . toHaveProp ( 'title' , `You do not have permission to view this reference` ) ;
129+ const wrapper = render ( < TopLevelSchemaRow schemaNode = { tree . children [ 0 ] ! } /> ) ;
130+ const icons = wrapper . queryAllByLabelText ( 'You do not have permission to view this reference' ) ;
131+ expect ( icons ) . toHaveLength ( 0 ) ;
133132 wrapper . unmount ( ) ;
134133 } ) ;
135134} ) ;
0 commit comments