@@ -14,13 +14,17 @@ import DeclarationSource
14
14
import { multipleLinesClass } from 'docc-render/constants/multipleLines' ;
15
15
import { hasMultipleLines } from 'docc-render/utils/multipleLines' ;
16
16
import { themeSettingsState } from 'docc-render/utils/theme-settings' ;
17
+ import { indentDeclaration } from 'docc-render/utils/indentation' ;
18
+ import Language from '@/constants/Language' ;
19
+ import { flushPromises } from '../../../../../test-utils' ;
17
20
18
21
const { Token } = DeclarationSource . components ;
19
22
const { TokenKind } = Token . constants ;
20
23
21
- jest . mock ( '@/utils/multipleLines' , ( ) => ( {
22
- hasMultipleLines : jest . fn ( ) ,
23
- } ) ) ;
24
+ jest . mock ( '@/utils/indentation' ) ;
25
+ jest . mock ( '@/utils/multipleLines' ) ;
26
+
27
+ hasMultipleLines . mockImplementation ( ( ) => false ) ;
24
28
25
29
describe ( 'DeclarationSource' , ( ) => {
26
30
let wrapper ;
@@ -87,6 +91,27 @@ describe('DeclarationSource', () => {
87
91
await wrapper . vm . $nextTick ( ) ;
88
92
expect ( wrapper . find ( { ref : 'declarationGroup' } ) . classes ( ) ) . toContain ( multipleLinesClass ) ;
89
93
} ) ;
94
+
95
+ it ( 'runs the hasMultipleLines, after `indentDeclaration` for ObjC code' , async ( ) => {
96
+ const callStack = [ ] ;
97
+ hasMultipleLines . mockImplementationOnce ( ( ) => {
98
+ callStack . push ( 'hasMultipleLines' ) ;
99
+ return true ;
100
+ } ) ;
101
+ indentDeclaration . mockImplementationOnce ( ( ) => callStack . push ( 'indentDeclaration' ) ) ;
102
+
103
+ wrapper = shallowMount ( DeclarationSource , {
104
+ propsData : {
105
+ ...propsData ,
106
+ language : Language . objectiveC . key . api ,
107
+ } ,
108
+ } ) ;
109
+ await flushPromises ( ) ;
110
+ expect ( indentDeclaration ) . toHaveBeenCalledTimes ( 1 ) ;
111
+ expect ( indentDeclaration )
112
+ . toHaveBeenCalledWith ( wrapper . find ( { ref : 'code' } ) . element , Language . objectiveC . key . api ) ;
113
+ expect ( callStack ) . toEqual ( [ 'indentDeclaration' , 'hasMultipleLines' ] ) ;
114
+ } ) ;
90
115
} ) ;
91
116
92
117
describe ( 'Swift function/initializer formatting' , ( ) => {
0 commit comments