Skip to content

Commit

Permalink
test(plugin): add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alecxe committed Jun 29, 2016
1 parent 935d0e6 commit a1664e9
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"standard": {
"globals": ["describe", "it", "before"]
},
"keywords": [
"eslint",
"eslint-plugin",
Expand All @@ -38,6 +41,7 @@
"eslint": "^2.0.0"
},
"devDependencies": {
"chai": "^3.5.0",
"commitizen": "^2.8.1",
"coveralls": "^2.11.9",
"cz-conventional-changelog": "^1.1.6",
Expand Down
77 changes: 77 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'use strict'

var expect = require('chai').expect
var fs = require('fs')
var path = require('path')
var baseDir = path.join(__dirname, '../')
var rulesDir = path.join(__dirname, '../lib/rules/')
var documentationPath = 'docs/rules/'
var documentationDir = path.join(__dirname, '../', documentationPath)
var plugin = require('..')

describe('eslint-plugin-protractor', function () {
var ruleFiles

before(function (done) {
fs.readdir(rulesDir, function (error, files) {
ruleFiles = files
done(error)
})
})

it('should expose all rules', function () {
ruleFiles.forEach(function (file) {
var ruleName = path.basename(file, '.js')

expect(plugin).to.have.deep.property('rules.' + ruleName)
.that.equals(require(rulesDir + ruleName))
})
})

it('should expose recommended configuration for all rules', function () {
ruleFiles.forEach(function (file) {
var ruleName = path.basename(file, '.js')

expect(plugin).to.have.deep.property('configs.recommended.rules').that.has.property('protractor/' + ruleName)
})
})

describe('documentation', function () {
var documentationFiles
var documentationIndex

before(function (done) {
fs.readdir(documentationDir, function (readDirError, files) {
if (readDirError) {
done(readDirError)
return
}

documentationFiles = files

fs.readFile(baseDir + 'README.md', function (error, data) {
documentationIndex = data.toString()
done(error)
})
})
})

it('should have each rule documented', function () {
ruleFiles.forEach(function (file) {
var ruleName = path.basename(file, '.js')
var expectedDocumentationFileName = ruleName + '.md'

expect(documentationFiles).to.contain(expectedDocumentationFileName)
})
})

it('should be linked in the documenation index', function () {
documentationFiles.forEach(function (file) {
var ruleName = path.basename(file, '.md')
var expectedLink = '[' + ruleName + ']: ' + documentationPath + file

expect(documentationIndex).to.contain(expectedLink)
})
})
})
})

0 comments on commit a1664e9

Please sign in to comment.