Skip to content

Commit

Permalink
Add changeNote, editorialNote, historyNote, add tests for notes #281
Browse files Browse the repository at this point in the history
  • Loading branch information
sroertgen committed Mar 27, 2024
1 parent ff13455 commit 828155f
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 19 deletions.
51 changes: 41 additions & 10 deletions src/components/Concept.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,53 @@ const Concept = ({
</Markdown>
</div>
)}
{concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && (
{concept.note && i18n(language)(concept.note) !== "" && (
<div className="markdown">
<h3>ScopeNote</h3>
<ul aria-labelledby="scopeNote">
{i18n(language)(concept.scopeNote).map((scopeNote, i) => (
<li key={i}>{scopeNote}</li>
<h3 id="note">Note</h3>
<ul aria-labelledby="note">
{i18n(language)(concept.note).map((note, i) => (
<li key={i}>{note}</li>
))}
</ul>
</div>
)}
{concept.note && i18n(language)(concept.note) !== "" && (
{concept.changeNote && i18n(language)(concept.changeNote) !== "" && (
<div className="markdown">
<h3>Note</h3>
<ul aria-labelledby="note">
{i18n(language)(concept.note).map((note, i) => (
<li key={i}>{note}</li>
<h3 id="changenote">ChangeNote</h3>
<ul aria-labelledby="changenote">
{i18n(language)(concept.changeNote).map((changeNote, i) => (
<li key={i}>{changeNote}</li>
))}
</ul>
</div>
)}
{concept.editorialNote &&
i18n(language)(concept.editorialNote) !== "" && (
<div className="markdown">
<h3 id="editorialnote">EditorialNote</h3>
<ul aria-labelledby="editorialnote">
{i18n(language)(concept.editorialNote).map((editorialNote, i) => (
<li key={i}>{editorialNote}</li>
))}
</ul>
</div>
)}
{concept.historyNote && i18n(language)(concept.historyNote) !== "" && (
<div className="markdown">
<h3 id="historynote">HistoryNote</h3>
<ul aria-labelledby="historynote">
{i18n(language)(concept.historyNote).map((historyNote, i) => (
<li key={i}>{historyNote}</li>
))}
</ul>
</div>
)}
{concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && (
<div className="markdown">
<h3 id="scopenote">ScopeNote</h3>
<ul aria-labelledby="scopenote">
{i18n(language)(concept.scopeNote).map((scopeNote, i) => (
<li key={i}>{scopeNote}</li>
))}
</ul>
</div>
Expand Down
13 changes: 11 additions & 2 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ const jsonld = {
definition: {
"@container": "@language",
},
scopeNote: {
note: {
"@container": ["@language", "@set"],
},
note: {
changeNote: {
"@container": ["@language", "@set"],
},
editorialNote: {
"@container": ["@language", "@set"],
},
historyNote: {
"@container": ["@language", "@set"],
},
scopeNote: {
"@container": ["@language", "@set"],
},
notation: {
Expand Down
13 changes: 11 additions & 2 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ module.exports.allConcept = (inScheme, languages) => `
definition {
${[...languages].join(" ")}
}
scopeNote {
note {
${[...languages].join(" ")}
}
note {
changeNote {
${[...languages].join(" ")}
}
editorialNote {
${[...languages].join(" ")}
}
historyNote {
${[...languages].join(" ")}
}
scopeNote {
${[...languages].join(" ")}
}
notation
Expand Down
5 changes: 4 additions & 1 deletion src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ module.exports = (languages) => `
altLabel: LanguageMapArray,
hiddenLabel: LanguageMapArray,
definition: LanguageMap,
scopeNote: LanguageMapArray,
note: LanguageMapArray,
changeNote: LanguageMapArray,
editorialNote: LanguageMapArray,
historyNote: LanguageMapArray,
scopeNote: LanguageMapArray,
notation: [String],
example: LanguageMap,
topConceptOf: [ConceptScheme] @link(from: "topConceptOf___NODE"),
Expand Down
65 changes: 65 additions & 0 deletions test/concept.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,71 @@ describe.concurrent("Concept", () => {
).toBeInTheDocument()
})

it("renders notes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Anmerkung/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: "Note",
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders changeNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Change Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /changenote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders editorialNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Editorial Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /editorialnote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders historyNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine History Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /historynote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders scopeNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Scope Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /scopenote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders related Concepts", () => {
render(<Concept pageContext={ConceptPC} />)
expect(
Expand Down
17 changes: 13 additions & 4 deletions test/data/pageContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,20 @@ export const topConcept = {
example: {
de: "Ein Beispiel",
},
scopeNote: {
de: ["Meine Scope Note"],
},
note: {
de: ["Meine Anmerkung"],
de: ["Meine Anmerkung", "Noch eine Anmerkung"],
},
changeNote: {
de: ["Meine Change Note", "Noch eine Change Note"],
},
editorialNote: {
de: ["Meine Editorial Note", "Noch eine Editorial Note"],
},
historyNote: {
de: ["Meine History Note", "Noch eine History Note"],
},
scopeNote: {
de: ["Meine Scope Note", "Noch eine Scope Note"],
},
notation: ["1"],
narrower: [concept2],
Expand Down

0 comments on commit 828155f

Please sign in to comment.