Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't auto-load prettier-plugin-organize-imports in tests #420

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function compareFiles(
const actual: string = format(code, {
parser: 'pug',
plugins: [plugin],
// pluginSearchDirs: false,
...formatOptions,
});

Expand Down
4 changes: 4 additions & 0 deletions tests/issues/issue-419/formatted.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.topic(
v-for="topic in topics",
v-delayed-unhide="{ disabled: !!selectedTopic }"
)
38 changes: 38 additions & 0 deletions tests/issues/issue-419/issue-419.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { compareFiles } from 'tests/common';
import type { SpyInstance } from 'vitest';
import { describe, expect, it, vi } from 'vitest';

describe('Issues', () => {
it('should log a warning when passing inline object literal to custom vue directive and pugFramework is not set', () => {
const spyConsoleWarn: SpyInstance<
[message?: any, ...optionalParams: any[]],
void
> = vi.spyOn(console, 'warn');

const { expected, actual } = compareFiles(__dirname);
expect(actual).toBe(expected);

expect(spyConsoleWarn).toHaveBeenCalledWith(
'The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:',
'disabled: !!selectedTopic',
);

spyConsoleWarn.mockRestore();
});

it('should not log a warning when passing inline object literal to custom vue directive and pugFramework is set to vue', () => {
const spyConsoleWarn: SpyInstance<
[message?: any, ...optionalParams: any[]],
void
> = vi.spyOn(console, 'warn');

const { expected, actual } = compareFiles(__dirname, {
formatOptions: { pugFramework: 'vue' },
});
expect(actual).toBe(expected);

expect(spyConsoleWarn).not.toHaveBeenCalled();

spyConsoleWarn.mockRestore();
});
});
4 changes: 4 additions & 0 deletions tests/issues/issue-419/unformatted.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.topic(
v-for="topic in topics"
v-delayed-unhide="{ disabled: !!selectedTopic }"
)