當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。