-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] Convert lib/mappings to TypeScript #4008
Changes from 12 commits
f5faee9
a7e1367
9b16a0a
51f2d9f
204491c
010629f
253aa8c
617e02e
894fdea
4251173
499ac53
0d6ab00
a77d615
8daf1bc
df73ecc
f4b9de8
a854556
3571a7d
d8c81ba
0ea3fdb
fc52bb3
ccdee60
e776e9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
* under the License. | ||
*/ | ||
|
||
import { Field } from '../mappings'; | ||
import '../../../application/models/sense_editor/sense_editor.test.mocks'; | ||
import * as mappings from '../mappings'; | ||
|
||
|
@@ -39,7 +40,7 @@ describe('Mappings', () => { | |
mappings.clear(); | ||
}); | ||
|
||
function fc(f1, f2) { | ||
function fc(f1: Field, f2: Field) { | ||
if (f1.name < f2.name) { | ||
return -1; | ||
} | ||
|
@@ -49,8 +50,8 @@ describe('Mappings', () => { | |
return 0; | ||
} | ||
|
||
function f(name, type) { | ||
return { name: name, type: type || 'string' }; | ||
function f(name: string, type?: string) { | ||
return { name, type: type || 'string' }; | ||
} | ||
|
||
test('Multi fields 1.0 style', function () { | ||
|
@@ -256,10 +257,37 @@ describe('Mappings', () => { | |
'test_index2', | ||
]); | ||
expect(mappings.getIndices(false).sort()).toEqual(['test_index1', 'test_index2']); | ||
expect(mappings.expandAliases(['alias1', 'test_index2']).sort()).toEqual([ | ||
expect((mappings.expandAliases(['alias1', 'test_index2']) as string[]).sort()).toEqual([ | ||
'test_index1', | ||
'test_index2', | ||
]); | ||
expect(mappings.expandAliases('alias2')).toEqual('test_index2'); | ||
}); | ||
|
||
test('Multi types', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think there are also some missing tests on other functions like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to add unit tests, but after looking through it, |
||
mappings.loadMappings({ | ||
index: { | ||
properties: { | ||
name1: { | ||
type: 'object', | ||
path: 'just_name', | ||
properties: { | ||
first1: { type: 'string' }, | ||
last1: { type: 'string', index_name: 'i_last_1' }, | ||
}, | ||
}, | ||
name2: { | ||
type: 'object', | ||
path: 'full', | ||
properties: { | ||
first2: { type: 'string' }, | ||
last2: { type: 'string', index_name: 'i_last_2' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(mappings.getTypes()).toEqual(['properties']); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is some conflicts here. Seems some mess up with other commits. could you remove these three lines that are not ur PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done