Skip to content

Commit

Permalink
Add test for multiple plugins
Browse files Browse the repository at this point in the history
Uses some actual other plugins, which could be brittle, but on the other hand,
should give us greater confidence that it's working
  • Loading branch information
IanVS committed Jun 25, 2024
1 parent 9e413dc commit 6d7e4af
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"@vue/compiler-sfc": "3.4.21",
"cross-env": "^7.0.3",
"prettier": "^3.0.3",
"prettier-plugin-jsdoc": "^1.3.0",
"prettier-plugin-tailwindcss": "^0.6.5",
"typescript": "5.2.2",
"vitest": "^0.34.5"
},
Expand Down
2 changes: 1 addition & 1 deletion test-setup/run_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as plugin from '../src';
export async function run_spec(dirname, parsers, options) {
options = Object.assign(
{
plugins: [plugin],
plugins: options.plugins ?? [plugin],
tabWidth: 4,
},
options,
Expand Down
81 changes: 81 additions & 0 deletions tests/MultiplePlugins/__snapshots__/ppsi.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`imports-with-jsdoc.tsx - typescript-verify > imports-with-jsdoc.tsx 1`] = `
import z from 'z';
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";
import thirdParty from "third-party";
import oneLevelRelativePath from "../oneLevelRelativePath";
import otherthing from "@core/otherthing";
import abc from "@core/abc";
import twoLevelRelativePath from "../../twoLevelRelativePath";
/**
* function example description that was wrapped by hand
* so it have more then one line and don't end with a dot
* REPEATED TWO TIMES BECAUSE IT WAS EASIER to copy
* function example description that was wrapped by hand
* so it have more then one line.
* @return {Boolean} Description for @returns with s
* @param {String|Number} text - some text description that is very long and needs to be wrapped
* @param {String} [defaultValue="defaultTest"] TODO
* @arg {Number|Null} [optionalNumber]
* @private
*@memberof test
@async
* @examples
* var one = 5
* var two = 10
*
* if(one > 2) { two += one }
* @undefiendTag\${" "}
* @undefiendTag {number} name des
*/
const TestFunction = (text: string | number, defaultValue: string, optionalNumber: number | Null): boolean => (
<div className="text-white px-4 sm:px-8 py-2 sm:py-3 bg-sky-700 hover:bg-sky-800"></div>
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import thirdParty from "third-party";
import z from "z";
import abc from "@core/abc";
import otherthing from "@core/otherthing";
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import twoLevelRelativePath from "../../twoLevelRelativePath";
import oneLevelRelativePath from "../oneLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";
/**
* Function example description that was wrapped by hand so it have more then
* one line and don't end with a dot REPEATED TWO TIMES BECAUSE IT WAS EASIER to
* copy function example description that was wrapped by hand so it have more
* then one line.
*
* @async
* @private
* @memberof test
* @example
* var one = 5;
* var two = 10;
*
* if (one > 2) {
* two += one;
* }
*
* @param {String | Number} text - Some text description that is very long and
* needs to be wrapped
* @param {String} [defaultValue="defaultTest"] TODO. Default is \`"defaultTest"\`
* @param {Number | Null} [optionalNumber]
* @returns {Boolean} Description for @returns with s
* @undefiendTag\${" "}
* @undefiendTag {number} name des
*/
const TestFunction = (
text: string | number,
defaultValue: string,
optionalNumber: number | Null,
): boolean => (
<div className="bg-sky-700 px-4 py-2 text-white hover:bg-sky-800 sm:px-8 sm:py-3"></div>
);
`;
34 changes: 34 additions & 0 deletions tests/MultiplePlugins/imports-with-jsdoc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import z from 'z';
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";
import thirdParty from "third-party";
import oneLevelRelativePath from "../oneLevelRelativePath";
import otherthing from "@core/otherthing";
import abc from "@core/abc";
import twoLevelRelativePath from "../../twoLevelRelativePath";


/**
* function example description that was wrapped by hand
* so it have more then one line and don't end with a dot
* REPEATED TWO TIMES BECAUSE IT WAS EASIER to copy
* function example description that was wrapped by hand
* so it have more then one line.
* @return {Boolean} Description for @returns with s
* @param {String|Number} text - some text description that is very long and needs to be wrapped
* @param {String} [defaultValue="defaultTest"] TODO
* @arg {Number|Null} [optionalNumber]
* @private
*@memberof test
@async
* @examples
* var one = 5
* var two = 10
*
* if(one > 2) { two += one }
* @undefiendTag${" "}
* @undefiendTag {number} name des
*/
const TestFunction = (text: string | number, defaultValue: string, optionalNumber: number | Null): boolean => (
<div className="text-white px-4 sm:px-8 py-2 sm:py-3 bg-sky-700 hover:bg-sky-800"></div>
)
14 changes: 14 additions & 0 deletions tests/MultiplePlugins/ppsi.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {run_spec} from '../../test-setup/run_spec';
import * as plugin from '../../src';

run_spec(__dirname, ["typescript"], {
// Note, this is the only order that works in tests, because tailwind looks for published plugins,
// and jsdoc throws a maximum call stack size exceeded error if it comes after tailwind.
plugins: [
'prettier-plugin-jsdoc',
"prettier-plugin-tailwindcss",
plugin,
],
importOrder: ['^@core/(.*)$', '^@server/(.*)', '^@ui/(.*)$', '^[./]'],

});
Loading

0 comments on commit 6d7e4af

Please sign in to comment.