Tom MacWright 25152edeb9 style(prettier): Use prettier for code formatting (#710)
* style(prettier): Use prettier for code formatting

This saves us style issues. Also adds husky and lint-staged for pre-commit testing

Refs https://github.com/documentationjs/documentation/issues/709
2017-04-10 14:25:45 -04:00

91 lines
1.5 KiB
JavaScript

'use strict';
var test = require('tap').test, walk = require('../../lib/walk');
test('walk', function(group) {
group.test('flat comments', function(t) {
var comments = [{ name: 'Tom' }];
function renamer(comment, options) {
if (options) {
comment.name = options.name;
} else {
comment.name = 'Tim';
}
}
t.deepEqual(walk(comments, renamer), [{ name: 'Tim' }], 'no-option case');
t.deepEqual(
walk(comments, renamer, { name: 'John' }),
[{ name: 'John' }],
'with options'
);
t.end();
});
group.test('nested comments', function(t) {
var comments = [
{
name: 'Tom',
members: {
static: [
{
name: 'Billy'
}
]
}
}
];
function renamer(comment, options) {
if (options) {
comment.name = options.name;
} else {
comment.name = 'Tim';
}
}
t.deepEqual(
walk(comments, renamer),
[
{
name: 'Tim',
members: {
static: [
{
name: 'Tim'
}
]
}
}
],
'no-option case'
);
t.deepEqual(
walk(comments, renamer, {
name: 'Bob'
}),
[
{
name: 'Bob',
members: {
static: [
{
name: 'Bob'
}
]
}
}
],
'with options'
);
t.end();
});
group.end();
});