Skip to content

Commit

Permalink
fix(informative test): #205 changed test. It is now clearer which ent…
Browse files Browse the repository at this point in the history
…ries are mocked

fix(informative test): #205 changed test. It should be clearer which entries are mocked
  • Loading branch information
rainer-exxcellent committed Feb 26, 2025
1 parent 1ea27f6 commit 18098b4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 14 deletions.
26 changes: 24 additions & 2 deletions tests/informativeTest_6_3_8.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ import { expect } from 'chai'
import informativeTest_6_3_8 from '../lib/informativeTests/informativeTest_6_3_8.js'
import readExampleFiles from './shared/readExampleFiles.js'

const validString = "Informative test: Spell check (failing example 2, Check branches)"
const validString = "Mocked as Valid"

const failingExamples = await readExampleFiles(
new URL('informativeTest_6_3_8/failing', import.meta.url)
)

const validExamples = await readExampleFiles(
new URL('informativeTest_6_3_8/valid', import.meta.url)
)

describe('Informative test 6.3.8', function () {
describe('failing examples', function () {
for (const [title, failingExample] of failingExamples) {
it(title, async function () {
const result = await informativeTest_6_3_8(failingExample, {
async hunspell({ dictionary, input }) {
if (validString === input) {
if (input.includes(validString)) {
return 'Hunspell vMOCK\n\n*'
} else {
return 'Hunspell vMOCK\n\n# wrongword 1'
Expand All @@ -26,4 +30,22 @@ describe('Informative test 6.3.8', function () {
})
}
})

describe('valid examples', function () {
for (const [title, validExample] of validExamples) {
it(title, async function () {
const result = await informativeTest_6_3_8(validExample, {
async hunspell({ dictionary, input }) {
if (input.includes(validString)) {
return 'Hunspell vMOCK\n\n*'
} else {
return 'Hunspell vMOCK\n\n# wrongword 1'
}
},
})

expect(result.infos.length).to.equal(0)
})
}
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"notes": [
{
"category": "summary",
"text": "Secruity researchers found multiple vulnerabilities in XYZ."
"text": "Mocked as Valid"
}
],
"publisher": {
"category": "other",
"name": "OASIS CSAF TC",
"namespace": "https://csaf.io"
"namespace": "https://example.com"
},
"title": "Informative test: Spell check (failing example 1)",
"title": "Informative test: Spell check (failing example 1)[Mocked as Valid]",
"tracking": {
"current_release_date": "2021-07-21T10:00:00.000Z",
"id": "OASIS_CSAF_TC-CSAF_2.0-2021-6-3-08-01",
Expand All @@ -23,7 +23,7 @@
{
"date": "2021-07-21T10:00:00.000Z",
"number": "1",
"summary": "Initial version."
"summary": "Mocked as Invalid"
}
],
"status": "final",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"document": {
"category": "csaf_base",
"category": "Mocked as Valid",
"csaf_version": "2.0",
"lang": "en",
"publisher": {
"category": "other",
"namespace": "https://csaf.io"
"namespace": "https://example.com",
"name": "Mocked as Valid"
},
"title": "Informative test: Spell check (failing example 2, Check branches)",
"title": "Mocked as Valid",
"tracking": {
"current_release_date": "2021-07-21T10:00:00.000Z",
"id": "OASIS_CSAF_TC-CSAF_2.0-2021-6-3-08-01",
"initial_release_date": "2021-07-21T10:00:00.000Z",
"revision_history": [
{
"date": "2021-07-21T10:00:00.000Z",
"number": "1"
"number": "1",
"summary": "Mocked as Valid"
}
],
"status": "final",
Expand All @@ -30,18 +32,22 @@
"branches": [
{
"category": "product_name",
"name": "Red Hat Enterprise Linux Client (v. 7)",
"name": "Mocked as Invalid",
"product": {
"name": "Red Hat Enterprise Linux Client (v. 7)",
"name": "Mocked as Valid",
"product_id": "7Client-7.6",
"product_identification_helper": {
"cpe": "cpe:/o:redhat:enterprise_linux:7::client"
}
}
}
]
],
"category": "product_family",
"name": "Mocked as Valid"
}
]
],
"category": "vendor",
"name": "Mocked as Valid"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"document": {
"category": "csaf_base",
"csaf_version": "2.0",
"lang": "en",
"notes": [
{
"category": "summary",
"text": "Mocked as Valid"
}
],
"publisher": {
"category": "other",
"name": "OASIS CSAF TC [Mocked as Valid]",
"namespace": "https://example.com"
},
"title": "Informative test: Spell check (failing example 1)[Mocked as Valid]",
"tracking": {
"current_release_date": "2021-07-21T10:00:00.000Z",
"id": "OASIS_CSAF_TC-CSAF_2.0-2021-6-3-08-01",
"initial_release_date": "2021-07-21T10:00:00.000Z",
"revision_history": [
{
"date": "2021-07-21T10:00:00.000Z",
"number": "1",
"summary": "Mocked as Valid"
}
],
"status": "final",
"version": "1"
}
}
}

0 comments on commit 18098b4

Please sign in to comment.