1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-28 08:02:33 +01:00

#N/A: Update react_native_command_unrecognized rule

This commit is contained in:
Vladimir Iakovlev
2017-08-30 08:09:13 +02:00
parent 1f1b7da6f4
commit 503c903822
2 changed files with 59 additions and 22 deletions

View File

@@ -1,25 +1,39 @@
import pytest
from io import BytesIO
from thefuck.rules.react_native_command_unrecognized import match, \
get_new_command
from tests.utils import Command
stderr = 'Command `{}` unrecognized'.format
stderr = "Unrecognized command '{}'".format
stdout = '''
Usage: react-native <command>
stdout = b'''
Scanning 615 folders for symlinks in /home/nvbn/work/zcho/BookkaWebView/node_modules (6ms)
Commands:
- start: starts the webserver
- bundle: builds the javascript bundle for offline use
- unbundle: builds javascript as "unbundle" for offline use
- new-library: generates a native library bridge
- android: generates an Android project for your app
- run-android: builds your app and starts it on a connected Android emulator or device
- log-android: print Android logs
- run-ios: builds your app and starts it on iOS simulator
- log-ios: print iOS logs
- upgrade: upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
- link: link a library
Usage: react-native [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
start [options] starts the webserver
run-ios [options] builds your app and starts it on iOS simulator
run-android [options] builds your app and starts it on a connected Android emulator or device
new-library [options] generates a native library bridge
bundle [options] builds the javascript bundle for offline use
unbundle [options] builds javascript as "unbundle" for offline use
eject [options] Re-create the iOS and Android folders and native code
link [options] [packageName] links all native dependencies (updates native build files)
unlink [options] <packageName> unlink native dependency
install [options] <packageName> install and link native dependencies
uninstall [options] <packageName> uninstall and unlink native dependencies
upgrade [options] upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
log-android [options] starts adb logcat
log-ios [options] starts iOS device syslog tail
'''
@@ -38,9 +52,12 @@ def test_not_match(command):
@pytest.mark.parametrize('command, result', [
(Command('react-native star', stdout, stderr('star')),
(Command('react-native star', stderr=stderr('star')),
'react-native start'),
(Command('react-native logsandroid -f', stdout, stderr('logsandroid')),
(Command('react-native logsandroid -f', stderr=stderr('logsandroid')),
'react-native log-android -f')])
def test_get_new_command(command, result):
def test_get_new_command(mocker, command, result):
patch = mocker.patch(
'thefuck.rules.react_native_command_unrecognized.Popen')
patch.return_value.stdout = BytesIO(stdout)
assert get_new_command(command)[0] == result