From a69063de9b86428c9e87412ad7d6fa1bc1d8734d Mon Sep 17 00:00:00 2001 From: Klaxon Date: Tue, 2 Oct 2018 13:51:55 +1000 Subject: [PATCH] add tests --- test/index.mjs | 1 + .../operations/ExtractEmailAddresses.mjs | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/tests/operations/ExtractEmailAddresses.mjs diff --git a/test/index.mjs b/test/index.mjs index 3f873201..c3e413fe 100644 --- a/test/index.mjs +++ b/test/index.mjs @@ -40,6 +40,7 @@ import "./tests/operations/Compress"; import "./tests/operations/ConditionalJump"; import "./tests/operations/Crypt"; import "./tests/operations/DateTime"; +import "./tests/operations/ExtractEmailAddresses"; import "./tests/operations/Fork"; import "./tests/operations/FromGeohash.mjs"; import "./tests/operations/Hash"; diff --git a/test/tests/operations/ExtractEmailAddresses.mjs b/test/tests/operations/ExtractEmailAddresses.mjs new file mode 100644 index 00000000..728d3c57 --- /dev/null +++ b/test/tests/operations/ExtractEmailAddresses.mjs @@ -0,0 +1,33 @@ +/** + * Parse IP Range tests. + * + * @author Klaxon [klaxon@veyr.com] + * @copyright Crown Copyright 2017 + * @license Apache-2.0 + */ +import TestRegister from "../../TestRegister"; + +TestRegister.addTests([ + { + name: "Extract email address", + input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com", + expectedOutput: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n", + recipeConfig: [ + { + "op": "Extract email addresses", + "args": [false] + }, + ], + }, + { + name: "Extract email address - Display total", + input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com", + expectedOutput: "Total found: 11\n\nemail@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n", + recipeConfig: [ + { + "op": "Extract email addresses", + "args": [true] + }, + ], + }, +]);