Skip to content

Commit

Permalink
feat: added tests for obsolete and update metadata parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmutre committed Feb 5, 2025
1 parent 9e18ab9 commit 3b05804
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tests/fixtures/txt-blocks/section-blocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ Updates: 6789, 7890, 8901, 9012 (if approved)
draft-ietf-idr-rt-derived-community-05
`

export const metaWithoutObsoleteAndUpdatesTXTBlock = `
idr Z. Zhang
Internet-Draft J. Haas
Intended status: Standards Track Juniper Networks
Expires: 8 September 2023 K. Patel
Arrcus
21 January 2025
Extended Communities Derived from Route Targets
draft-ietf-idr-rt-derived-community-05
`

export const authorAddressTXTBlock = `
Authors' Addresses
Expand Down
33 changes: 32 additions & 1 deletion tests/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
textWithIPsTXTBlock,
textWithRFC2119KeywordsTXTBlock,
RFC2119BoilerplateTXTBlock,
RFC8174BoilerplateTXTBlock
RFC8174BoilerplateTXTBlock,
metaWithoutObsoleteAndUpdatesTXTBlock
} from './fixtures/txt-blocks/section-blocks.mjs'
import { parse } from '../lib/parsers/txt.mjs'

Expand Down Expand Up @@ -444,3 +445,33 @@ describe('Parsing similar to RFC2119 boilerplate text', () => {
expect(result.data.boilerplate.similar2119boilerplate).toEqual(true)
})
})

describe('Parcsing obsolete and update metadata', () => {
test('Parsing obsolete metadata', async () => {
const txt = `
${metaTXTBlock}
${tableOfContentsTXTBlock}
${abstractWithReferencesTXTBlock}
${introductionTXTBlock}
${securityConsiderationsTXTBlock}
`

const result = await parse(txt, 'txt')
expect(result.data.extractedElements.obsoletesRfc).toEqual(['5678', '1234', '2345', '3456'])
expect(result.data.extractedElements.updatesRfc).toEqual(['6789', '7890', '8901', '9012'])
})

test('Parsing tetxt without obsolete and update metadata', async () => {
const txt = `
${metaWithoutObsoleteAndUpdatesTXTBlock}
${tableOfContentsTXTBlock}
${abstractWithReferencesTXTBlock}
${introductionTXTBlock}
${securityConsiderationsTXTBlock}
`

const result = await parse(txt, 'txt')
expect(result.data.extractedElements.obsoletesRfc).toHaveLength(0)
expect(result.data.extractedElements.updatesRfc).toHaveLength(0)
})
})

0 comments on commit 3b05804

Please sign in to comment.