Skip to content

Commit

Permalink
Merge bd6d219 into 117880a
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwatts committed May 21, 2020
2 parents 117880a + bd6d219 commit c39f60d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/createActions.js
Expand Up @@ -7,7 +7,7 @@ const defaultOptions = {

// matches each word in a camelCaseString (except the first)
// consecutive capitals are treated as one word
const RX_CAPS = /(?!^)([A-Z][a-z]+|[A-Z]+(?=[A-Z]|\b))/g
const RX_CAPS = /(?!^)([A-Z][a-z0-9]+|[A-Z][A-Z0-9]*(?=[A-Z]|\b))/g

// converts a camelCaseWord into a SCREAMING_SNAKE_CASE word
const camelToScreamingSnake = pipe(
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/createActionsTest.js
Expand Up @@ -18,6 +18,20 @@ test('types are snake case', t => {
t.is(Types.HELLO_WORLD, 'HELLO_WORLD')
})

test('type names handle consecutive capitals', t => {
const { Types } = createActions({ setVIPById: null })
t.is(Types.SET_VIP_BY_ID, 'SET_VIP_BY_ID')
})

test('type names handle numbers', t => {
const { Types } = createActions({
storeS3Key: null,
usePython3Instead: null,
})
t.is(Types.STORE_S3_KEY, 'STORE_S3_KEY')
t.is(Types.USE_PYTHON3_INSTEAD, 'USE_PYTHON3_INSTEAD')
})

test('null produces a type-only action creator', t => {
const { Creators } = createActions({ helloWorld: null })
t.is(typeof Creators.helloWorld, 'function')
Expand Down

0 comments on commit c39f60d

Please sign in to comment.