Skip to content

Commit 1828896

Browse files
test(): reorder unit tests in client-proxy
1 parent 22a54d7 commit 1828896

1 file changed

Lines changed: 55 additions & 55 deletions

File tree

packages/microservices/test/client/client-proxy.spec.ts

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,61 @@ describe('ClientProxy', () => {
2020
client = new TestClientProxy();
2121
});
2222

23+
describe('createObserver', () => {
24+
describe('returned function calls', () => {
25+
it(`"error" when first parameter is not null or undefined`, () => {
26+
const testClient = new TestClientProxy();
27+
const err = 'test';
28+
const error = sinon.spy();
29+
const next = sinon.spy();
30+
const complete = sinon.spy();
31+
const observer = {
32+
error,
33+
next,
34+
complete,
35+
};
36+
const fn = testClient['createObserver'](observer);
37+
38+
fn({ err });
39+
expect(error.calledWith(err)).to.be.true;
40+
});
41+
42+
it(`"next" when first parameter is null or undefined`, () => {
43+
const testClient = new TestClientProxy();
44+
const data = 'test';
45+
const error = sinon.spy();
46+
const next = sinon.spy();
47+
const complete = sinon.spy();
48+
const observer = {
49+
error,
50+
next,
51+
complete,
52+
};
53+
const fn = testClient['createObserver'](observer);
54+
55+
fn({ response: data });
56+
expect(next.calledWith(data)).to.be.true;
57+
});
58+
59+
it(`"complete" when third parameter is true`, () => {
60+
const testClient = new TestClientProxy();
61+
const data = 'test';
62+
const error = sinon.spy();
63+
const next = sinon.spy();
64+
const complete = sinon.spy();
65+
const observer = {
66+
error,
67+
next,
68+
complete,
69+
};
70+
const fn = testClient['createObserver'](observer);
71+
72+
fn({ data, isDisposed: true } as any);
73+
expect(complete.called).to.be.true;
74+
});
75+
});
76+
});
77+
2378
describe('send', () => {
2479
it(`should return an observable stream`, () => {
2580
const stream$ = client.send({}, '');
@@ -117,59 +172,4 @@ describe('ClientProxy', () => {
117172
expect(err$).to.be.instanceOf(Observable);
118173
});
119174
});
120-
121-
describe('createObserver', () => {
122-
describe('returned function calls', () => {
123-
it(`"error" when first parameter is not null or undefined`, () => {
124-
const testClient = new TestClientProxy();
125-
const err = 'test';
126-
const error = sinon.spy();
127-
const next = sinon.spy();
128-
const complete = sinon.spy();
129-
const observer = {
130-
error,
131-
next,
132-
complete,
133-
};
134-
const fn = testClient['createObserver'](observer);
135-
136-
fn({ err });
137-
expect(error.calledWith(err)).to.be.true;
138-
});
139-
140-
it(`"next" when first parameter is null or undefined`, () => {
141-
const testClient = new TestClientProxy();
142-
const data = 'test';
143-
const error = sinon.spy();
144-
const next = sinon.spy();
145-
const complete = sinon.spy();
146-
const observer = {
147-
error,
148-
next,
149-
complete,
150-
};
151-
const fn = testClient['createObserver'](observer);
152-
153-
fn({ response: data });
154-
expect(next.calledWith(data)).to.be.true;
155-
});
156-
157-
it(`"complete" when third parameter is true`, () => {
158-
const testClient = new TestClientProxy();
159-
const data = 'test';
160-
const error = sinon.spy();
161-
const next = sinon.spy();
162-
const complete = sinon.spy();
163-
const observer = {
164-
error,
165-
next,
166-
complete,
167-
};
168-
const fn = testClient['createObserver'](observer);
169-
170-
fn({ data, isDisposed: true } as any);
171-
expect(complete.called).to.be.true;
172-
});
173-
});
174-
});
175175
});

0 commit comments

Comments
 (0)