[Unit test] jasmine createSpyObj
作者:互联网
beforeEach(() => { contextStub = { debug: false, engine: jasmine.createSpyObj('engine', [ 'createCollection', 'createContext', 'createSchematic', 'createSourceFromUrl', 'transformOptions', 'executePostTasks' ]), logger: jasmine.createSpyObj('logger', ['info']), schematic: jasmine.createSpyObj('schematic', ['call']), strategy: 0, interactive: false, addTask: jasmine.createSpy() }; }); it('schedules an npm install task if Material is not installed', () => { const rule = installMaterial(); rule(testTree, contextStub); expect(contextStub.addTask).toHaveBeenCalled(); expect(contextStub.logger.info).toHaveBeenCalledWith('Installing Angular Material...'); });
标签:Material,jasmine,contextStub,expect,test,createSpyObj,logger 来源: https://www.cnblogs.com/Answer1215/p/12031590.html