Skip to content

Commit 6268306

Browse files
committed
fixed hover tests
1 parent 6a7a3f3 commit 6268306

1 file changed

Lines changed: 57 additions & 33 deletions

File tree

src/test/extension.autocomplete.test.ts

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,8 @@ suite('Hover Definition', () => {
234234
assert.equal(def.length, 1, 'Definition length is incorrect');
235235
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '30,4', 'Start position is incorrect');
236236
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '30,11', 'End position is incorrect');
237-
assert.equal(def[0].contents.length, 2, 'Invalid content items');
238-
assert.equal(def[0].contents[0]['value'], 'def method1()', 'function signature incorrect');
239-
assert.equal(def[0].contents[1], `This is method1`, 'Invalid conents');
237+
assert.equal(def[0].contents.length, 1, 'Invalid content items');
238+
assert.equal(def[0].contents[0], '```python' + EOL + 'def method1()' + EOL + '```' + EOL + 'This is method1', 'function signature incorrect');
240239
}).then(done, done);
241240
});
242241

@@ -255,8 +254,7 @@ suite('Hover Definition', () => {
255254
assert.equal(def.length, 1, 'Definition length is incorrect');
256255
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '1,9', 'Start position is incorrect');
257256
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '1,12', 'End position is incorrect');
258-
assert.equal(def[0].contents[0]['value'], 'def fun()', 'function signature incorrect');
259-
assert.equal(def[0].contents[1], `This is fun`, 'Invalid conents');
257+
assert.equal(def[0].contents[0], '```python' + EOL + 'def fun()' + EOL + '```' + EOL + 'This is fun', 'Invalid conents');
260258
}).then(done, done);
261259
});
262260

@@ -275,9 +273,9 @@ suite('Hover Definition', () => {
275273
assert.equal(def.length, 1, 'Definition length is incorrect');
276274
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '25,4', 'Start position is incorrect');
277275
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '25,7', 'End position is incorrect');
278-
assert.equal(def[0].contents[0]['value'], 'def bar()', 'function signature incorrect');
279-
const documentation = `说明 - keep this line, it works${EOL}delete following line, it works${EOL}如果存在需要等待审批或正在执行的任务,将不刷新页面`;
280-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
276+
assert.equal(def[0].contents[0], '```python' + EOL + 'def bar()' + EOL + '```' + EOL +
277+
'说明 - keep this line, it works' + EOL + 'delete following line, it works' +
278+
EOL + '如果存在需要等待审批或正在执行的任务,将不刷新页面', 'Invalid conents');
281279
}).then(done, done);
282280
});
283281

@@ -296,9 +294,11 @@ suite('Hover Definition', () => {
296294
assert.equal(def.length, 1, 'Definition length is incorrect');
297295
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '1,5', 'Start position is incorrect');
298296
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '1,16', 'End position is incorrect');
299-
assert.equal(def[0].contents[0]['value'], 'def showMessage()', 'Invalid content items');
300-
const documentation = `Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи. ${EOL}Шэа декам экшырки эи, эи зыд эррэм докэндё, векж факэтэ пэрчыквюэрёж ку.`;
301-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
297+
assert.equal(def[0].contents[0], '```python' + EOL +
298+
'def showMessage()' + EOL +
299+
'```' + EOL +
300+
'Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи. ' + EOL +
301+
'Шэа декам экшырки эи, эи зыд эррэм докэндё, векж факэтэ пэрчыквюэрёж ку.', 'Invalid conents');
302302
}).then(done, done);
303303
});
304304

@@ -349,17 +349,21 @@ suite('Hover Definition', () => {
349349
assert.equal(def.length, 1, 'Definition length is incorrect');
350350
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '11,12', 'Start position is incorrect');
351351
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '11,18', 'End position is incorrect');
352-
assert.equal(def[0].contents[0]['value'], 'class Random(x=None)', 'Invalid content items');
353-
const documentation = `Random number generator base class used by bound module functions.${EOL}${EOL}` +
354-
`Used to instantiate instances of Random to get generators that don't${EOL}` +
355-
`share state.${EOL}${EOL}` +
356-
`Class Random can also be subclassed if you want to use a different basic${EOL}` +
357-
`generator of your own devising: in that case, override the following${EOL}` +
358-
`methods: random(), seed(), getstate(), and setstate().${EOL}` +
359-
`Optionally, implement a getrandbits() method so that randrange()${EOL}` +
360-
`can cover arbitrarily large ranges.`;
352+
let documentation = "```python" + EOL +
353+
"class Random(x=None)" + EOL +
354+
"```" + EOL +
355+
"Random number generator base class used by bound module functions." + EOL +
356+
"" + EOL +
357+
"Used to instantiate instances of Random to get generators that don't" + EOL +
358+
"share state." + EOL +
359+
"" + EOL +
360+
"Class Random can also be subclassed if you want to use a different basic" + EOL +
361+
"generator of your own devising: in that case, override the following" + EOL +
362+
"methods: random(), seed(), getstate(), and setstate()." + EOL +
363+
"Optionally, implement a getrandbits() method so that randrange()" + EOL +
364+
"can cover arbitrarily large ranges.";
361365

