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


TypeScript dom.mockDOMSource函数代码示例

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


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

示例1: mockSources

 function mockSources(selector, id, name) {
   return Object.assign({},
     {DOM: mockDOMSource(RxAdapter, {
       selector: {'click': O.of({target: {innerHTML: '5'}})}})},
     {props$: O.of({id, name})}
   );
 }
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:7,代码来源:index.spec.ts

示例2: test

  test({type: 'DELETE ITEM', payload: 11}, function() {
    const DOM = mockDOMSource(RxJSAdapter, {});
    const mockBLaction$ = O.of({type: 'DELETE', payload: 11});

    expect(intent(DOM, mockBLaction$).isEmpty())
    .toBeStreamOf(false);
    expect(intent(DOM, mockBLaction$).last())
    .toBeStreamOf({type: 'DELETE ITEM', payload: 11});
  });
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:9,代码来源:intent.spec.ts

示例3: test

 test('DOM flows to intent', function() {
   const DOM = mockDOMSource(RxJSAdapter, {
     '.rollButton': {
       'click': O.of({target: {innerHTML: '5'}})
     }
   });
   BowlingLine({DOM}, nullView, nullModel, intent);
   function intent(DOMSource) {
     const rollButton$ = DOMSource.select('.rollButton').events('click');
     expect(rollButton$.map(evt => evt.target.innerHTML)).toBeStreamOf('5');
     return O.of({type: 'ROLL', payload: 5});
   }
 });
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:13,代码来源:bowlingLine.spec.ts

示例4: test

 test('intent is function from DOMSource to observable of actions', function() {
   const DOM = mockDOMSource(RxJSAdapter, {
     '.foo': {
       'click': O.of({target: {innerHTML: '123'}})
     }
   });
   Component({DOM}, nullModel, nullView, intent);
   function intent(DOMSource, ...rest) {
     const rollButton$ = DOMSource.select('.foo').events('click');
     expect(rollButton$.map(evt => evt.target.innerHTML)).toBeStreamOf('123');
     return O.empty();
   }
 });
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:13,代码来源:testsuite.ts

示例5: test

 test('confirm actions from DOM', function() {
   [
     [mockDOMSource(
       RxAdapter, {'.rollButton': {'click': O.of({target: {innerHTML: '5'}})}}
     ), {type: 'ROLL', payload: 5}],
     [mockDOMSource(
       RxAdapter, {'.newGame': {'click': O.of({})}}
     ), {type: 'NEW GAME'}],
     [mockDOMSource(
       RxAdapter, {'.undo': {'click': O.of({})}}
     ), {type: 'UNDO'}],
     [mockDOMSource(
       RxAdapter, {'.redo': {'click': O.of({})}}
     ), {type: 'REDO'}],
     [mockDOMSource(
       RxAdapter, {'.delete': {'click': O.of({})}}
     ), {type: 'DELETE'}]
   ].forEach(([DOMSource, action]) =>
     test(action, function() {
       expect(intent(DOMSource).isEmpty()).toBeStreamOf(false);
       expect(intent(DOMSource)).toBeStreamOf(action);
     })
   );
 });
开发者ID:wizardwerdna,项目名称:FRPBowlingKata,代码行数:24,代码来源:intent.spec.ts

示例6: it

  it('can be used to test Cycle apps', done => {
    function Counter({DOM}: any) {
      const add$ = DOM.select('.add')
        .events('click')
        .mapTo(+1);

      const subtract$ = DOM.select('.subtract')
        .events('click')
        .mapTo(-1);

      const change$ = xs.merge(add$, subtract$);

      const add = (a: number, b: number) => a + b;

      const count$ = change$.fold(add, 0);

      return {
        count$,
      };
    }

    const Time = mockTimeSource();

    const addClick = '---x-x-x------x-|';
    const subtractClick = '-----------x----|';

    const expectedCount = '0--1-2-3---2--3-|';

    const _DOM = mockDOMSource({
      '.add': {
        click: Time.diagram(addClick),
      },
      '.subtract': {
        click: Time.diagram(subtractClick),
      },
    });

    const counter = Counter({DOM: _DOM});

    Time.assertEqual(counter.count$, Time.diagram(expectedCount));

    Time.run(done);
  });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:43,代码来源:time.ts

示例7: withTime

                withTime(Time => {
                    const add$ = Time.diagram(addDiagram)
                    const subtract$ = Time.diagram(subtractDiagram)

                    const DOM = mockDOMSource({
                        '.add': { click: add$ },
                        '.subtract': { click: subtract$ }
                    })

                    const app = onionify(App)({ DOM } as any)
                    const html$ = (app.DOM as Stream<VNode>).map(toHtml)

                    const expected$ = xs
                        .merge(add$.mapTo(+1), subtract$.mapTo(-1))
                        .fold((acc, curr) => acc + curr, 0)
                        .map(expectedHTML)

                    Time.assertEqual(html$, expected$, htmlLooksLike)
                })
开发者ID:OpenDirective,项目名称:brian,代码行数:19,代码来源:app.test.ts

示例8: forall

        const property = forall(diagramArbitrary, diagramArbitrary, (addDiagram, subtractDiagram) => {
            const Time = mockTimeSource();

            const add$ = Time.diagram(addDiagram);
            const subtract$ = Time.diagram(subtractDiagram);

            const DOM = mockDOMSource({
                '.add': { click: add$ },
                '.subtract': { click: subtract$ }
            });

            const app = onionify(App)({ DOM } as any);
            const html$ = app.DOM.map(toHtml);

            const expected$ = xs.merge(add$.mapTo(+1), subtract$.mapTo(-1))
                .fold((acc, curr) => acc + curr, 0)
                .map(expectedHTML);

            Time.assertEqual(html$, expected$, htmlLooksLike);
            return promise(Time.run);
        });
开发者ID:michalvankodev,项目名称:portfolio,代码行数:21,代码来源:app.test.ts


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