当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chai.spy类代码示例

本文整理汇总了TypeScript中chai.spy的典型用法代码示例。如果您正苦于以下问题:TypeScript spy类的具体用法?TypeScript spy怎么用?TypeScript spy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了spy类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

        it("should not propagate if stopPropagation is passed", () => {
            const spy = chai.spy.on(parent, "updateValidity");

            parent.child.setIssue({
                [parent.child.loc]: {
                    message: "",
                    type: "error",
                    code: ErrorCode.ID_INVALID_CHAR
                }
            }, true);

            expect(spy).to.not.have.been.called;
            expect(parent.errors).to.be.empty;
            expect(parent.child.errors).to.have.lengthOf(1);
        });
开发者ID:mayacoda,项目名称:cwl-ts,代码行数:15,代码来源:ValidationBase.spec.ts

示例2: it

    it('should clear everything using #remove', () => {
      const spyRemove = chai.spy.on(collection, 'remove');
      collection.removeAll();

      const eventListeners: string[] = collection.eventNames() as string[]

      expect(eventListeners.filter(
        (eventName: string) => /foo/.test(eventName)
      )).to.be.empty;

      expect(eventListeners.filter(
        (eventName: string) => /bar/.test(eventName)
      )).to.be.empty;

      expect(spyRemove).to.have.been.called.twice;
      expect(collection.count).to.equal(0);
    });
开发者ID:joelalejandro,项目名称:xethya,代码行数:17,代码来源:stat-collection.test.ts

示例3: it

    it('Should not delete the todo from the interactor nor set the collection if the gateway rejected the Promise', done => {
      const spy = chai.spy.on(controller, 'setTodoCollection')

      gateway.removeTodo = id => Promise.reject('Spec rejected the Promise intentionnaly')

      sut.deleteTodo(todo.id)
        .catch(() => {
          expect(sut.todos).to.deep.equal([
            todo,
            todo_
          ])

          expect(spy).not.to.have.been.called

          done()
        })
    })
开发者ID:Evgeniia0511,项目名称:clean-todo,代码行数:17,代码来源:todo.interactor.spec.ts

示例4: it

  it('should call challengeResolver when checking for challenge', () => {
    const spy = chai.spy.on(combat, 'challengeResolver');

    expect(combat.challenge()).to.be.true;
    expect(spy).to.have.been.called;
  });
开发者ID:joelalejandro,项目名称:xethya,代码行数:6,代码来源:combat-simulation.test.ts

示例5: afterEach

 afterEach(() => spy.restore(console));
开发者ID:vladjerca,项目名称:imgstry,代码行数:1,代码来源:logger.test.ts

示例6: on

    on(name: string, fn: () => void) {
    }
};

let spiedFn = chai.spy(original);

// then use in place of original
ee.on('some event', spiedFn);

// or use without original
let spy_again = chai.spy();
ee.on('some other event', spy_again);

// or you can track an object's method
let array = [ 1, 2, 3 ];
chai.spy.on(array, 'push');

// or you can track multiple object's methods
chai.spy.on(array, 'push', 'pop');

array.push(5);

// and you can reset the object calls
// array.push.reset();

// or you can create spy object
let object = chai.spy.object([ 'push', 'pop' ]);
object.push(5);

// or you create spy which returns static value
spiedFn = chai.spy.returns(true);
开发者ID:CaselIT,项目名称:DefinitelyTyped,代码行数:31,代码来源:chai-spies-tests.ts

示例7: on

    on(name: string, fn: () => void) {
    }
};

let spiedFn = chai.spy(original);

// then use in place of original
ee.on('some event', spiedFn);

// or use without original
let spy_again = chai.spy();
ee.on('some other event', spy_again);

// or you can track an object's method
let array = [ 1, 2, 3 ];
chai.spy.on(array, 'push');

// or you can track multiple object's methods
chai.spy.on(array, ['push', 'pop']);

// or you can track multiple object's methods
chai.spy.on(array, 'push', function(item) {
    array.push(item);
});

array.push(5);

// and you can reset the object calls
// array.push.reset();

// or you can create spy object
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:chai-spies-tests.ts

示例8: it

 it('should do nothing if setting value without changes', () => {
   const modifier = new Modifier('foo', 10);
   const spyEmit = chai.spy.on(modifier, 'emit');
   modifier.value = 10;
   expect(spyEmit).to.not.have.been.called;
 });
开发者ID:joelalejandro,项目名称:xethya,代码行数:6,代码来源:modifier.test.ts


注:本文中的chai.spy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。