mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
bf109ee548
For example, if an "etl" script is defined in package.json, it can be run with `yarn etl`. However, if `yarn etil` is run, `yarn` will suggest the correction. This change lets `thefuck` take advantage of that: $ yarn etil yarn etil v0.21.3 error Command "etil" not found. Did you mean "etl"? $ fuck yarn etl [enter/?/?/ctrl+c]
25 lines
857 B
Python
25 lines
857 B
Python
import pytest
|
|
from thefuck.rules.yarn_alias import match, get_new_command
|
|
from tests.utils import Command
|
|
|
|
|
|
stderr_remove = 'error Did you mean `yarn remove`?'
|
|
stderr_etl = 'error Command "etil" not found. Did you mean "etl"?'
|
|
stderr_list = 'error Did you mean `yarn list`?'
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
Command(script='yarn rm', stderr=stderr_remove),
|
|
Command(script='yarn etil', stderr=stderr_etl),
|
|
Command(script='yarn ls', stderr=stderr_list)])
|
|
def test_match(command):
|
|
assert match(command)
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
|
(Command('yarn rm', stderr=stderr_remove), 'yarn remove'),
|
|
(Command('yarn etil', stderr=stderr_etl), 'yarn etl'),
|
|
(Command('yarn ls', stderr=stderr_list), 'yarn list')])
|
|
def test_get_new_command(command, new_command):
|
|
assert get_new_command(command) == new_command
|