mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 04:18:55 +00:00
#621: Refine yarn_command_replaced
rule tests
This commit is contained in:
parent
900e83e028
commit
802fcd96fd
@ -1,32 +1,32 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
from tests.utils import Command
|
||||
from thefuck.rules.yarn_command_replaced import match, get_new_command
|
||||
|
||||
|
||||
stderr = '''
|
||||
error `install` has been replaced with `add` to add new dependencies. Run "yarn add {}" instead.
|
||||
'''.format
|
||||
stderr = ('error `install` has been replaced with `add` to add new '
|
||||
'dependencies. Run "yarn add {}" instead.').format
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='yarn install asdklj', stderr=stderr('asdklj')),
|
||||
Command(script='yarn install liuqowe', stderr=stderr('liuqowe')),
|
||||
Command(script='yarn install zxmnc', stderr=stderr('zxmnc'))])
|
||||
Command(script='yarn install redux', stderr=stderr('redux')),
|
||||
Command(script='yarn install moment', stderr=stderr('moment')),
|
||||
Command(script='yarn install lodash', stderr=stderr('lodash'))])
|
||||
def test_match(command):
|
||||
assert match(command)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('yarn install asdklj', stderr=stderr('asdklj')), 'yarn add asdklj'),
|
||||
(Command('yarn install iiuqowe', stderr=stderr('iiuqowe')), 'yarn add iiuqowe'),
|
||||
(Command('yarn install zxmnc', stderr=stderr('zxmnc')), 'yarn add zxmnc')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command) == new_command
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command('yarn install')])
|
||||
def test_not_match(command):
|
||||
assert not match(command)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('yarn install redux', stderr=stderr('redux')),
|
||||
'yarn add redux'),
|
||||
(Command('yarn install moment', stderr=stderr('moment')),
|
||||
'yarn add moment'),
|
||||
(Command('yarn install lodash', stderr=stderr('lodash')),
|
||||
'yarn add lodash')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command) == new_command
|
||||
|
Loading…
x
Reference in New Issue
Block a user