diff --git a/tests/__snapshots__/index.spec.ts.snap b/tests/__snapshots__/index.spec.ts.snap new file mode 100644 index 0000000..f541fbd --- /dev/null +++ b/tests/__snapshots__/index.spec.ts.snap @@ -0,0 +1,110 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`test config > custom config 1`] = ` +{ + "importOrder": [ + "", + "^vue$", + "^react$", + "", + "^@/(.*)$", + "^~/(.*)$", + "^[.]", + ], + "overrides": [ + { + "files": "*.md", + "options": { + "organizeImportsSkipDestructiveCodeActions": true, + }, + }, + ], + "plugins": [ + "@ianvs/prettier-plugin-sort-imports", + "prettier-plugin-tailwindcss", + "prettier-plugin-packagejson", + "prettier-plugin-test", + ], + "printWidth": 120, + "semi": true, + "singleQuote": true, + "vueIndentScriptAndStyle": true, +} +`; + +exports[`test config > option is undefined 1`] = ` +{ + "importOrder": [ + "", + "^vue$", + "^react$", + "", + "^@/(.*)$", + "^~/(.*)$", + "^[.]", + ], + "plugins": [ + "@ianvs/prettier-plugin-sort-imports", + "prettier-plugin-tailwindcss", + "prettier-plugin-packagejson", + ], + "printWidth": 120, + "semi": false, + "singleQuote": true, +} +`; + +exports[`test config > sortAtomicClass is false 1`] = ` +{ + "importOrder": [ + "", + "^vue$", + "^react$", + "", + "^@/(.*)$", + "^~/(.*)$", + "^[.]", + ], + "plugins": [ + "@ianvs/prettier-plugin-sort-imports", + "prettier-plugin-packagejson", + ], + "printWidth": 120, + "semi": false, + "singleQuote": true, +} +`; + +exports[`test config > sortImports is false 1`] = ` +{ + "importOrder": undefined, + "plugins": [ + "prettier-plugin-tailwindcss", + "prettier-plugin-packagejson", + ], + "printWidth": 120, + "semi": false, + "singleQuote": true, +} +`; + +exports[`test config > sortPackageJson is false 1`] = ` +{ + "importOrder": [ + "", + "^vue$", + "^react$", + "", + "^@/(.*)$", + "^~/(.*)$", + "^[.]", + ], + "plugins": [ + "@ianvs/prettier-plugin-sort-imports", + "prettier-plugin-tailwindcss", + ], + "printWidth": 120, + "semi": false, + "singleQuote": true, +} +`; diff --git a/tests/index.spec.ts b/tests/index.spec.ts index 493bfbd..82be66c 100644 --- a/tests/index.spec.ts +++ b/tests/index.spec.ts @@ -3,86 +3,19 @@ import { defineConfig } from '../dist/index.js' describe('test config', () => { it('option is undefined', () => { - expect(defineConfig()).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: false, - importOrder: ['', '^vue$', '^react$', '', '^@/(.*)$', '^~/(.*)$', '^[.]'], - plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss', 'prettier-plugin-packagejson'], - overrides: [ - { - files: '**/package.json', - options: { - packageSortOrder: [], - }, - }, - ], - }) + expect(defineConfig()).toMatchSnapshot() }) it('sortImports is false', () => { - expect(defineConfig({ sortImports: false })).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: false, - importOrder: undefined, - plugins: ['prettier-plugin-tailwindcss', 'prettier-plugin-packagejson'], - overrides: [ - { - files: '**/package.json', - options: { - packageSortOrder: [], - }, - }, - ], - }) + expect(defineConfig({ sortImports: false })).toMatchSnapshot() }) it('sortAtomicClass is false', () => { - expect(defineConfig({ sortAtomicClass: false })).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: false, - importOrder: ['', '^vue$', '^react$', '', '^@/(.*)$', '^~/(.*)$', '^[.]'], - plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-packagejson'], - overrides: [ - { - files: '**/package.json', - options: { - packageSortOrder: [], - }, - }, - ], - }) + expect(defineConfig({ sortAtomicClass: false })).toMatchSnapshot() }) it('sortPackageJson is false', () => { - expect(defineConfig({ sortPackageJson: false })).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: false, - importOrder: ['', '^vue$', '^react$', '', '^@/(.*)$', '^~/(.*)$', '^[.]'], - plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss'], - overrides: [], - }) - }) - - it('custom packageSortOrder', () => { - expect(defineConfig({ packageSortOrder: ['name', 'version', 'description', 'scripts'] })).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: false, - importOrder: ['', '^vue$', '^react$', '', '^@/(.*)$', '^~/(.*)$', '^[.]'], - plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss', 'prettier-plugin-packagejson'], - overrides: [ - { - files: '**/package.json', - options: { - packageSortOrder: ['name', 'version', 'description', 'scripts'], - }, - }, - ], - }) + expect(defineConfig({ sortPackageJson: false })).toMatchSnapshot() }) it('custom config', () => { @@ -100,32 +33,6 @@ describe('test config', () => { }, ], }), - ).toStrictEqual({ - printWidth: 120, - singleQuote: true, - semi: true, - importOrder: ['', '^vue$', '^react$', '', '^@/(.*)$', '^~/(.*)$', '^[.]'], - plugins: [ - '@ianvs/prettier-plugin-sort-imports', - 'prettier-plugin-tailwindcss', - 'prettier-plugin-packagejson', - 'prettier-plugin-test', - ], - overrides: [ - { - files: '**/package.json', - options: { - packageSortOrder: [], - }, - }, - { - files: '*.md', - options: { - organizeImportsSkipDestructiveCodeActions: true, - }, - }, - ], - vueIndentScriptAndStyle: true, - }) + ).toMatchSnapshot() }) })