Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ CONTRIBUTING.md
**/**.vsix
**/**.tar.gz
test-resources
!node_modules/prettier/index.js
!node_modules/prettier/third-party.js
!node_modules/prettier/parser-yaml.js
29 changes: 29 additions & 0 deletions smoke-test/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ suite('Smoke test suite', function () {

const SCHEMA_INSTANCE_NAME = 'references-schema.yaml';
const THROUGH_SETTINGS_NAME = 'references-schema-settings.yaml';
const UNFORMATTED_NAME = 'unformatted.yaml';

let schemaInstanceUri: URI;
let throughSettingsUri: URI;
let unformattedUri: URI;

this.beforeAll(async function () {
const workspaceUri = vscode.workspace.workspaceFolders[0].uri;
Expand All @@ -22,6 +24,9 @@ suite('Smoke test suite', function () {
throughSettingsUri = workspaceUri.with({
path: workspaceUri.path + (workspaceUri.path.endsWith('/') ? '' : '/') + THROUGH_SETTINGS_NAME,
});
unformattedUri = workspaceUri.with({
path: workspaceUri.path + (workspaceUri.path.endsWith('/') ? '' : '/') + UNFORMATTED_NAME,
});
});

test('instance has right diagnostics', async function () {
Expand All @@ -43,4 +48,28 @@ suite('Smoke test suite', function () {
assert.strictEqual(diagnostics.length, 1);
assert.strictEqual(diagnostics[0].message, 'Value is below the minimum of 0.');
});

test('has right formatting', async function () {
const textDocument = await vscode.workspace.openTextDocument(unformattedUri);
await vscode.window.showTextDocument(textDocument);

// heavily borrowed from prettier's test suite
const edits = await vscode.commands.executeCommand<vscode.TextEdit[]>(
'vscode.executeFormatDocumentProvider',
textDocument.uri,
{ tabSize: 2, insertSpaces: true }
);

if (edits && edits.length > 0) {
const workspaceEdit = new vscode.WorkspaceEdit();
workspaceEdit.set(textDocument.uri, edits);
await vscode.workspace.applyEdit(workspaceEdit);
}

const EXPECTED = `aaa:
bbb: hjkl
`;

assert.strictEqual(textDocument.getText(), EXPECTED);
});
});
2 changes: 2 additions & 0 deletions smoke-test/unformatted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aaa:
bbb: hjkl
2 changes: 0 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const config = {
devtool: 'source-map',
externals: {
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
prettier: 'commonjs prettier',
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
Expand Down Expand Up @@ -136,7 +135,6 @@ const serverWeb = {
mainFields: ['browser', 'module', 'main'],
extensions: ['.ts', '.js'], // support ts-files and js-files
alias: {
'./services/yamlFormatter': path.resolve(__dirname, './build/polyfills/yamlFormatter.js'), // not supported for now. prettier can run in the web, but it's a bit more work.
'vscode-json-languageservice/lib/umd': 'vscode-json-languageservice/lib/esm',
},
fallback: {
Expand Down
Loading