Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add worker to subsystems and add subsystems tests #42

Merged
merged 2 commits into from
Jan 11, 2019
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
1 change: 1 addition & 0 deletions lib/rules/subsystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const validSubsystems = [
, 'util'
, 'v8'
, 'vm'
, 'worker'
, 'zlib'
]

Expand Down
65 changes: 65 additions & 0 deletions test/rules/subsystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict'

const test = require('tap').test
const Rule = require('../../lib/rules/subsystem')
const Commit = require('gitlint-parser-node')
const Validator = require('../../')

test('rule: subsystem', (t) => {
t.test('invalid', (tt) => {
tt.plan(7)
const v = new Validator()
const context = new Commit({
sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea'
, author: {
name: 'Evan Lucas'
, email: 'evanlucas@me.com'
, date: '2016-04-12T19:42:23Z'
}
, message: 'fhqwhgads: come on'
}, v)

context.report = (opts) => {
tt.pass('called report')
tt.equal(opts.id, 'subsystem', 'id')
tt.equal(opts.message, 'Invalid subsystem: "fhqwhgads"', 'message')
tt.equal(opts.string, 'fhqwhgads: come on', 'string')
tt.equal(opts.line, 0, 'line')
tt.equal(opts.column, 0, 'column')
tt.equal(opts.level, 'fail', 'level')
tt.end()
}

Rule.validate(context, {options: {subsystems: Rule.defaults.subsystems}})
})

t.test('valid', (tt) => {
tt.plan(2)

const v = new Validator()
const context = new Commit({
sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea'
, author: {
name: 'Evan Lucas'
, email: 'evanlucas@me.com'
, date: '2016-04-12T19:42:23Z'
}
, message: 'worker: come on, fhqwhgads'
}, v)

context.report = (opts) => {
tt.pass('called report')
tt.strictSame(opts, {
id: 'subsystem'
, message: 'valid subsystems'
, string: 'worker'
, level: 'pass'
})
tt.end()
}

Rule.validate(context, {options: {subsystems: Rule.defaults.subsystems}})
})

t.end()
})