mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-18 22:29:56 +01:00
3c8134184b
Enables the same `no-unexternalized-strings` with have in `vscode` in this repo. This make sure we have a more consistent style across repos and when generating edits
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import { expect, suite, test } from 'vitest';
|
|
import { validateDocstringFormat } from '../slashDoc.py.stest';
|
|
|
|
suite('hasCorrectlyFormattedDocstring Tests', function () {
|
|
|
|
test('Correctly formatted docstring', function () {
|
|
const fileContents = `
|
|
def my_function(param1, param2):
|
|
"""
|
|
This is a docstring for my_function.
|
|
"""
|
|
pass
|
|
`;
|
|
const targetLineString = 'def my_function(param1, param2):';
|
|
validateDocstringFormat(fileContents, targetLineString);
|
|
});
|
|
|
|
test('error: not indented', function () {
|
|
const fileContents = `
|
|
def my_function(param1, param2):
|
|
"""
|
|
This is a wrongly indented docstring for my_function.
|
|
"""
|
|
pass
|
|
`;
|
|
const targetLineString = 'def my_function(param1, param2):';
|
|
expect(() => validateDocstringFormat(fileContents, targetLineString)).toThrowErrorMatchingInlineSnapshot(`[Error: Incorrect docstring indentation. Expected: ' ', but got: '']`);
|
|
});
|
|
|
|
test('error: no docstring', function () {
|
|
const fileContents = `
|
|
def my_function(param1, param2):
|
|
pass
|
|
`;
|
|
const targetLineString = 'def my_function(param1, param2):';
|
|
expect(() => validateDocstringFormat(fileContents, targetLineString)).toThrowErrorMatchingInlineSnapshot(`[Error: No docstring found after the target line.]`);
|
|
});
|
|
|
|
test('Docstring with correct indentation using tabs', function () {
|
|
const fileContents = `
|
|
def my_function(param1, param2):
|
|
"""
|
|
This is a docstring for my_function with tabs.
|
|
"""
|
|
`;
|
|
const targetLineString = 'def my_function(param1, param2):';
|
|
expect(() => validateDocstringFormat(fileContents, targetLineString)).toThrowErrorMatchingInlineSnapshot(`[Error: Incorrect docstring indentation. Expected: ' ········', but got: '········']`);
|
|
});
|
|
|
|
});
|