Coverage for tests / integration / tools / vue_tsc / test_check.py: 100%
34 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Integration tests for vue-tsc tool definition.
3These tests require vue-tsc to be installed and available in PATH.
4They verify the VueTscPlugin definition, check command, and set_options method.
5"""
7from __future__ import annotations
9from collections.abc import Callable
10from pathlib import Path
11from typing import TYPE_CHECKING
13import pytest
14from assertpy import assert_that
16from tests.integration.tools.vue_tsc.conftest import vue_tsc_is_available
18if TYPE_CHECKING:
19 from lintro.plugins.base import BaseToolPlugin
21# Skip all tests if vue-tsc is not installed or not working
22pytestmark = pytest.mark.skipif(
23 not vue_tsc_is_available(),
24 reason="vue-tsc not installed or not working",
25)
28# --- Tests for VueTscPlugin definition ---
31@pytest.mark.parametrize(
32 ("attr", "expected"),
33 [
34 ("name", "vue-tsc"),
35 ("can_fix", False),
36 ],
37 ids=["name", "can_fix"],
38)
39def test_definition_attributes(
40 get_plugin: Callable[[str], BaseToolPlugin],
41 attr: str,
42 expected: object,
43) -> None:
44 """Verify VueTscPlugin definition has correct attribute values.
46 Tests that the plugin definition exposes the expected values for
47 name and can_fix attributes.
49 Args:
50 get_plugin: Fixture factory to get plugin instances.
51 attr: The attribute name to check on the definition.
52 expected: The expected value of the attribute.
53 """
54 vue_tsc_plugin = get_plugin("vue-tsc")
55 assert_that(getattr(vue_tsc_plugin.definition, attr)).is_equal_to(expected)
58def test_definition_file_patterns(
59 get_plugin: Callable[[str], BaseToolPlugin],
60) -> None:
61 """Verify VueTscPlugin definition includes Vue file patterns.
63 Tests that the plugin is configured to handle Vue files (*.vue).
65 Args:
66 get_plugin: Fixture factory to get plugin instances.
67 """
68 vue_tsc_plugin = get_plugin("vue-tsc")
69 assert_that(vue_tsc_plugin.definition.file_patterns).contains("*.vue")
72def test_definition_has_version_command(
73 get_plugin: Callable[[str], BaseToolPlugin],
74) -> None:
75 """Verify VueTscPlugin definition has a version command.
77 Tests that the plugin exposes a version command for checking
78 the installed vue-tsc version.
80 Args:
81 get_plugin: Fixture factory to get plugin instances.
82 """
83 vue_tsc_plugin = get_plugin("vue-tsc")
84 assert_that(vue_tsc_plugin.definition.version_command).is_not_none()
87# --- Integration tests for vue-tsc check command ---
90def test_check_empty_directory(
91 get_plugin: Callable[[str], BaseToolPlugin],
92 tmp_path: Path,
93) -> None:
94 """Verify vue-tsc check handles empty directories gracefully.
96 Runs vue-tsc check on an empty directory and verifies a result is returned
97 without errors.
99 Args:
100 get_plugin: Fixture factory to get plugin instances.
101 tmp_path: Pytest fixture providing a temporary directory.
102 """
103 vue_tsc_plugin = get_plugin("vue-tsc")
104 result = vue_tsc_plugin.check([str(tmp_path)], {})
106 assert_that(result).is_not_none()
107 assert_that(result.success).is_true()
108 assert_that(result.issues_count).is_equal_to(0)
111# --- Tests for VueTscPlugin.set_options method ---
114@pytest.mark.parametrize(
115 ("option_name", "option_value", "expected"),
116 [
117 ("timeout", 60, 60),
118 ("project", "./tsconfig.app.json", "./tsconfig.app.json"),
119 ("strict", True, True),
120 ("skip_lib_check", False, False),
121 ],
122 ids=["timeout", "project", "strict", "skip_lib_check"],
123)
124def test_set_options(
125 get_plugin: Callable[[str], BaseToolPlugin],
126 option_name: str,
127 option_value: object,
128 expected: object,
129) -> None:
130 """Verify VueTscPlugin.set_options correctly sets various options.
132 Tests that plugin options can be set and retrieved correctly.
134 Args:
135 get_plugin: Fixture factory to get plugin instances.
136 option_name: Name of the option to set.
137 option_value: Value to set for the option.
138 expected: Expected value when retrieving the option.
139 """
140 vue_tsc_plugin = get_plugin("vue-tsc")
141 vue_tsc_plugin.set_options(**{option_name: option_value})
142 assert_that(vue_tsc_plugin.options.get(option_name)).is_equal_to(expected)
145def test_set_exclude_patterns(
146 get_plugin: Callable[[str], BaseToolPlugin],
147) -> None:
148 """Verify VueTscPlugin.set_options correctly sets exclude_patterns.
150 Tests that exclude patterns can be set and retrieved correctly.
152 Args:
153 get_plugin: Fixture factory to get plugin instances.
154 """
155 vue_tsc_plugin = get_plugin("vue-tsc")
156 vue_tsc_plugin.set_options(exclude_patterns=["node_modules", "dist"])
157 assert_that(vue_tsc_plugin.exclude_patterns).contains("node_modules")
158 assert_that(vue_tsc_plugin.exclude_patterns).contains("dist")