Skip to content

Commit 39cd960

Browse files
committed
feat: cleanup & add many tests
1 parent 79acf90 commit 39cd960

10 files changed

+152
-28
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
random text to comment
2+
3+
export const unrelated = "unrelated"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const obj = {
2+
3+
random text to comment
4+
5+
foo: "bar",
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const obj = {
2+
foo: "bar",
3+
baz: "quux", // example docs for `baz`
4+
}

test/results/singleAddSelection.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/** random text to comment */
2+
3+
export const unrelated = "unrelated"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const obj = {
2+
3+
/** random text to comment */
4+
5+
foo: "bar",
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const obj = {
2+
foo: "bar",
3+
/** */
4+
baz: "quux", // example docs for `baz`
5+
}

test/suite/extension.test.ts

Lines changed: 124 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,22 @@ describe("single line jsdoc comment", () => {
303303
)
304304
})
305305

306+
// FIXME: adds line to the comment that has active cursor
307+
describe.skip(
308+
"when selection is entire line",
309+
itHasCorrectOutputAndSelectionPositions(
310+
"singleAddSelection.js",
311+
0,
312+
0,
313+
1,
314+
0,
315+
0,
316+
4,
317+
-1,
318+
26
319+
)
320+
)
321+
306322
// TODO: improve weak example
307323
describe(
308324
"when selection exists within interior of line",
@@ -335,10 +351,40 @@ describe("single line jsdoc comment", () => {
335351
)
336352
)
337353

354+
// FIXME: adds line to the comment that has active cursor & messes up selection
355+
describe.skip(
356+
"when selection is entire line (triple click) and indented",
357+
itHasCorrectOutputAndSelectionPositions(
358+
"singleAddSelectionIndent.js",
359+
1,
360+
0,
361+
2,
362+
0,
363+
0,
364+
6,
365+
-1,
366+
28
367+
)
368+
)
369+
// FIXME: adds line to the comment that has active cursor & messes up spacing & selection
370+
describe.skip(
371+
"when selection is entire alone line (triple click) and indented",
372+
itHasCorrectOutputAndSelectionPositions(
373+
"singleAddSelectionIndentAlone.js",
374+
2,
375+
0,
376+
3,
377+
0,
378+
0,
379+
6,
380+
-1,
381+
28
382+
)
383+
)
338384
describe(
339385
"when selection is all of the text and indented",
340386
itHasCorrectOutputAndSelectionPositions(
341-
"singleAddIndentSelection.js",
387+
"singleAddSelectionIndent.js",
342388
1,
343389
2,
344390
1,
@@ -352,7 +398,7 @@ describe("single line jsdoc comment", () => {
352398
describe(
353399
"when reversed selection is all of the text and indented",
354400
itHasCorrectOutputAndSelectionPositions(
355-
"singleAddIndentSelection.js",
401+
"singleAddSelectionIndent.js",
356402
1,
357403
24,
358404
1,
@@ -365,12 +411,11 @@ describe("single line jsdoc comment", () => {
365411
)
366412
})
367413

368-
describe("converting existing comment", () => {
414+
describe("when existing comment", () => {
369415
describe("when it's a line comment", () => {
370-
// TODO: make sure any arbitrary spaces are handled
371-
describe.skip("when it's missing spaces and is ugly", () => {
372-
/* TODO: implement */
373-
})
416+
// TODO: implement (make sure any arbitrary spaces are handled)
417+
// describe("when it's missing spaces and is ugly", () => {
418+
// })
374419

375420
describe("when it's alone on a line", () => {
376421
describe("when NO selection", () => {
@@ -440,9 +485,9 @@ describe("single line jsdoc comment", () => {
440485
)
441486
)
442487
})
443-
describe.skip("when selection", () => {
444-
/* TODO: implement */
445-
})
488+
// TODO: implement
489+
// describe("when selection", () => {
490+
// })
446491
})
447492

448493
describe("when it's at start of a line", () => {
@@ -458,15 +503,14 @@ describe("single line jsdoc comment", () => {
458503
)
459504
)
460505

461-
// TODO: needs new file
462-
describe.skip(
463-
"when cursor is before comment",
506+
describe(
507+
"when cursor is just before comment tag",
464508
itHasCorrectOutputAndCursorPosition(
465509
"singleConvertLineStart.js",
466-
2,
467-
1,
468510
0,
469-
4
511+
0,
512+
0,
513+
3
470514
)
471515
)
472516

@@ -514,9 +558,9 @@ describe("single line jsdoc comment", () => {
514558
)
515559
)
516560
})
517-
describe.skip("when selection", () => {
518-
/* TODO: implement */
519-
})
561+
// TODO: implement
562+
// describe("when selection", () => {
563+
// })
520564
})
521565

522566
describe("when it's nested in JSDoc", () => {
@@ -542,7 +586,7 @@ describe("single line jsdoc comment", () => {
542586
-1
543587
)
544588
)
545-
// TODO: rm extra space
589+
// FIXME: rm extra space
546590
describe(
547591
"when a star proceeds it",
548592
itHasCorrectOutputAndCursorPosition(
@@ -557,11 +601,10 @@ describe("single line jsdoc comment", () => {
557601

558602
describe("when it's trailing code", () => {
559603
describe("when NO selection", () => {
560-
// FIXME: create new tag
561-
describe.skip(
604+
describe(
562605
"when cursor is before comment",
563606
itHasCorrectOutputAndCursorPosition(
564-
"singleConvertLineTrailing.js",
607+
"singleConvertLineTrailingB.js",
565608
2,
566609
6,
567610
0,
@@ -578,10 +621,64 @@ describe("single line jsdoc comment", () => {
578621
-12
579622
)
580623
)
624+
// REVIEW: should this leave cursor just before comment tag instead of moving inside jsdoc?
625+
// FIXME: creates new comment instead of converting
626+
describe.skip(
627+
"when cursor is just before comment tag",
628+
itHasCorrectOutputAndCursorPosition(
629+
"singleConvertLineTrailing.js",
630+
2,
631+
15,
632+
0,
633+
-9
634+
)
635+
)
636+
// FIXME: doesn't get rid of comment tag
637+
describe.skip(
638+
"when cursor is inside comment tag",
639+
itHasCorrectOutputAndCursorPosition(
640+
"singleConvertLineTrailing.js",
641+
2,
642+
16,
643+
0,
644+
-10
645+
)
646+
)
647+
// FIXME: adds an extra space between jsdoc start and comment
648+
describe.skip(
649+
"when cursor is just after comment tag before a space",
650+
itHasCorrectOutputAndCursorPosition(
651+
"singleConvertLineTrailing.js",
652+
2,
653+
17,
654+
0,
655+
-11
656+
)
657+
)
658+
describe(
659+
"when cursor is just after space after comment tag",
660+
itHasCorrectOutputAndCursorPosition(
661+
"singleConvertLineTrailing.js",
662+
2,
663+
18,
664+
0,
665+
-12
666+
)
667+
)
668+
describe(
669+
"when cursor is at end of line comment",
670+
itHasCorrectOutputAndCursorPosition(
671+
"singleConvertLineTrailing.js",
672+
2,
673+
40,
674+
0,
675+
-12
676+
)
677+
)
581678
})
582-
describe.skip("when selection", () => {
583-
/* TODO: implement */
584-
})
679+
// TODO: implement
680+
// describe("when selection", () => {
681+
// })
585682
})
586683
})
587684

@@ -651,7 +748,7 @@ describe("single line jsdoc comment", () => {
651748
-10
652749
)
653750
)
654-
// TODO: doesn't add space afterward
751+
// FIXME: doesn't add space afterward
655752
describe.skip(
656753
"when it's missing spaces and ugly",
657754
itHasCorrectOutputAndCursorPosition(

test/suite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const run = (
1919
color: true,
2020
inlineDiffs: true,
2121
bail: DEBUG_TESTS,
22-
timeout: 8000,
22+
timeout: 10000, // bumped up so startup doesn't fail first test
2323
})
2424

2525
const scratchpadUri = path.join(

0 commit comments

Comments
 (0)