[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...');
    });

 

posted @ 2019-12-12 20:59  Zhentiw  阅读(...)  评论(...)    收藏