File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 66export * from './enums'
77export * from './interfaces'
88export * from './types'
9+ export * from './utils'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Unit Tests - max
3+ * @module commitlint-config/utils/tests/unit/max
4+ */
5+
6+ import { Scope } from '#src/enums'
7+ import testSubject from '../max'
8+
9+ describe ( 'unit:utils/max' , ( ) => {
10+ it ( 'should return length of longest string in given array' , ( ) => {
11+ // Arrange
12+ const array : Scope [ ] = [ Scope . BUILD , Scope . COMPONENTS , Scope . YARN ]
13+
14+ // Act + Expect
15+ expect ( testSubject ( array ) ) . to . equal ( Scope . COMPONENTS . length )
16+ } )
17+ } )
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Entry Point - Utilities
3+ * @module commitlint-config/utils
4+ */
5+
6+ export { default as max } from './max'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Utilities - max
3+ * @module commitlint-config/utils/max
4+ */
5+
6+ /**
7+ * Returns the length of the longest string in the given `array`.
8+ *
9+ * @param {string[] } array - Array to evaluate
10+ * @return {number } Length of longest string in `array`
11+ */
12+ const max = ( array : string [ ] ) : number => {
13+ return array . reduce ( ( max : number , str : string ) : number => {
14+ return str . length > max ? str . length : max
15+ } , 0 )
16+ }
17+
18+ export default max
You can’t perform that action at this time.
0 commit comments