Created
March 22, 2019 13:47
-
-
Save Saturate/aaa9546d06c9e1f8d379a91f6bd7bb44 to your computer and use it in GitHub Desktop.
When you use redux, you might have an actions keys file, a common error is having two const export the same thing. This will test for that, and maybe make your coverage 100%!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as actionKeys from './action-keys'; | |
describe('action keys', () => { | |
it('should have a unique string for each key', () => { | |
let uniq = Object.keys(actionKeys) | |
.map(objKey => { | |
return { count: 1, name: actionKeys[objKey] }; | |
}) | |
.reduce((a, b) => { | |
a[b.name] = (a[b.name] || 0) + b.count; | |
return a; | |
}, {}); | |
const duplicates = Object.keys(uniq).filter(a => uniq[a] > 1); | |
expect(duplicates).toHaveLength(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment