From 105445f02dd4b832c7ca5536f34f7ed48ccd6c25 Mon Sep 17 00:00:00 2001 From: Fynn Becker <post@fynn.be> Date: Wed, 27 Mar 2019 11:25:42 +0100 Subject: [PATCH] chore: Remove type checks from unit tests --- .../generate-preview-template.spec.js | 36 ------------------- test/unit/lib/utils/format-name.spec.js | 20 ----------- test/unit/lib/utils/normalize-path.spec.js | 20 ----------- test/unit/lib/utils/read-file-sync.spec.js | 20 ----------- 4 files changed, 96 deletions(-) diff --git a/test/unit/lib/nunjucks/generate-preview-template.spec.js b/test/unit/lib/nunjucks/generate-preview-template.spec.js index e341cd3d..df72c568 100644 --- a/test/unit/lib/nunjucks/generate-preview-template.spec.js +++ b/test/unit/lib/nunjucks/generate-preview-template.spec.js @@ -19,39 +19,3 @@ test('generates custom template', t => { t.snapshot(template) }) - -test('throws Error on missing options', t => { - const error = t.throws(() => { - generatePreviewTemplate({ body: 'test' }) - }, Error) - - t.is(error.message, 'options.head missing') -}) - -test('throws TypeError on wrong option types', t => { - const errorTemplate = t.throws(() => { - generatePreviewTemplate({ - template: 42, - head: 'test', - body: 'test' - }) - }, TypeError) - - const errorHead = t.throws(() => { - generatePreviewTemplate({ - head: 1337, - body: 'test' - }) - }, TypeError) - - const errorBody = t.throws(() => { - generatePreviewTemplate({ - head: 'test', - body: 3.142 - }) - }, TypeError) - - t.is(errorTemplate.message, 'options.template must be of type string') - t.is(errorHead.message, 'options.head must be of type string') - t.is(errorBody.message, 'options.body must be of type string') -}) diff --git a/test/unit/lib/utils/format-name.spec.js b/test/unit/lib/utils/format-name.spec.js index 1d8a0530..2750b748 100644 --- a/test/unit/lib/utils/format-name.spec.js +++ b/test/unit/lib/utils/format-name.spec.js @@ -35,23 +35,3 @@ test('formats name with double dashes', t => { t.is(actual, expected) }) - -test('throws on empty ‘name’ parameter', t => { - const actual = t.throws(() => { formatName() }).message - const expected = 'Paramater ‘name’ is necessary.' - - t.is(actual, expected) -}) - -test('throws on non-string ‘path’ parameter', t => { - const actualArray = t.throws(() => { formatName([]) }).message - const actualFunction = t.throws(() => { formatName(() => {}) }).message - const actualNumber = t.throws(() => { formatName(2) }).message - const actualObject = t.throws(() => { formatName({}) }).message - const expected = 'Parameter ‘name’ must be a string.' - - t.is(actualArray, expected) - t.is(actualFunction, expected) - t.is(actualNumber, expected) - t.is(actualObject, expected) -}) diff --git a/test/unit/lib/utils/normalize-path.spec.js b/test/unit/lib/utils/normalize-path.spec.js index 8cc37f50..ca173e8b 100644 --- a/test/unit/lib/utils/normalize-path.spec.js +++ b/test/unit/lib/utils/normalize-path.spec.js @@ -14,23 +14,3 @@ test('leaves Unix paths as is', t => { t.is(actual, expected) }) - -test('throws on empty ‘path’ parameter', t => { - const actual = t.throws(() => { normalizePath() }).message - const expected = 'Paramater ‘path’ is necessary.' - - t.is(actual, expected) -}) - -test('throws on non-string ‘path’ parameter', t => { - const actualArray = t.throws(() => { normalizePath([]) }).message - const actualFunction = t.throws(() => { normalizePath(() => {}) }).message - const actualNumber = t.throws(() => { normalizePath(2) }).message - const actualObject = t.throws(() => { normalizePath({}) }).message - const expected = 'Parameter ‘path’ must be a string.' - - t.is(actualArray, expected) - t.is(actualFunction, expected) - t.is(actualNumber, expected) - t.is(actualObject, expected) -}) diff --git a/test/unit/lib/utils/read-file-sync.spec.js b/test/unit/lib/utils/read-file-sync.spec.js index 3699f41f..6fa7781b 100644 --- a/test/unit/lib/utils/read-file-sync.spec.js +++ b/test/unit/lib/utils/read-file-sync.spec.js @@ -20,23 +20,3 @@ test('returns undefined for missing files', t => { t.is(actual, expected) }) - -test('throws on empty ‘filePath’ parameter', t => { - const actual = t.throws(() => { readFileSync() }).message - const expected = 'Paramater ‘filePath’ is necessary.' - - t.is(actual, expected) -}) - -test('throws on non-string ‘filePath’ parameter', t => { - const actualArray = t.throws(() => { readFileSync([]) }).message - const actualFunction = t.throws(() => { readFileSync(() => {}) }).message - const actualNumber = t.throws(() => { readFileSync(2) }).message - const actualObject = t.throws(() => { readFileSync({}) }).message - const expected = 'Parameter ‘filePath’ must be a string.' - - t.is(actualArray, expected) - t.is(actualFunction, expected) - t.is(actualNumber, expected) - t.is(actualObject, expected) -})