Files
freeCodeCamp/tools/challenge-parser/parser/plugins/utils/get-paragraph-content.test.js
2024-10-04 09:42:41 -05:00

23 lines
740 B
JavaScript

const parseFixture = require('../../__fixtures__/parse-fixture');
const { getParagraphContent } = require('./get-paragraph-content');
describe('getParagraphContent', () => {
let simpleAST;
beforeAll(async () => {
simpleAST = await parseFixture('simple.md');
});
it('should return the content of a paragraph node', () => {
const paragraphNode = simpleAST.children[1];
expect(paragraphNode.type).toBe('paragraph');
expect(getParagraphContent(paragraphNode)).toEqual('Paragraph 1');
});
it('should return null if the node is not a paragraph', () => {
const headingNode = simpleAST.children[0];
expect(headingNode.type).toBe('heading');
expect(getParagraphContent(headingNode)).toBeNull();
});
});