From 2a2bc09d16fb405710130ced9c27265c692c4631 Mon Sep 17 00:00:00 2001 From: Fabio Spampinato Date: Sat, 14 Sep 2024 20:56:26 +0100 Subject: [PATCH] Ported test suite: plugin-extensions --- test/__fixtures__/plugin-extensions/file.foo | 1 + .../__fixtures__/plugin-extensions/plugin.cjs | 24 +++++++++++++++++++ test/__tests__/plugin-extensions.js | 15 ++++++++++++ test/__tests__/plugin-flush-line-suffix.js | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 test/__fixtures__/plugin-extensions/file.foo create mode 100644 test/__fixtures__/plugin-extensions/plugin.cjs create mode 100644 test/__tests__/plugin-extensions.js diff --git a/test/__fixtures__/plugin-extensions/file.foo b/test/__fixtures__/plugin-extensions/file.foo new file mode 100644 index 0000000..12f00e9 --- /dev/null +++ b/test/__fixtures__/plugin-extensions/file.foo @@ -0,0 +1 @@ +contents diff --git a/test/__fixtures__/plugin-extensions/plugin.cjs b/test/__fixtures__/plugin-extensions/plugin.cjs new file mode 100644 index 0000000..be9f6c9 --- /dev/null +++ b/test/__fixtures__/plugin-extensions/plugin.cjs @@ -0,0 +1,24 @@ +"use strict"; + +module.exports = { + languages: [ + { + name: "foo", + parsers: ["foo-parser"], + extensions: [".foo"], + }, + ], + parsers: { + "foo-parser": { + parse: (text) => ({ text }), + astFormat: "foo-ast", + }, + }, + printers: { + "foo-ast": { + print(path) { + return ["!", path.getValue().text]; + }, + }, + }, +}; diff --git a/test/__tests__/plugin-extensions.js b/test/__tests__/plugin-extensions.js new file mode 100644 index 0000000..cbfcbbd --- /dev/null +++ b/test/__tests__/plugin-extensions.js @@ -0,0 +1,15 @@ +import { runCli } from "../utils"; + +describe("uses 'extensions' from languages to determine parser", () => { + runCli("plugin-extensions", [ + "*.foo", + "--plugin=./plugin.cjs", + ], { + ignoreLineEndings: true, + }).test({ + stdout: "!contents", + stderr: "", + status: 0, + write: [], + }); +}); diff --git a/test/__tests__/plugin-flush-line-suffix.js b/test/__tests__/plugin-flush-line-suffix.js index 7e9bc9d..bd25b09 100644 --- a/test/__tests__/plugin-flush-line-suffix.js +++ b/test/__tests__/plugin-flush-line-suffix.js @@ -3,7 +3,7 @@ import { runCli } from "../utils"; describe("flush all line-suffix content", () => { runCli("plugin-flush-line-suffix", [ "*.foo", - "--plugin=./plugin.cjs" + "--plugin=./plugin.cjs", ], { ignoreLineEndings: true, }).test({