Skip to content

Commit

Permalink
add an initial integration test
Browse files Browse the repository at this point in the history
It at least prevents this extension from being entirely corrupted.
  • Loading branch information
shinnn committed Mar 1, 2018
1 parent a70d674 commit f470e38
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode-test
node_modules
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
git:
depth: 1
branches:
except: /^v\d/
language: node_js
node_js: node
before_install: npm install --global npm@next
matrix:
include:
- script: eval xvfb-run `jq --raw-output .scripts.test < package.json`
- os: osx
osx_image: xcode9.3beta
branches:
except: /^v\d/
20 changes: 11 additions & 9 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.editorconfig
.gitignore
.vscode/**
*.css
*.png
*.scss
*.less
media/*.ai
test
.editorconfig
.gitignore
.vscode
.vscode-test
*.css
*.less
*.png
*.scss
*.yml
media/*.ai
test
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
]
},
"scripts": {
"test": "eslint --fix --format=codeframe index.js server.js"
"pretest": "eslint --fix --format=codeframe .",
"test": "node node_modules/vscode/bin/test"
},
"dependencies": {
"stylelint-vscode": "^6.1.0",
Expand All @@ -89,6 +90,7 @@
"devDependencies": {
"@shinnn/eslint-config-node": "^5.0.0",
"eslint": "^4.18.1",
"tape": "^4.9.0",
"vscode": "^1.1.10"
},
"eslintConfig": {
Expand Down
42 changes: 42 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable node/no-unpublished-require */
'use strict';

const test = require('tape');
const {extensions, workspace, window} = require('vscode');

const run = () => test('vscode-stylelint', async t => {
const vscodeStylelint = extensions.getExtension('shinnn.stylelint');

const plaintextDocument = await workspace.openTextDocument({
content: 'Hello',
language: 'plaintext'
});

await window.showTextDocument(plaintextDocument);

t.equal(
vscodeStylelint.isActive,
false,
'should not be activated when the open file is not CSS.'
);

const cssDocument = await workspace.openTextDocument({
content: '}',
language: 'css'
});

await window.showTextDocument(cssDocument);

t.equal(
vscodeStylelint.isActive,
true,
'should be activated when the open file is CSS.'
);

t.end();
});

exports.run = (root, done) => {
test.onFinish(done);
run();
};

0 comments on commit f470e38

Please sign in to comment.