Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
test - add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman committed Jul 30, 2020
1 parent dff506e commit bdabc72
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion client/src/commandHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';
import { TypeDefinitionRequest } from 'vscode-languageclient';

export async function exportArchive(file: vscode.Uri) {
try {
Expand All @@ -26,11 +27,14 @@ export async function exportArchive(file: vscode.Uri) {
const archive = await template.toArchive('cicero');
const outputPath = path.join(file.path, `${template.getIdentifier()}.cta`);
fs.writeFileSync(outputPath, archive);
vscode.window.showInformationMessage(`Created archive ${outputPath}`);
vscode.window.showInformationMessage(`Created archive ${outputPath}`);
return true;
}
catch(error) {
vscode.window.showErrorMessage(`Error ${error}`);
}

return false;
}

export async function downloadModels(file: vscode.Uri) {
Expand All @@ -42,8 +46,11 @@ export async function downloadModels(file: vscode.Uri) {
const outputPath = path.join(file.path, 'model');
template.getModelManager().writeModelsToFileSystem(outputPath);
vscode.window.showInformationMessage(`Downloaded models to ${outputPath}`);
return true;
}
catch(error) {
vscode.window.showErrorMessage(`Error ${error}`);
}

return false;
}
14 changes: 8 additions & 6 deletions client/src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ suite('Extension Tests', () => {
workspace.openTextDocument(uri).then((document) => {
assert.equal(document.languageId, 'ergo');
assert.ok(document.lineCount === 41);

});
});

Expand All @@ -38,7 +37,6 @@ suite('Extension Tests', () => {
workspace.openTextDocument(uri).then((document) => {
assert.equal(document.languageId, 'concerto');
assert.ok(document.lineCount === 5);

});
});

Expand All @@ -48,18 +46,22 @@ suite('Extension Tests', () => {
workspace.openTextDocument(uri).then((document) => {
assert.equal(document.languageId, 'ciceroMark');
assert.ok(document.lineCount === 4);

});
});

test('should execute exportArchive command', () => {
const uri = vscode.Uri.file(path.join(rootPath, '../test/data/valid/template/acceptance-of-delivery'));
return vscode.commands.executeCommand('cicero-vscode-extension.exportArchive', uri);

vscode.commands.executeCommand('cicero-vscode-extension.exportArchive', uri).then((result) => {
assert.ok(result);
});
});

test('should execute downloadModels command', () => {
const uri = vscode.Uri.file(path.join(rootPath, '../test/data/valid/template/acceptance-of-delivery'));
return vscode.commands.executeCommand('cicero-vscode-extension.downloadModels', uri);
});

vscode.commands.executeCommand('cicero-vscode-extension.downloadModels', uri).then((result) => {
assert.ok(result);
});
});
});
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bdabc72

Please sign in to comment.