2017-03-25 23:12:01 -07:00
|
|
|
import pytest
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2017-03-25 23:12:01 -07:00
|
|
|
from thefuck.rules.yarn_command_replaced import match, get_new_command
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
output = ('error `install` has been replaced with `add` to add new '
|
2017-03-28 18:35:40 +02:00
|
|
|
'dependencies. Run "yarn add {}" instead.').format
|
2017-03-25 23:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('yarn install redux', output('redux')),
|
|
|
|
Command('yarn install moment', output('moment')),
|
|
|
|
Command('yarn install lodash', output('lodash'))])
|
2017-03-25 23:12:01 -07:00
|
|
|
def test_match(command):
|
|
|
|
assert match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('yarn install', '')])
|
2017-03-25 23:12:01 -07:00
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command)
|
2017-03-28 18:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('yarn install redux', output('redux')),
|
2017-03-28 18:35:40 +02:00
|
|
|
'yarn add redux'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('yarn install moment', output('moment')),
|
2017-03-28 18:35:40 +02:00
|
|
|
'yarn add moment'),
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('yarn install lodash', output('lodash')),
|
2017-03-28 18:35:40 +02:00
|
|
|
'yarn add lodash')])
|
|
|
|
def test_get_new_command(command, new_command):
|
|
|
|
assert get_new_command(command) == new_command
|