diff --git a/test.js b/test.js index c8aa38f..e87b177 100644 --- a/test.js +++ b/test.js @@ -6,56 +6,62 @@ var french = require('./fr') var english = require('.') test('profanities', function(t) { - t.plan(12) - retext() .use(english) .process('Shit!', function(err, file) { - t.deepEqual([err].concat(file.messages), [ - null, - { - message: 'Don’t use “Shit”, it’s profane', - name: '1:1-1:5', - reason: 'Don’t use “Shit”, it’s profane', - line: 1, - column: 1, - location: { - start: {line: 1, column: 1, offset: 0}, - end: {line: 1, column: 5, offset: 4} - }, - source: 'retext-profanities', - ruleId: 'shit', - fatal: false, - profanitySeverity: 2, - actual: 'Shit', - expected: null - } - ]) + t.deepEqual( + [err].concat(file.messages), + [ + null, + { + message: 'Don’t use “Shit”, it’s profane', + name: '1:1-1:5', + reason: 'Don’t use “Shit”, it’s profane', + line: 1, + column: 1, + location: { + start: {line: 1, column: 1, offset: 0}, + end: {line: 1, column: 5, offset: 4} + }, + source: 'retext-profanities', + ruleId: 'shit', + fatal: false, + profanitySeverity: 2, + actual: 'Shit', + expected: null + } + ], + 'should warn' + ) }) retext() .use(french) .process('Merde!', function(err, file) { - t.deepEqual([err].concat(file.messages), [ - null, - { - message: 'Don’t use “Merde”, it’s profane', - name: '1:1-1:6', - reason: 'Don’t use “Merde”, it’s profane', - line: 1, - column: 1, - location: { - start: {line: 1, column: 1, offset: 0}, - end: {line: 1, column: 6, offset: 5} - }, - source: 'retext-profanities-fr', - ruleId: 'merde', - fatal: false, - profanitySeverity: 2, - actual: 'Merde', - expected: null - } - ]) + t.deepEqual( + [err].concat(file.messages), + [ + null, + { + message: 'Don’t use “Merde”, it’s profane', + name: '1:1-1:6', + reason: 'Don’t use “Merde”, it’s profane', + line: 1, + column: 1, + location: { + start: {line: 1, column: 1, offset: 0}, + end: {line: 1, column: 6, offset: 5} + }, + source: 'retext-profanities-fr', + ruleId: 'merde', + fatal: false, + profanitySeverity: 2, + actual: 'Merde', + expected: null + } + ], + 'should support other languages' + ) }) retext() @@ -67,11 +73,10 @@ test('profanities', function(t) { 'The kidnapper was the mother, an addict.' ].join('\n'), function(err, file) { - t.ifError(err, 'should not fail (#1)') - t.deepEqual( - file.messages.map(String), + [err].concat(file.messages.map(String)), [ + null, '1:33-1:37: Be careful with “butt”, it’s profane in some cases', '2:9-2:15: Don’t use “asshat”, it’s profane', '3:34-3:40: Reconsider using “addict”, it may be profane' @@ -86,11 +91,9 @@ test('profanities', function(t) { .process( ['He’s pretty set on beating your butt for sheriff.'].join('\n'), function(err, file) { - t.ifError(err, 'should not fail (#2)') - t.deepEqual( - file.messages.map(String), - [], + [err].concat(file.messages.map(String)), + [null], 'should not warn for `ignore`d phrases' ) } @@ -101,11 +104,12 @@ test('profanities', function(t) { .process( ['When he’ll freeze over, hell freezes over.'].join('\n'), function(err, file) { - t.ifError(err, 'should not fail (#3)') - t.deepEqual( - file.messages.map(String), - ['1:25-1:29: Be careful with “hell”, it’s profane in some cases'], + [err].concat(file.messages.map(String)), + [ + null, + '1:25-1:29: Be careful with “hell”, it’s profane in some cases' + ], 'should correctly depend on apostrophes' ) } @@ -114,20 +118,15 @@ test('profanities', function(t) { retext() .use(english) .process('slave slaves', function(err, file) { - t.deepEqual([err].concat(file.messages.map(String)), [ - null, - '1:1-1:6: Don’t use “slave”, it’s profane', - '1:7-1:13: Don’t use “slaves”, it’s profane' - ]) - }) - - retext() - .use(french) - .process('Euh, merde!', function(err, file) { - t.deepEqual([err].concat(file.messages.map(String)), [ - null, - '1:6-1:11: Don’t use “merde”, it’s profane' - ]) + t.deepEqual( + [err].concat(file.messages.map(String)), + [ + null, + '1:1-1:6: Don’t use “slave”, it’s profane', + '1:7-1:13: Don’t use “slaves”, it’s profane' + ], + 'should support plurals and singulars' + ) }) retext() @@ -139,11 +138,10 @@ test('profanities', function(t) { 'The kidnapper was the mother, an addict.' ].join('\n'), function(err, file) { - t.ifError(err, 'should not fail (#1)') - t.deepEqual( - file.messages.map(String), + [err].concat(file.messages.map(String)), [ + null, '2:9-2:15: Don’t use “asshat”, it’s profane', '3:34-3:40: Reconsider using “addict”, it may be profane' ], @@ -151,4 +149,6 @@ test('profanities', function(t) { ) } ) + + t.end() })