Skip to content

Commit 137cdd1

Browse files
authored
fix(graphql): Prevent the graphql server from accidentally starting with a TypeSpec file (#4639)
* test(graphql): add: lsp-graphql-test.el Reproduce a situation where GraphQL is unintentionally reacting to a TypeSpec file (`.tsp`). * fix(graphql): fix `lsp-graphql-activate-p`, determine on extension Do not mistakenly assume that `.tsp` is a file containing GraphQL. * test(graphql): add test case for `/path/to/graphql/test.go`
1 parent 567a49b commit 137cdd1

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/lsp-graphql-test.el

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
;;; lsp-graphql-test.el --- unit tests for lsp-graphql.el -*- lexical-binding: t -*-
2+
3+
;; Copyright (C) 2024 ncaq <ncaq@ncaq.net>
4+
5+
;; Author: ncaq <ncaq@ncaq.net>
6+
;; Keywords:
7+
8+
;; This program is free software; you can redistribute it and/or modify
9+
;; it under the terms of the GNU General Public License as published by
10+
;; the Free Software Foundation, either version 3 of the License, or
11+
;; (at your option) any later version.
12+
13+
;; This program is distributed in the hope that it will be useful,
14+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
;; GNU General Public License for more details.
17+
18+
;; You should have received a copy of the GNU General Public License
19+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
21+
;;; Commentary:
22+
23+
;;
24+
25+
;;; Code:
26+
27+
(require 'ert)
28+
(require 'lsp-graphql)
29+
30+
(ert-deftest lsp-graphql-activate-p-based-on-file-extension ()
31+
(should (lsp-graphql-activate-p "abc.ts"))
32+
(should (lsp-graphql-activate-p "abc.js"))
33+
(should (lsp-graphql-activate-p "abc.jsx"))
34+
(should (lsp-graphql-activate-p "abc.tsx"))
35+
(should (lsp-graphql-activate-p "abc.vue"))
36+
(should (lsp-graphql-activate-p "abc.graphql"))
37+
(should (lsp-graphql-activate-p "abc.graphqls"))
38+
(should (lsp-graphql-activate-p "abc.gql"))
39+
(should-not (lsp-graphql-activate-p "abc.tsxx"))
40+
(should-not (lsp-graphql-activate-p "abc.jss"))
41+
(should-not (lsp-graphql-activate-p "abc.tsp"))
42+
(should-not (lsp-graphql-activate-p "js.hs"))
43+
(should-not (lsp-graphql-activate-p "/path/to/graphql/test.go")))
44+
45+
;;; lsp-graphql-test.el ends here

0 commit comments

Comments
 (0)