2017-03-25 23:12:01 -07:00
|
|
|
import pytest
|
|
|
|
from tests.utils import Command
|
|
|
|
from thefuck.rules.yarn_command_replaced import match, get_new_command
|
|
|
|
|
|
|
|
|
2017-03-28 18:35:40 +02:00
|
|
|
stderr = ('error `install` has been replaced with `add` to add new '
|
|
|
|
'dependencies. Run "yarn add {}" instead.').format
|
2017-03-25 23:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-03-28 18:35:40 +02:00
|
|
|
Command(script='yarn install redux', stderr=stderr('redux')),
|
|
|
|
Command(script='yarn install moment', stderr=stderr('moment')),
|
|
|
|
Command(script='yarn install lodash', stderr=stderr('lodash'))])
|
2017-03-25 23:12:01 -07:00
|
|
|
def test_match(command):
|
|
|
|
assert match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command('yarn install')])
|
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command)
|
2017-03-28 18:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
@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
|