@@ -13,29 +13,26 @@ describe("convertEditorSettings", () => {
13
13
} ;
14
14
15
15
// Act
16
- const { converted, missing, failed } = convertEditorSettings (
17
- { converters } ,
18
- editorConfiguration ,
19
- ) ;
16
+ const result = convertEditorSettings ( { converters } , editorConfiguration ) ;
20
17
21
18
// Assert
22
- expect ( converted . size ) . toEqual ( 0 ) ;
23
- expect ( missing . length ) . toEqual ( 0 ) ;
24
- expect ( failed . length ) . toEqual ( 0 ) ;
19
+ expect ( result ) . toEqual ( {
20
+ converted : new Map ( ) ,
21
+ failed : [ ] ,
22
+ missing : [ ] ,
23
+ } ) ;
25
24
} ) ;
26
25
27
26
it ( "skips a configuration if not an editor setting" , ( ) => {
28
27
// Arrange
29
- const conversionResult : EditorSettingConversionResult = {
28
+ const { editorSetting , converters } = setupConversionEnvironment ( {
30
29
settings : [
31
30
{
32
31
editorSettingName : "editor.eslint-setting-a" ,
33
32
value : "a" ,
34
33
} ,
35
34
] ,
36
- } ;
37
-
38
- const { editorSetting, converters } = setupConversionEnvironment ( conversionResult ) ;
35
+ } ) ;
39
36
40
37
const editorConfiguration = {
41
38
notAnEditorSetting : "a" ,
@@ -44,29 +41,40 @@ describe("convertEditorSettings", () => {
44
41
} ;
45
42
46
43
// Act
47
- const { converted, missing, failed } = convertEditorSettings (
48
- { converters } ,
49
- editorConfiguration ,
50
- ) ;
44
+ const result = convertEditorSettings ( { converters } , editorConfiguration ) ;
51
45
52
46
// Assert
53
- expect ( converted . size ) . toEqual ( 1 ) ;
54
- expect ( missing . length ) . toEqual ( 0 ) ;
55
- expect ( failed . length ) . toEqual ( 0 ) ;
47
+ expect ( result ) . toEqual ( {
48
+ converted : new Map ( [
49
+ [
50
+ "editor.eslint-setting-a" ,
51
+ {
52
+ editorSettingName : "editor.eslint-setting-a" ,
53
+ value : "a" ,
54
+ } ,
55
+ ] ,
56
+ ] ) ,
57
+ failed : [ ] ,
58
+ missing : [ ] ,
59
+ } ) ;
56
60
} ) ;
57
61
58
62
it ( "marks a setting as missing when its converter returns undefined" , ( ) => {
59
63
// Arrange
60
64
const { editorSetting, converters } = setupConversionEnvironment ( ) ;
61
65
62
66
// Act
63
- const { missing } = convertEditorSettings (
67
+ const result = convertEditorSettings (
64
68
{ converters } ,
65
69
{ [ editorSetting . editorSettingName ] : editorSetting } ,
66
70
) ;
67
71
68
72
// Assert
69
- expect ( missing ) . toEqual ( [ { editorSettingName : editorSetting . editorSettingName } ] ) ;
73
+ expect ( result ) . toEqual ( {
74
+ converted : new Map ( ) ,
75
+ failed : [ ] ,
76
+ missing : [ { editorSettingName : editorSetting . editorSettingName } ] ,
77
+ } ) ;
70
78
} ) ;
71
79
72
80
it ( "marks a conversion as failed when returned a conversion error" , ( ) => {
@@ -76,45 +84,50 @@ describe("convertEditorSettings", () => {
76
84
converters . set ( editorSetting . editorSettingName , ( ) => conversionError ) ;
77
85
78
86
// Act
79
- const { failed } = convertEditorSettings (
87
+ const result = convertEditorSettings (
80
88
{ converters } ,
81
89
{ [ editorSetting . editorSettingName ] : editorSetting } ,
82
90
) ;
83
91
84
92
// Assert
85
- expect ( failed ) . toEqual ( [ conversionError ] ) ;
93
+ expect ( result ) . toEqual ( {
94
+ converted : new Map ( ) ,
95
+ failed : [ conversionError ] ,
96
+ missing : [ ] ,
97
+ } ) ;
86
98
} ) ;
87
99
88
100
it ( "marks a converted setting name as converted when a conversion has settings" , ( ) => {
89
101
// Arrange
90
- const conversionResult : EditorSettingConversionResult = {
102
+ const { editorSetting , converters } = setupConversionEnvironment ( {
91
103
settings : [
92
104
{
93
- editorSettingName : "editor. eslint-setting-a " ,
105
+ editorSettingName : "eslint.configFile " ,
94
106
value : "a" ,
95
107
} ,
96
108
] ,
97
- } ;
98
- const { editorSetting, converters } = setupConversionEnvironment ( conversionResult ) ;
109
+ } ) ;
99
110
100
111
// Act
101
- const { converted } = convertEditorSettings (
112
+ const result = convertEditorSettings (
102
113
{ converters } ,
103
114
{ [ editorSetting . editorSettingName ] : editorSetting . value } ,
104
115
) ;
105
116
106
117
// Assert
107
- expect ( converted ) . toEqual (
108
- new Map ( [
118
+ expect ( result ) . toEqual ( {
119
+ converted : new Map ( [
109
120
[
110
- "editor. eslint-setting-a " ,
121
+ "eslint.configFile " ,
111
122
{
112
- editorSettingName : "editor. eslint-setting-a " ,
123
+ editorSettingName : "eslint.configFile " ,
113
124
value : "a" ,
114
125
} ,
115
126
] ,
116
127
] ) ,
117
- ) ;
128
+ failed : [ ] ,
129
+ missing : [ ] ,
130
+ } ) ;
118
131
} ) ;
119
132
} ) ;
120
133
@@ -127,7 +140,7 @@ function setupConversionEnvironment(conversionResult?: EditorSettingConversionRe
127
140
128
141
function createSampleEditorSetting ( ) : EditorSetting {
129
142
return {
130
- editorSettingName : "editor. tslint-editor-setting-a " ,
143
+ editorSettingName : "tslint.configFile " ,
131
144
value : "a" ,
132
145
} ;
133
146
}
0 commit comments