@@ -4,7 +4,7 @@ import * as Gatsby from "gatsby"
4
4
5
5
import React from "react"
6
6
import Concept from "../src/components/Concept.jsx"
7
- import { ConceptPC } from "./data/pageContext"
7
+ import { ConceptPC , ConceptPCDeprecated } from "./data/pageContext"
8
8
import mockFetch from "./mocks/mockFetch"
9
9
import { mockConfig } from "./mocks/mockConfig"
10
10
import { useSkoHubContext } from "../src/context/Context.jsx"
@@ -130,7 +130,10 @@ describe.concurrent("Concept", () => {
130
130
expect (
131
131
screen . getByRole ( "heading" , { name : / ^ r e l a t e d $ / i } )
132
132
) . toBeInTheDocument ( )
133
- expect ( screen . getByRole ( "link" , { name : / k o n z e p t 4 / i } ) ) . toBeInTheDocument ( )
133
+ const href = screen . getByRole ( "link" , { name : / k o n z e p t 4 / i } )
134
+ expect ( href ) . toBeInTheDocument ( )
135
+ // ensure there is no language tag in the link
136
+ expect ( href . getAttribute ( "href" ) ) . not . toMatch ( / \. .{ 2 } \. h t m l $ / )
134
137
} )
135
138
136
139
it ( "renders narrow matches" , ( ) => {
@@ -226,4 +229,26 @@ describe.concurrent("Concept", () => {
226
229
screen . getByRole ( "link" , { name : / j u s t - a n o t h e r - s c h e m e / i } )
227
230
) . toHaveAttribute ( "href" , "http://just-another-scheme.org/" )
228
231
} )
232
+
233
+ it ( "renders deprecated notice, if concept is deprecaed" , ( ) => {
234
+ render ( < Concept pageContext = { ConceptPCDeprecated } /> )
235
+ expect (
236
+ screen . getByRole ( "heading" , { name : / D e p r e c a t e d / i } )
237
+ ) . toBeInTheDocument ( )
238
+ } )
239
+
240
+ it ( "adds a isReplacedBy notice if concept is replaced" , ( ) => {
241
+ render ( < Concept pageContext = { ConceptPCDeprecated } /> )
242
+ expect (
243
+ screen . getByRole ( "heading" , { name : / i s R e p l a c e d B y / i } )
244
+ ) . toBeInTheDocument ( )
245
+ const linkElement = screen . getByRole ( "link" , {
246
+ name : "http://w3id.org/replacement" ,
247
+ } ) // Adjust the query to match your link
248
+ const href = linkElement . getAttribute ( "href" )
249
+
250
+ // Assert the URL ends with .html but not .xx.html
251
+ expect ( href ) . toMatch ( / \. h t m l $ / )
252
+ expect ( href ) . not . toMatch ( / \. .{ 2 } \. h t m l $ / )
253
+ } )
229
254
} )
0 commit comments