From f85a040034c682e4b3ebcabf3c094db2f7024e72 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" <chris.brody+brodybits@gmail.com> Date: Thu, 2 Apr 2020 11:47:42 -0400 Subject: [PATCH 1/2] add lib-bogus-empty-object.test.js --- .../with-bogus/lib-bogus-empty-object.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/with-injection/create/with-bogus/lib-bogus-empty-object.test.js diff --git a/tests/with-injection/create/with-bogus/lib-bogus-empty-object.test.js b/tests/with-injection/create/with-bogus/lib-bogus-empty-object.test.js new file mode 100644 index 00000000..48e846ab --- /dev/null +++ b/tests/with-injection/create/with-bogus/lib-bogus-empty-object.test.js @@ -0,0 +1,20 @@ +const lib = require('../../../../lib/lib.js'); + +const ioInject = require('../../helpers/io-inject.js'); + +test('create module with bogus empty object', async () => { + // with snapshot info ignored in this test + const inject = ioInject([]); + + const options = {}; + + let error; + try { + // expected to throw: + await lib(options, inject); + } catch (e) { + error = e; + } + expect(error).toBeDefined(); + expect(error.message).toMatch(`Please write your library's name`); +}); From 29167baf00d437f4587d6592a8df32314bc15456 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" <chris.brody+brodybits@gmail.com> Date: Thu, 2 Apr 2020 11:51:01 -0400 Subject: [PATCH 2/2] add lib-bogus-null-object.test.js --- .../with-bogus/lib-bogus-null-object.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/with-injection/create/with-bogus/lib-bogus-null-object.test.js diff --git a/tests/with-injection/create/with-bogus/lib-bogus-null-object.test.js b/tests/with-injection/create/with-bogus/lib-bogus-null-object.test.js new file mode 100644 index 00000000..5227c30c --- /dev/null +++ b/tests/with-injection/create/with-bogus/lib-bogus-null-object.test.js @@ -0,0 +1,20 @@ +const lib = require('../../../../lib/lib.js'); + +const ioInject = require('../../helpers/io-inject.js'); + +test('create module with bogus null object', async () => { + // with snapshot info ignored in this test + const inject = ioInject([]); + + const options = null; + + let error; + try { + // expected to throw: + await lib(options, inject); + } catch (e) { + error = e; + } + expect(error).toBeDefined(); + expect(error.message).toMatch(`Cannot read property 'name' of null`); +});