1- import type { ActionDescriptor , CommandLatest } from "@cursorless/common" ;
1+ // import type { ActionDescriptor, CommandLatest } from "@cursorless/common";
22import { activate } from "@cursorless/cursorless-everywhere-talon-core" ;
33import * as std from "std" ;
44import talonMock from "./talonMock" ;
@@ -12,95 +12,95 @@ async function runTests() {
1212 console . log ( ) ;
1313 console . log ( "Running quickjs tests" ) ;
1414
15- await test ( "testTake" , testTake ) ;
16- await test ( "testChuck" , testChuck ) ;
15+ // await test("testTake", testTake);
16+ // await test("testChuck", testChuck);
1717 } catch ( _error ) {
1818 hasFailed = true ;
1919 }
2020
2121 std . exit ( hasFailed ? 1 : 0 ) ;
2222}
2323
24- async function testTake ( ) {
25- const testHelpers = talonMock . getTestHelpers ( ) ;
26- const initialText = "Hello, world!" ;
27-
28- testHelpers . setEditorState ( {
29- text : initialText ,
30- selections : [ { anchor : 0 , active : 0 } ] ,
31- } ) ;
32-
33- await runAction ( {
34- name : "setSelection" ,
35- target : {
36- type : "primitive" ,
37- modifiers : [ { type : "containingScope" , scopeType : { type : "token" } } ] ,
38- } ,
39- } ) ;
40-
41- const { text, selections } = testHelpers . getFinalEditorState ( ) ;
42-
43- assert . equal ( text , initialText ) ;
44- assert . equal ( selections . length , 1 ) ;
45- assert . equal ( selections [ 0 ] . anchor , 0 ) ;
46- assert . equal ( selections [ 0 ] . active , 5 ) ;
47- }
48-
49- async function testChuck ( ) {
50- const testHelpers = talonMock . getTestHelpers ( ) ;
51-
52- testHelpers . setEditorState ( {
53- text : "Hello, world!" ,
54- selections : [ { anchor : 0 , active : 0 } ] ,
55- } ) ;
56-
57- await runAction ( {
58- name : "remove" ,
59- target : {
60- type : "primitive" ,
61- modifiers : [ { type : "containingScope" , scopeType : { type : "token" } } ] ,
62- } ,
63- } ) ;
64-
65- const { text, selections } = testHelpers . getFinalEditorState ( ) ;
66-
67- assert . equal ( text , ", world!" ) ;
68- assert . equal ( selections . length , 1 ) ;
69- assert . equal ( selections [ 0 ] . anchor , 0 ) ;
70- assert . equal ( selections [ 0 ] . active , 0 ) ;
71- }
72-
73- function runAction ( action : ActionDescriptor ) {
74- const command : CommandLatest = {
75- version : 7 ,
76- usePrePhraseSnapshot : false ,
77- action,
78- } ;
79- return talonMock
80- . getTestHelpers ( )
81- . contextActions . private_cursorless_talonjs_run_and_wait (
82- "cursorless.command" ,
83- command ,
84- ) ;
85- }
86-
87- const assert = {
88- equal : ( actual : unknown , expected : unknown ) => {
89- if ( actual !== expected ) {
90- throw new Error ( `Actual '${ actual } ' Expected '${ expected } '` ) ;
91- }
92- } ,
93- } ;
94-
95- async function test ( name : string , fn : ( ) => Promise < void > ) {
96- try {
97- await fn ( ) ;
98- console . log ( ` * ${ name } ` ) ;
99- } catch ( error ) {
100- console . error ( ` x ${ name } ` ) ;
101- console . error ( error ) ;
102- hasFailed = true ;
103- }
104- }
24+ // async function testTake() {
25+ // const testHelpers = talonMock.getTestHelpers();
26+ // const initialText = "Hello, world!";
27+
28+ // testHelpers.setEditorState({
29+ // text: initialText,
30+ // selections: [{ anchor: 0, active: 0 }],
31+ // });
32+
33+ // await runAction({
34+ // name: "setSelection",
35+ // target: {
36+ // type: "primitive",
37+ // modifiers: [{ type: "containingScope", scopeType: { type: "token" } }],
38+ // },
39+ // });
40+
41+ // const { text, selections } = testHelpers.getFinalEditorState();
42+
43+ // assert.equal(text, initialText);
44+ // assert.equal(selections.length, 1);
45+ // assert.equal(selections[0].anchor, 0);
46+ // assert.equal(selections[0].active, 5);
47+ // }
48+
49+ // async function testChuck() {
50+ // const testHelpers = talonMock.getTestHelpers();
51+
52+ // testHelpers.setEditorState({
53+ // text: "Hello, world!",
54+ // selections: [{ anchor: 0, active: 0 }],
55+ // });
56+
57+ // await runAction({
58+ // name: "remove",
59+ // target: {
60+ // type: "primitive",
61+ // modifiers: [{ type: "containingScope", scopeType: { type: "token" } }],
62+ // },
63+ // });
64+
65+ // const { text, selections } = testHelpers.getFinalEditorState();
66+
67+ // assert.equal(text, ", world!");
68+ // assert.equal(selections.length, 1);
69+ // assert.equal(selections[0].anchor, 0);
70+ // assert.equal(selections[0].active, 0);
71+ // }
72+
73+ // function runAction(action: ActionDescriptor) {
74+ // const command: CommandLatest = {
75+ // version: 7,
76+ // usePrePhraseSnapshot: false,
77+ // action,
78+ // };
79+ // return talonMock
80+ // .getTestHelpers()
81+ // .contextActions.private_cursorless_talonjs_run_and_wait(
82+ // "cursorless.command",
83+ // command,
84+ // );
85+ // }
86+
87+ // const assert = {
88+ // equal: (actual: unknown, expected: unknown) => {
89+ // if (actual !== expected) {
90+ // throw new Error(`Actual '${actual}' Expected '${expected}'`);
91+ // }
92+ // },
93+ // };
94+
95+ // async function test(name: string, fn: () => Promise<void>) {
96+ // try {
97+ // await fn();
98+ // console.log(` * ${name}`);
99+ // } catch (error) {
100+ // console.error(` x ${name}`);
101+ // console.error(error);
102+ // hasFailed = true;
103+ // }
104+ // }
105105
106106await runTests ( ) ;
0 commit comments