-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the language selector to detect autonym by exonym (#883)
* add API call to get language code * get an array of lang codes and filter from that * simplify response handling and improve api constant name * debounce api requests * don't make api calls with empty inputs * Mock svg import files in jest tests * add test skeleton * add test --------- Co-authored-by: gtzatchkova <[email protected]>
- Loading branch information
Showing
6 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import LanguageSelector from '@/Components/LanguageSelector.vue'; | ||
import { createI18n } from 'vue-banana-i18n'; | ||
|
||
const i18n = createI18n({ | ||
messages: {}, | ||
locale: 'en', | ||
wikilinks: true | ||
}); | ||
|
||
describe('LanguageSelector.vue', () => { | ||
it('suggests the relevant language upon input', async () => { | ||
const wrapper = mount(LanguageSelector, { | ||
global: { | ||
plugins: [i18n], | ||
}}); | ||
|
||
const input = wrapper.find('input'); | ||
|
||
expect(input.exists()).toBe(true); | ||
|
||
await input.setValue('deu'); | ||
const listItems = await wrapper.findAll('.languageSelector__options-menu__languages-list__item'); | ||
|
||
expect(listItems.at(0).text()).toContain('Deutsch'); | ||
}); | ||
|
||
it('suggests the relevant language upon RTL input', async () => { | ||
const wrapper = mount(LanguageSelector, { | ||
global: { | ||
plugins: [i18n], | ||
}}); | ||
|
||
const input = wrapper.find('input'); | ||
|
||
expect(input.exists()).toBe(true); | ||
|
||
await input.setValue('עב'); | ||
const listItems = await wrapper.findAll('.languageSelector__options-menu__languages-list__item'); | ||
|
||
expect(listItems.at(0).text()).toContain('עברית'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
process(sourceText, sourcePath) { | ||
const mockComponent = { | ||
name: sourcePath, | ||
template: sourceText | ||
} | ||
|
||
return { | ||
code: `module.exports = ${JSON.stringify(mockComponent)};` | ||
} | ||
} | ||
} |