aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/helper.js4
-rw-r--r--test/index.html29
-rw-r--r--test/spec/test.js11
-rw-r--r--test/unit/idStore-test.js81
4 files changed, 85 insertions, 40 deletions
diff --git a/test/helper.js b/test/helper.js
new file mode 100644
index 000000000..7746b90e0
--- /dev/null
+++ b/test/helper.js
@@ -0,0 +1,4 @@
+require('mocha-sinon')()
+var jsdom = require('mocha-jsdom')
+jsdom()
+
diff --git a/test/index.html b/test/index.html
deleted file mode 100644
index 6498d5fcc..000000000
--- a/test/index.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Mocha Spec Runner</title>
- <link rel="stylesheet" href="../bower_components/mocha/mocha.css">
-</head>
-<body>
- <div id="mocha"></div>
- <script src="../bower_components/mocha/mocha.js"></script>
- <script>mocha.setup('bdd');</script>
- <script src="../bower_components/chai/chai.js"></script>
- <script>
- var assert = chai.assert;
- var expect = chai.expect;
- var should = chai.should();
- </script>
- <!-- bower:js -->
- <!-- endbower -->
- <!-- include source files here... -->
- <!-- include spec files here... -->
- <script src="spec/test.js"></script>
- <script>
- if (navigator.userAgent.indexOf('PhantomJS') === -1) {
- mocha.run();
- }
- </script>
-</body>
-</html>
diff --git a/test/spec/test.js b/test/spec/test.js
deleted file mode 100644
index 0fca0fb57..000000000
--- a/test/spec/test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-(function () {
- 'use strict';
-
- describe('Give it some context', function () {
- describe('maybe a bit more context here', function () {
- it('should run here few assertions', function () {
-
- });
- });
- });
-})();
diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js
new file mode 100644
index 000000000..d3fabfe9d
--- /dev/null
+++ b/test/unit/idStore-test.js
@@ -0,0 +1,81 @@
+var assert = require('assert')
+var IdentityStore = require('../../app/scripts/lib/idStore')
+
+describe('IdentityStore', function() {
+
+ describe('#createNewVault', function () {
+ let idStore
+ let password = 'password123'
+ let entropy = 'entripppppyy duuude'
+ let seedWords
+ let accounts = []
+ let originalKeystore
+
+ before(function(done) {
+ window.localStorage = {} // Hacking localStorage support into JSDom
+
+ idStore = new IdentityStore({
+ addAccount(acct) { accounts.push(acct) },
+ })
+
+ idStore.createNewVault(password, entropy, (err, seeds) => {
+ seedWords = seeds
+ originalKeystore = idStore._idmgmt.keyStore
+ done()
+ })
+ })
+
+ describe('#recoverFromSeed', function() {
+ let newAccounts = []
+
+ before(function() {
+ window.localStorage = {} // Hacking localStorage support into JSDom
+
+ idStore = new IdentityStore({
+ addAccount(acct) { newAccounts.push(acct) },
+ })
+ })
+
+ it('should return the expected keystore', function (done) {
+
+ idStore.recoverFromSeed(password, seedWords, (err) => {
+ assert.ifError(err)
+
+ let newKeystore = idStore._idmgmt.keyStore
+ assert.equal(newAccounts[0], accounts[0])
+ done()
+ })
+ })
+ })
+ })
+
+ describe('#recoverFromSeed BIP44 compliance', function() {
+ let seedWords = 'picnic injury awful upper eagle junk alert toss flower renew silly vague'
+ let firstAccount = '0x5d8de92c205279c10e5669f797b853ccef4f739a'
+
+ let password = 'secret!'
+ let accounts = []
+ let idStore
+
+ before(function() {
+ window.localStorage = {} // Hacking localStorage support into JSDom
+
+ idStore = new IdentityStore({
+ addAccount(acct) {
+ accounts.push(acct)
+ },
+ })
+ })
+
+ it('should return the expected first account', function (done) {
+
+ idStore.recoverFromSeed(password, seedWords, (err) => {
+ assert.ifError(err)
+
+ let newKeystore = idStore._idmgmt.keyStore
+ assert.equal(accounts[0], firstAccount)
+ done()
+ })
+ })
+ })
+})