-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca3092b
commit 772e907
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { test } from 'tape-promise/tape'; | ||
import { makeRegistrar } from '../../../../more/registrar/registrar'; | ||
|
||
test('Registrar creation', async t => { | ||
try { | ||
const registrarService = makeRegistrar('testnet'); | ||
const obj1 = {}; | ||
const obj2 = {}; | ||
const id1 = registrarService.register('myname', obj1); | ||
t.assert(id1.match(/^myname_\d{4,}$/), 'id1 is correct format') | ||
const id2 = registrarService.register('myname', obj2); | ||
t.assert(id2.match(/^myname_\d{4,}$/), 'id2 is correct format') | ||
t.isNot(id2, id1, 'ids for different objects are different'); | ||
const id1a = registrarService.register('myname', obj1); | ||
t.assert(id1a.match(/^myname_\d{4,}$/), 'id1a is correct format') | ||
t.isNot(id1a, id1, 'ids for same object are different'); | ||
const id1b = registrarService.register('othername', obj1); | ||
t.assert(id1b.match(/^othername_\d{4,}$/), 'id1b is correct format') | ||
const ret1 = registrarService.get(id1); | ||
t.equals(ret1, obj1, 'returned obj1 is equal'); | ||
const ret2 = registrarService.get(id2); | ||
t.equals(ret2, obj2, 'returned obj2 is equal'); | ||
const ret1a = registrarService.get(id1a); | ||
t.equals(ret1a, obj1, 'returned obj1a is equal'); | ||
const ret1b = registrarService.get(id1b); | ||
t.equals(ret1b, obj1, 'returned obj1b is equal'); | ||
} catch (e) { | ||
t.isNot(e, e, 'unexpected exception'); | ||
} finally { | ||
t.end(); | ||
} | ||
}); |