Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
…and simplify & improve performance of tests
  • Loading branch information
wooorm committed Jan 24, 2020
1 parent 3629145 commit 0cc5502
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 219 deletions.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repository": "https://github.com/get-alex/alex",
"bugs": "https://github.com/get-alex/alex/issues",
"funding": {
"url": "https://github.com/sponsors/wooorm"
},
"url": "https://github.com/sponsors/wooorm"
},
"homepage": "https://alexjs.com",
"keywords": [
"cli-app",
Expand Down Expand Up @@ -75,13 +75,12 @@
"vfile-sort": "^2.0.0"
},
"devDependencies": {
"ava": "^2.0.0",
"browserify": "^16.0.0",
"execa": "^3.0.0",
"nyc": "^14.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.25.0"
},
Expand All @@ -90,8 +89,8 @@
"build-bundle": "browserify . -s alex -o alex.js",
"build-mangle": "browserify . -s alex -p tinyify -o alex.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "ava",
"test-coverage": "nyc --reporter lcov ava",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test/index.js",
"test": "npm run format && npm run build && npm run test-coverage"
},
"alex": {
Expand Down
111 changes: 54 additions & 57 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

var fs = require('fs')
var path = require('path')
var test = require('ava')
var test = require('tape')
var alex = require('..')

var html = fs.readFileSync(path.join(__dirname, 'fixtures', 'three.html'))

// Tests. Note that these are small because alex is in fact
// just a collection of well-tested modules.
// See `retextjs/retext-equality` for the gist of what
Expand All @@ -29,35 +31,32 @@ test('alex()', function(t) {
'3:10-3:17: `cripple` may be insensitive, use `person with a ' +
'limp` instead',
'5:36-5:40: Be careful with `butt`, it’s profane in some cases'
]
],
'should work'
)
})

test('alex() with an allow array', function(t) {
var messages = alex('Eric is pretty set on beating your butt for sheriff.', [
'butt'
]).messages

t.is(messages.length, 0)
})
t.deepEqual(
alex('Eric is pretty set on beating your butt for sheriff.', ['butt'])
.messages,
[],
'should work with an allow array'
)

test('alex() with profantity config', function(t) {
var messages = alex(
'Eric, the asshat, is pretty set on beating your butt for sheriff.',
{
t.deepEqual(
alex('Eric, the asshat, is pretty set on beating your butt for sheriff.', {
allow: ['asshat'],
profanitySureness: 1
}
).messages

t.is(messages.length, 0, 'We dont expect any messages')
})
}).messages,
[],
'should work with profantity config'
)

test('alex.markdown()', function(t) {
t.deepEqual(alex.markdown('The `boogeyman`.').messages.map(String), [])
})
t.deepEqual(
alex.markdown('The `boogeyman`.').messages.map(String),
[],
'alex.markdown()'
)

test('alex.text()', function(t) {
t.deepEqual(
alex
.text(
Expand All @@ -70,11 +69,10 @@ test('alex.text()', function(t) {
[
'1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead',
'2:36-2:40: Be careful with `butt`, it’s profane in some cases'
]
],
'alex.text()'
)
})

test('alex.text() with allow config', function(t) {
t.deepEqual(
alex
.text(
Expand All @@ -85,11 +83,10 @@ test('alex.text() with allow config', function(t) {
{allow: ['butt']}
)
.messages.map(String),
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead']
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead'],
'alex.text() with allow config'
)
})

test('alex.text() with allow array', function(t) {
t.deepEqual(
alex
.text(
Expand All @@ -100,37 +97,37 @@ test('alex.text() with allow array', function(t) {
['butt']
)
.messages.map(String),
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead']
['1:6-1:15: `boogeyman` may be insensitive, use `boogeymonster` instead'],
'alex.text() with allow array'
)
})

test('alex.html()', function(t) {
var fp = path.join(__dirname, 'fixtures', 'three.html')
var fixture = fs.readFileSync(fp)

t.deepEqual(alex.html(fixture).messages.map(String), [
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead',
'11:36-11:40: Be careful with `butt`, it’s profane in some cases'
])
})

test('alex.html() with allow config', function(t) {
var fp = path.join(__dirname, 'fixtures', 'three.html')
var fixture = fs.readFileSync(fp)
t.deepEqual(
alex.html(html).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead',
'11:36-11:40: Be careful with `butt`, it’s profane in some cases'
],
'alex.html()'
)

t.deepEqual(alex.html(fixture, {allow: ['butt']}).messages.map(String), [
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
])
})
t.deepEqual(
alex.html(html, {allow: ['butt']}).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
],
'alex.html() with allow config'
)

test('alex.html() with allow array', function(t) {
var fp = path.join(__dirname, 'fixtures', 'three.html')
var fixture = fs.readFileSync(fp)
t.deepEqual(
alex.html(html, ['butt']).messages.map(String),
[
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
],
'alex.html() with allow array'
)

t.deepEqual(alex.html(fixture, ['butt']).messages.map(String), [
'9:18-9:20: `He` may be insensitive, use `They`, `It` instead',
'10:1-10:4: `She` may be insensitive, use `They`, `It` instead'
])
t.end()
})
Loading

0 comments on commit 0cc5502

Please sign in to comment.