Skip to content

Commit

Permalink
Add more tests for extension
Browse files Browse the repository at this point in the history
  • Loading branch information
timonwong committed May 9, 2018
1 parent 34063a5 commit 93f57d4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .vscodeignore
Expand Up @@ -8,3 +8,5 @@ scripts/**
.gitignore
tsconfig.json
tslint.json
.editorconfig
.travis.yml
33 changes: 25 additions & 8 deletions test/extension.test.ts
Expand Up @@ -9,13 +9,30 @@ import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
import * as myExtension from '../src/extension';

// Defines a Mocha test suite to group tests of similar kind together
suite('Extension Tests', () => {
// Defines a Mocha unit test
test('Something 1', () => {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));


suite('Shellcheck extension', () => {
const ext = vscode.extensions.getExtension('timonwong.shellcheck');

test('Extension should not be activated', async () => {
const plaintextDocument = await vscode.workspace.openTextDocument({
content: 'hello',
language: 'plaintext',
});

await vscode.window.showTextDocument(plaintextDocument);

assert.equal(ext.isActive, false, 'should not be activated when file type is not shell script.');
});

test('Extension should be activated on shell script files', async () => {
const shellscriptDocument = await vscode.workspace.openTextDocument({
content: '#!/bin/bash\n',
language: 'shellscript',
});

await vscode.window.showTextDocument(shellscriptDocument);

assert.equal(ext.isActive, true, 'should be activated when file type is shellscript.');
});
});

0 comments on commit 93f57d4

Please sign in to comment.