From b7b2899e55e1804c3a58b258b8e1bb45d50bd9f1 Mon Sep 17 00:00:00 2001 From: Viktor Bahr Date: Thu, 14 Apr 2022 17:44:08 +0200 Subject: [PATCH] test(techdocs-node): sequence node custom tag validation failure This test proves that currently only scalar YAML nodes are considered valid by the mkdocs YAML validation logic, even though using the `!ENV` tag with sequential data is officially supported by mkdocs[0]. [0] https://www.mkdocs.org/user-guide/configuration/#environment-variables Signed-off-by: Viktor Bahr --- .../generate/__fixtures__/mkdocs_with_env_tag.yml | 1 + .../techdocs-node/src/stages/generate/helpers.test.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml diff --git a/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml new file mode 100644 index 0000000000..8da1ef0cca --- /dev/null +++ b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml @@ -0,0 +1 @@ +site_name: !ENV [SITE_NAME, OTHER_NAME, 'My default site name'] \ No newline at end of file diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 7590df94fb..f45f6034ec 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -78,6 +78,9 @@ const mkdocsYmlWithoutPlugins = fs.readFileSync( const mkdocsYmlWithAdditionalPlugins = fs.readFileSync( resolvePath(__filename, '../__fixtures__/mkdocs_with_additional_plugins.yml'), ); +const mkdocsYmlWithEnvTag = fs.readFileSync( + resolvePath(__filename, '../__fixtures__/mkdocs_with_env_tag.yml'), +); const mockLogger = getVoidLogger(); const warn = jest.spyOn(mockLogger, 'warn'); @@ -582,10 +585,16 @@ describe('helpers', () => { ).rejects.toThrow(); }); - it('should validate files with custom yaml tags', async () => { + it('should validate files with custom yaml tags (scalar)', async () => { await expect( validateMkdocsYaml(inputDir, mkdocsYmlWithExtensions.toString()), ).resolves.toBeUndefined(); }); + + it('should validate files with custom yaml tags (sequence)', async () => { + await expect( + validateMkdocsYaml(inputDir, mkdocsYmlWithEnvTag.toString()), + ).resolves.toBeUndefined(); + }); }); });