Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/infrastructure/Listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Listener', () => {
throw new Error('This should not be called when expecting error');
})
.catch((error) => {
expect(error.message.toString()).to.be.equal("getaddrinfo ENOTFOUND notcorrecturl notcorrecturl:0000");
expect(error.message.toString()).not.to.be.equal('');
});
});
});
Expand Down
42 changes: 25 additions & 17 deletions test/service/NamespaceService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,50 @@ import {UInt64} from '../../src/model/UInt64';
import {NamespaceService} from '../../src/service/NamespaceService';

describe('NamespaceService', () => {
let namespaceService: NamespaceService;
let rootNamespace: NamespaceInfo;
let subnamespace: NamespaceInfo;

before(() => {
it('should return the NamespaceInfo + name for a root namespace', () => {
const mockedNamespaceHttp = mock(NamespaceHttp);
rootNamespace = givenRootNamespace();
subnamespace = givenSubnamespace();
// e43f43d2c5a8f299 rootNamespace.id.toHex()
// f7ce33276a3288c1 subnamespace.id.toHex()
const rootNamespace = givenRootNamespace();
const subnamespace = givenSubnamespace();
when(mockedNamespaceHttp.getNamespace(rootNamespace.id))
.thenReturn(observableOf(rootNamespace));
when(mockedNamespaceHttp.getNamespace(subnamespace.id))
.thenReturn(observableOf(subnamespace));

when(mockedNamespaceHttp.getNamespacesName(deepEqual([rootNamespace.id])))
.thenReturn(observableOf([new NamespaceName(new NamespaceId([3316183705, 3829351378]), 'nem2tests')]));
when(mockedNamespaceHttp.getNamespacesName(deepEqual([subnamespace.id])))
.thenReturn(observableOf([new NamespaceName(new NamespaceId([1781696705, 4157485863]), 'level2')]));
when(mockedNamespaceHttp.getNamespacesName(deepEqual([rootNamespace.id, subnamespace.id])))
.thenReturn(observableOf([
new NamespaceName(new NamespaceId([3316183705, 3829351378]), 'nem2tests'),
new NamespaceName(new NamespaceId([1781696705, 4157485863]), 'level2'),
]));
const namespaceHttp = instance(mockedNamespaceHttp);
namespaceService = new NamespaceService(namespaceHttp);
});

it('should return the NamespaceInfo + name for a root namespace', () => {
return namespaceService.namespace(rootNamespace.id).toPromise().then((namespace) => {
const namespaceService = new NamespaceService(namespaceHttp);
namespaceService.namespace(rootNamespace.id).subscribe((namespace) => {
expect(namespace.name).to.be.equal('nem2tests');
});
});

it('should return the NamespaceInfo + name for a subnamespace', () => {
return namespaceService.namespace(subnamespace.id).toPromise().then((namespace) => {
const mockedNamespaceHttp = mock(NamespaceHttp);
const rootNamespace = givenRootNamespace();
const subnamespace = givenSubnamespace();
when(mockedNamespaceHttp.getNamespace(rootNamespace.id))
.thenReturn(observableOf(rootNamespace));
when(mockedNamespaceHttp.getNamespace(subnamespace.id))
.thenReturn(observableOf(subnamespace));
when(mockedNamespaceHttp.getNamespacesName(deepEqual([rootNamespace.id])))
.thenReturn(observableOf([new NamespaceName(new NamespaceId([3316183705, 3829351378]), 'nem2tests')]));
when(mockedNamespaceHttp.getNamespacesName(deepEqual([subnamespace.id])))
.thenReturn(observableOf([new NamespaceName(new NamespaceId([1781696705, 4157485863]), 'level2')]));
when(mockedNamespaceHttp.getNamespacesName(deepEqual([rootNamespace.id, subnamespace.id])))
.thenReturn(observableOf([
new NamespaceName(new NamespaceId([3316183705, 3829351378]), 'nem2tests'),
new NamespaceName(new NamespaceId([1781696705, 4157485863]), 'level2'),
]));
const namespaceHttp = instance(mockedNamespaceHttp);
const namespaceService = new NamespaceService(namespaceHttp);

namespaceService.namespace(subnamespace.id).subscribe((namespace) => {
expect(namespace.name).to.be.equal('nem2tests.level2');
});
});
Expand Down