362-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
366+
assert.equal(def[0].contents[0], documentation, 'Invalid conents');
363367
}).then(done, done);
364368
});
365369

@@ -378,9 +382,10 @@ suite('Hover Definition', () => {
378382
assert.equal(def.length, 1, 'Definition length is incorrect');
379383
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '12,5', 'Start position is incorrect');
380384
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '12,12', 'End position is incorrect');
381-
assert.equal(def[0].contents[0]['value'], 'def randint(a, b)', 'Invalid content items');
382-
const documentation = `Return random integer in range [a, b], including both end points.`;
383-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
385+
assert.equal(def[0].contents[0], '```python' + EOL +
386+
'def randint(a, b)' + EOL +
387+
'```' + EOL +
388+
'Return random integer in range [a, b], including both end points.', 'Invalid conents');
384389
}).then(done, done);
385390
});
386391

@@ -399,9 +404,10 @@ suite('Hover Definition', () => {
399404
assert.equal(def.length, 1, 'Definition length is incorrect');
400405
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '8,11', 'Start position is incorrect');
401406
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '8,15', 'End position is incorrect');
402-
assert.equal(def[0].contents[0]['value'], 'def acos(x)', 'Invalid content items');
403-
const documentation = `acos(x)${EOL}${EOL}Return the arc cosine (measured in radians) of x.`;
404-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
407+
assert.equal(def[0].contents[0], '```python' + EOL +
408+
'def acos(x)' + EOL +
409+
'```' + EOL +
410+
'Return the arc cosine (measured in radians) of x.', 'Invalid conents');
405411
}).then(done, done);
406412
});
407413

@@ -420,10 +426,15 @@ suite('Hover Definition', () => {
420426
assert.equal(def.length, 1, 'Definition length is incorrect');
421427
assert.equal(`${def[0].range.start.line},${def[0].range.start.character}`, '14,9', 'Start position is incorrect');
422428
assert.equal(`${def[0].range.end.line},${def[0].range.end.character}`, '14,15', 'End position is incorrect');
423-
const signature = `class Thread(group=None, target=None, name=None, args=(), kwargs=None, verbose=None)`;
424-
assert.equal(def[0].contents[0]['value'], signature, 'Invalid content items');
425-
const documentation = `A class that represents a thread of control.${EOL}${EOL}This class can be safely subclassed in a limited fashion.`;
426-
assert.equal(def[0].contents[1], documentation, 'Invalid conents');
429+
assert.equal(def[0].contents[0], '```python' + EOL +
430+
'class Thread(group=None, target=None, name=None, args=(), kwargs=None, verbose=None)' + EOL +
431+
'```' + EOL +
432+
'Thread(self, group=None, target=None, name=None,' + EOL +
433+
'args=(), kwargs=None, verbose=None)' + EOL +
434+
'' + EOL +
435+
'A class that represents a thread of control.' + EOL +
436+
'' + EOL +
437+
'This class can be safely subclassed in a limited fashion.', 'Invalid content items');
427438
}).then(done, done);
428439
});
429440

@@ -441,8 +452,21 @@ suite('Hover Definition', () => {
441452
}).then(def => {
442453
assert.equal(def.length, 1, 'Definition length is incorrect');
443454
assert.equal(def[0].contents.length, 1, 'Only expected one result');
444-
const signature = 'Random';
445-
assert.equal(def[0].contents[0]['value'], signature, 'Invalid content items');
455+
assert.equal(def[0].contents[0], '```python' + EOL +
456+
'Random' + EOL +
457+
'```' + EOL +
458+
'Random(self, x=None)' + EOL +
459+
EOL +
460+
'Random number generator base class used by bound module functions.' + EOL +
461+
EOL +
462+
"Used to instantiate instances of Random to get generators that don't" + EOL +
463+
'share state.' + EOL +
464+
EOL +
465+
'Class Random can also be subclassed if you want to use a different basic' + EOL +
466+
'generator of your own devising: in that case, override the following' + EOL +
467+
'methods: random(), seed(), getstate(), and setstate().' + EOL +
468+
'Optionally, implement a getrandbits() method so that randrange()' + EOL +
469+
'can cover arbitrarily large ranges.', 'Invalid content items');
446470
}).then(done, done);
447471
});
448472
});

0 commit comments

Comments
 (0)