const path = require('path'); const { expect } = require('chai'); const { createNavigationNode } = require('./create-navigation-node'); describe('fcc-create-nav-data', () => { describe('create-vanigation-node', () => { const mockNode = { internal: { content: '---\ntitle: File Writing\n---\n## File Writing\n\nThis is a stub.' + " Help our community expand it.\n\nThis quick style guide will help " + 'ensure your pull request gets accepted.\n\n\n\n#### More ' + 'Information:\n\n' }, frontmatter: { title: 'File Writing' }, fileAbsolutePath: path.resolve( __dirname, '../../../guide/english/php/functions/files/file-writing/index.md' ) }; const result = createNavigationNode(mockNode); it('should return an object', () => { expect(result).to.be.an('object'); }); it('node.children should be an array', () => { expect(result.categoryChildren).to.be.an('array'); }); it('node.dashedName should equal the containing folder name', () => { expect(result.dashedName).equal('file-writing'); }); it('node.path should equal the file path from pagesDir, prefixed with `/guide`', () => { expect(result.path).to.equal('/guide/php/functions/files/file-writing'); }); it('node.parentPath should equal the path of the parent page, prefixed with `/guide`', () => { expect(result.parentPath).to.equal('/guide/php/functions/files'); }); it('node.title should equal srcNode.frontmatter.title', () => { expect(result.title).to.equal(mockNode.frontmatter.title); }); it('node.isStubbed should be a boolean', () => { expect(result.isStubbed).to.be.a('boolean'); }); it('node.isStubbed should be true for a stubbed article', () => { expect(result.isStubbed).to.equal(true); }); it('node.isStubbed should be false for a non-stubbed article', () => { const notAStub = { ...mockNode, internal: { content: 'this is not a stub article. Infact, it is very informative' } }; const result = createNavigationNode(notAStub); expect(result.isStubbed).to.equal(false); }); }); });