@@ -28,42 +28,50 @@ import {UInt64} from '../../src/model/UInt64';
2828import { NamespaceService } from '../../src/service/NamespaceService' ;
2929
3030describe ( 'NamespaceService' , ( ) => {
31- let namespaceService : NamespaceService ;
32- let rootNamespace : NamespaceInfo ;
33- let subnamespace : NamespaceInfo ;
3431
35- before ( ( ) => {
32+ it ( 'should return the NamespaceInfo + name for a root namespace' , ( ) => {
3633 const mockedNamespaceHttp = mock ( NamespaceHttp ) ;
37- rootNamespace = givenRootNamespace ( ) ;
38- subnamespace = givenSubnamespace ( ) ;
39- // e43f43d2c5a8f299 rootNamespace.id.toHex()
40- // f7ce33276a3288c1 subnamespace.id.toHex()
34+ const rootNamespace = givenRootNamespace ( ) ;
35+ const subnamespace = givenSubnamespace ( ) ;
4136 when ( mockedNamespaceHttp . getNamespace ( rootNamespace . id ) )
4237 . thenReturn ( observableOf ( rootNamespace ) ) ;
4338 when ( mockedNamespaceHttp . getNamespace ( subnamespace . id ) )
4439 . thenReturn ( observableOf ( subnamespace ) ) ;
45-
4640 when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ rootNamespace . id ] ) ) )
4741 . thenReturn ( observableOf ( [ new NamespaceName ( new NamespaceId ( [ 3316183705 , 3829351378 ] ) , 'nem2tests' ) ] ) ) ;
48- when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ subnamespace . id ] ) ) )
49- . thenReturn ( observableOf ( [ new NamespaceName ( new NamespaceId ( [ 1781696705 , 4157485863 ] ) , 'level2' ) ] ) ) ;
5042 when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ rootNamespace . id , subnamespace . id ] ) ) )
5143 . thenReturn ( observableOf ( [
5244 new NamespaceName ( new NamespaceId ( [ 3316183705 , 3829351378 ] ) , 'nem2tests' ) ,
5345 new NamespaceName ( new NamespaceId ( [ 1781696705 , 4157485863 ] ) , 'level2' ) ,
5446 ] ) ) ;
5547 const namespaceHttp = instance ( mockedNamespaceHttp ) ;
56- namespaceService = new NamespaceService ( namespaceHttp ) ;
57- } ) ;
58-
59- it ( 'should return the NamespaceInfo + name for a root namespace' , ( ) => {
60- return namespaceService . namespace ( rootNamespace . id ) . toPromise ( ) . then ( ( namespace ) => {
48+ const namespaceService = new NamespaceService ( namespaceHttp ) ;
49+ namespaceService . namespace ( rootNamespace . id ) . subscribe ( ( namespace ) => {
6150 expect ( namespace . name ) . to . be . equal ( 'nem2tests' ) ;
6251 } ) ;
6352 } ) ;
6453
6554 it ( 'should return the NamespaceInfo + name for a subnamespace' , ( ) => {
66- return namespaceService . namespace ( subnamespace . id ) . toPromise ( ) . then ( ( namespace ) => {
55+ const mockedNamespaceHttp = mock ( NamespaceHttp ) ;
56+ const rootNamespace = givenRootNamespace ( ) ;
57+ const subnamespace = givenSubnamespace ( ) ;
58+ when ( mockedNamespaceHttp . getNamespace ( rootNamespace . id ) )
59+ . thenReturn ( observableOf ( rootNamespace ) ) ;
60+ when ( mockedNamespaceHttp . getNamespace ( subnamespace . id ) )
61+ . thenReturn ( observableOf ( subnamespace ) ) ;
62+ when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ rootNamespace . id ] ) ) )
63+ . thenReturn ( observableOf ( [ new NamespaceName ( new NamespaceId ( [ 3316183705 , 3829351378 ] ) , 'nem2tests' ) ] ) ) ;
64+ when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ subnamespace . id ] ) ) )
65+ . thenReturn ( observableOf ( [ new NamespaceName ( new NamespaceId ( [ 1781696705 , 4157485863 ] ) , 'level2' ) ] ) ) ;
66+ when ( mockedNamespaceHttp . getNamespacesName ( deepEqual ( [ rootNamespace . id , subnamespace . id ] ) ) )
67+ . thenReturn ( observableOf ( [
68+ new NamespaceName ( new NamespaceId ( [ 3316183705 , 3829351378 ] ) , 'nem2tests' ) ,
69+ new NamespaceName ( new NamespaceId ( [ 1781696705 , 4157485863 ] ) , 'level2' ) ,
70+ ] ) ) ;
71+ const namespaceHttp = instance ( mockedNamespaceHttp ) ;
72+ const namespaceService = new NamespaceService ( namespaceHttp ) ;
73+
74+ namespaceService . namespace ( subnamespace . id ) . subscribe ( ( namespace ) => {
6775 expect ( namespace . name ) . to . be . equal ( 'nem2tests.level2' ) ;
6876 } ) ;
6977 } ) ;
0 commit comments