From f418424144852905d7cdea1ddc45287b0dc8f73e Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 22 Nov 2018 06:21:19 +0700 Subject: [PATCH] Add tests --- .travis.yml | 8 ++++++++ package.json | 6 +++++- test/unit.js | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 test/unit.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2bde09e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - '8' +script: npm test +after_success: npm run coverage +notifications: + email: + on_success: never diff --git a/package.json b/package.json index ba468d6..d90cd20 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,17 @@ "author": "Luke Childs ", "license": "MIT", "scripts": { - "test": "xo" + "test": "xo && nyc ava", + "coverage": "nyc report --reporter=text-lcov | coveralls" }, "dependencies": { "bip39": "^2.5.0", "randombytes": "^2.0.6" }, "devDependencies": { + "ava": "^0.25.0", + "coveralls": "^3.0.2", + "nyc": "^13.1.0", "xo": "^0.23.0" } } diff --git a/test/unit.js b/test/unit.js new file mode 100644 index 0000000..85fff7f --- /dev/null +++ b/test/unit.js @@ -0,0 +1,17 @@ +import test from 'ava'; +import dogeSeed from '..'; + +test('Seed phrases contain the words "much", "such" and "very"', t => { + const words = [...new Set( + new Array(1000) + .fill() + .map(dogeSeed) + .map(seedPhrase => [seedPhrase.split(' ')[0], seedPhrase.split(' ')[2]]) + .reduce((a, b) => a.concat(b), []) + )]; + + t.is(words.length, 3); + t.true(words.includes('much')); + t.true(words.includes('such')); + t.true(words.includes('very')); +});