Skip to content

Commit

Permalink
Improve instantiation style in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Nov 27, 2017
1 parent 39cdc91 commit 822215c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/turndown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ attendant.run()

test('malformed documents', function (t) {
t.plan(0)
var turndownService = new TurndownService
var turndownService = new TurndownService()
turndownService.turndown('<HTML><head></head><BODY><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><body onload=alert(document.cookie);></body></html>')
t.end()
})

test('null input', function (t) {
t.plan(1)
var turndownService = new TurndownService
var turndownService = new TurndownService()
t.throws(
function () { turndownService.turndown(null) }, /null is not a string/
)
})

test('undefined input', function (t) {
t.plan(1)
var turndownService = new TurndownService
var turndownService = new TurndownService()
t.throws(
function () { turndownService.turndown(void (0)) },
/undefined is not a string/
Expand All @@ -35,7 +35,7 @@ test('undefined input', function (t) {

test('#addRule returns the instance', function (t) {
t.plan(1)
var turndownService = new TurndownService
var turndownService = new TurndownService()
var rule = {
filter: ['del', 's', 'strike'],
replacement: function (content) {
Expand All @@ -47,7 +47,7 @@ test('#addRule returns the instance', function (t) {

test('#addRule adds the rule', function (t) {
t.plan(2)
var turndownService = new TurndownService
var turndownService = new TurndownService()
var rule = {
filter: ['del', 's', 'strike'],
replacement: function (content) {
Expand All @@ -64,13 +64,13 @@ test('#addRule adds the rule', function (t) {

test('#use returns the instance for chaining', function (t) {
t.plan(1)
var turndownService = new TurndownService
var turndownService = new TurndownService()
t.equal(turndownService.use(function plugin () {}), turndownService)
})

test('#use with a single plugin calls the fn with instance', function (t) {
t.plan(1)
var turndownService = new TurndownService
var turndownService = new TurndownService()
function plugin (service) {
t.equal(service, turndownService)
}
Expand All @@ -79,7 +79,7 @@ test('#use with a single plugin calls the fn with instance', function (t) {

test('#use with multiple plugins calls each fn with instance', function (t) {
t.plan(2)
var turndownService = new TurndownService
var turndownService = new TurndownService()
function plugin1 (service) {
t.equal(service, turndownService)
}
Expand Down

0 comments on commit 822215c

Please sign in to comment.