|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import assert from 'assert' |
7 | | -import { resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test' |
| 7 | +import { resetCodeWhispererGlobalVariables, toTextDocument } from 'aws-core-vscode/test' |
8 | 8 | import { runtimeLanguageContext, RuntimeLanguageContext, PlatformLanguageId } from 'aws-core-vscode/codewhisperer' |
9 | 9 | import * as codewhispererClient from 'aws-core-vscode/codewhisperer' |
10 | 10 | import { CodewhispererLanguage } from 'aws-core-vscode/shared' |
11 | 11 |
|
12 | 12 | describe('runtimeLanguageContext', function () { |
13 | 13 | const languageContext = new RuntimeLanguageContext() |
14 | 14 |
|
15 | | - describe('test isLanguageSupported', function () { |
| 15 | + describe('test isLanguageSupported with languageId as the argument', function () { |
16 | 16 | const cases: [string, boolean][] = [ |
17 | 17 | ['java', true], |
18 | 18 | ['javascript', true], |
@@ -61,6 +61,61 @@ describe('runtimeLanguageContext', function () { |
61 | 61 | assert.strictEqual(actual, expected) |
62 | 62 | }) |
63 | 63 | }) |
| 64 | + |
| 65 | + describe('test isLanguageSupported with document as the argument', function () { |
| 66 | + const cases: [string, boolean][] = [ |
| 67 | + ['helloJava.java', true], |
| 68 | + ['helloPython.py', true], |
| 69 | + ['helloJavascript.js', true], |
| 70 | + ['helloJsx.jsx', true], |
| 71 | + ['helloTypescript.ts', true], |
| 72 | + ['helloTsx.tsx', true], |
| 73 | + ['helloCsharp.cs', true], |
| 74 | + ['helloC.c', true], |
| 75 | + ['helloC.h', true], |
| 76 | + ['helloCpp.cpp', true], |
| 77 | + ['helloCpp.cc', true], |
| 78 | + ['helloGo.go', true], |
| 79 | + ['helloKotlin.kt', true], |
| 80 | + ['helloPhp.php', true], |
| 81 | + ['helloRuby.rb', true], |
| 82 | + ['helloRust.rs', true], |
| 83 | + ['helloScala.scala', true], |
| 84 | + ['helloShellscript.sh', true], |
| 85 | + ['helloSql.sql', true], |
| 86 | + ['helloSystemVerilog.svh', true], |
| 87 | + ['helloSystemVerilog.sv', true], |
| 88 | + ['helloSystemVerilog.vh', true], |
| 89 | + ['helloDart.dart', true], |
| 90 | + ['helloLua.lua', true], |
| 91 | + ['helloLua.wlua', true], |
| 92 | + ['helloSwift.swift', true], |
| 93 | + ['helloVue.vue', true], |
| 94 | + ['helloPowerShell.ps1', true], |
| 95 | + ['helloPowerShell.psm1', true], |
| 96 | + ['helloR.r', true], |
| 97 | + ['helloJson.json', true], |
| 98 | + ['helloYaml.yaml', true], |
| 99 | + ['helloYaml.yml', true], |
| 100 | + ['helloTf.tf', true], |
| 101 | + ['helloPlaintext.txt', false], |
| 102 | + ['helloHtml.html', false], |
| 103 | + ['helloCss.css', false], |
| 104 | + ['helloUnknown', false], |
| 105 | + ['helloFoo.foo', false], |
| 106 | + ] |
| 107 | + |
| 108 | + cases.forEach((tuple) => { |
| 109 | + const fileName = tuple[0] |
| 110 | + const expected = tuple[1] |
| 111 | + |
| 112 | + it(`pass document ${fileName} as argument should first try determine by languageId then file extensions`, async function () { |
| 113 | + const doc = await toTextDocument('', fileName) |
| 114 | + const actual = languageContext.isLanguageSupported(doc) |
| 115 | + assert.strictEqual(actual, expected) |
| 116 | + }) |
| 117 | + }) |
| 118 | + }) |
64 | 119 | }) |
65 | 120 |
|
66 | 121 | describe('test getLanguageContext', function () { |
|
0 commit comments