Skip to content

Add 'cp, 'cs', 'sctest' snippets #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Every space inside `{ }` and `( )` means that this is pushed into next line :)
| `sto→` | `setTimeout(() => { }, delayTime` |
| `prom→` | `return new Promise((resolve, reject) => { }` |
| `cmmb→` | `comment block` |
| `cp→` | `const { } = this.props` |
| `cs→` | `const { } = this.state` |

## React

Expand Down Expand Up @@ -509,6 +511,24 @@ describe('<${1:ComponentName} />', () => {
})
```

### `sctest`

```javascript
import React from 'react'
import renderer from 'react-test-renderer'

import { ${1:ComponentName} } from '../${1:ComponentName}'

describe('<${1:ComponentName} />', () => {
const defaultProps = {}
const wrapper = renderer.create(<${1:ComponentName} {...defaultProps} />)

test('render', () => {
expect(wrapper).toMatchSnapshot()
})
})
```

### `snrtest`

```javascript
Expand Down
34 changes: 34 additions & 0 deletions snippets/snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@
"description":
"Displays a message in the console but also displays a blue information icon along with the logged message"
},
"DestructProps": {
"prefix": "cp",
"body": [
"const { $1 } = this.props"
],
"description": "Creates and assigns a local variable using props destructing"
},
"DestructState": {
"prefix": "cs",
"body": [
"const { $1 } = this.state"
],
"description": "Creates and assigns a local variable using state destructing"
},
// ==============================================================================================
// React
"import React": {
Expand Down Expand Up @@ -992,6 +1006,26 @@
""
]
},
"setupReactComponentTest": {
"prefix": "sctest",
"body": [
"import React from 'react'",
"import renderer from 'react-test-renderer'",
"",
"import { ${1:ComponentName} } from '../${1:ComponentName}'",
"",
"describe('<${1:ComponentName} />', () => {",
" const defaultProps = {}",
" const wrapper = renderer.create(<${1:ComponentName} {...defaultProps} />)",
"",
" test('render', () => {",
" expect(wrapper).toMatchSnapshot()",
" })",
"})",
""
],
"description": "Create test component"
},
"setupReactNativeTestWithRedux": {
"prefix": "snrtest",
"body": [
Expand Down