File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Unit Tests - types
3
+ * @module commitlint-config/utils/tests/unit/types
4
+ */
5
+
6
+ import { Type } from '#src/enums'
7
+ import testSubject from '../types'
8
+
9
+ describe ( 'unit:utils/types' , ( ) => {
10
+ it ( 'should return array containing valid commit types' , ( ) => {
11
+ // Arrange
12
+ const extras : string [ ] = [ 'release' , 'wip' ]
13
+
14
+ // Act + Expect
15
+ expect ( testSubject ( extras ) ) . to . include . members ( [
16
+ ...new Set < string > ( [ ...Object . values ( Type ) , ...extras ] )
17
+ ] )
18
+ } )
19
+ } )
Original file line number Diff line number Diff line change 6
6
export { default as max } from './max'
7
7
export { default as min } from './min'
8
8
export { default as scopes } from './scopes'
9
+ export { default as types } from './types'
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Utilities - types
3
+ * @module commitlint-config/utils/types
4
+ */
5
+
6
+ import { Type } from '#src/enums'
7
+ import type { LiteralUnion } from '@flex-development/tutils'
8
+
9
+ /**
10
+ * Returns an array of valid commit types.
11
+ *
12
+ * @param {(Set<string> | string[])? } [extras=[]] - Additional commit types
13
+ * @return {LiteralUnion<Type, string>[] } Commit types array
14
+ */
15
+ const types = (
16
+ extras : Set < string > | string [ ] = [ ]
17
+ ) : LiteralUnion < Type , string > [ ] => {
18
+ return [ ...new Set ( [ ...Object . values ( Type ) , ...extras ] ) ] . sort ( ( t1 , t2 ) => {
19
+ return t1 . localeCompare ( t2 )
20
+ } )
21
+ }
22
+
23
+ export default types
You can’t perform that action at this time.
0 commit comments