diff options
Diffstat (limited to 'spec/frontend/editor/utils_spec.js')
-rw-r--r-- | spec/frontend/editor/utils_spec.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/spec/frontend/editor/utils_spec.js b/spec/frontend/editor/utils_spec.js index e561cad1086..c9d6cbcaaa6 100644 --- a/spec/frontend/editor/utils_spec.js +++ b/spec/frontend/editor/utils_spec.js @@ -1,6 +1,8 @@ import { editor as monacoEditor } from 'monaco-editor'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import * as utils from '~/editor/utils'; +import languages from '~/ide/lib/languages'; +import { registerLanguages } from '~/ide/utils'; import { DEFAULT_THEME } from '~/ide/lib/themes'; describe('Source Editor utils', () => { @@ -53,20 +55,24 @@ describe('Source Editor utils', () => { }); describe('getBlobLanguage', () => { + beforeEach(() => { + registerLanguages(...languages); + }); + it.each` - path | expectedLanguage - ${'foo.js'} | ${'javascript'} - ${'foo.js.rb'} | ${'ruby'} - ${'foo.bar'} | ${'plaintext'} - ${undefined} | ${'plaintext'} - `( - 'sets the $expectedThemeName theme when $themeName is set in the user preference', - ({ path, expectedLanguage }) => { - const language = utils.getBlobLanguage(path); + path | expectedLanguage + ${'foo.js'} | ${'javascript'} + ${'foo.js.rb'} | ${'ruby'} + ${'foo.bar'} | ${'plaintext'} + ${undefined} | ${'plaintext'} + ${'foo/bar/foo.js'} | ${'javascript'} + ${'CODEOWNERS'} | ${'codeowners'} + ${'.gitlab/CODEOWNERS'} | ${'codeowners'} + `(`returns '$expectedLanguage' for '$path' path`, ({ path, expectedLanguage }) => { + const language = utils.getBlobLanguage(path); - expect(language).toEqual(expectedLanguage); - }, - ); + expect(language).toEqual(expectedLanguage); + }); }); describe('setupCodeSnipet', () => { |