-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
/
get-repl-fn.spec.ts
47 lines (40 loc) 路 1.21 KB
/
get-repl-fn.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { expect } from 'chai';
import * as sinon from 'sinon';
import { GetReplFn } from '../../../repl/native-functions';
import { ReplContext } from '../../../repl/repl-context';
import { NestContainer } from '../../../injector/container';
describe('GetReplFn', () => {
let getReplFn: GetReplFn;
let replContext: ReplContext;
let mockApp: {
container: NestContainer;
get: sinon.SinonStub;
resolve: sinon.SinonSpy;
select: sinon.SinonSpy;
};
before(async () => {
const container = new NestContainer();
mockApp = {
container,
get: sinon.stub(),
resolve: sinon.spy(),
select: sinon.spy(),
};
replContext = new ReplContext(mockApp as any);
});
beforeEach(() => {
getReplFn = replContext.nativeFunctions.get('get') as GetReplFn;
});
afterEach(() => sinon.restore());
it('the function name should be "get"', () => {
expect(getReplFn).to.not.be.undefined;
expect(getReplFn.fnDefinition.name).to.eql('get');
});
describe('action', () => {
it('should pass arguments down to the application context', () => {
const token = 'test';
getReplFn.action(token);
expect(mockApp.get.calledWith(token)).to.be.true;
});
});
});