コード例 #1
0
function mouseOverBetweenSuggestions(suggestionIndex1, suggestionIndex2) {
  const suggestions = TestUtils.scryRenderedDOMComponentsWithClass(autosuggest, 'react-autosuggest__suggestion');
  const suggestion1 = React.findDOMNode(suggestions[suggestionIndex1]);
  const suggestion2 = React.findDOMNode(suggestions[suggestionIndex2]);

  mouseOver(suggestion1, suggestion2);
}
コード例 #2
0
ファイル: Login.js プロジェクト: DaveDH2/coder-girl
  handleLogin: function(event) {
    event.preventDefault();
    var email = React.findDOMNode(this.refs.email).value.trim();
    var password = React.findDOMNode(this.refs.password).value.trim();

    AuthActions.login(email, password);
  },
コード例 #3
0
    componentDidMount: function () {
        var stageDOM = React.findDOMNode(this.refs.stage),
            stageW = stageDOM.scrollWidth,
            stageH = stageDOM.scrollHeight,
            halfStageW = Math.ceil(stageW / 2),
            halfStageH = Math.ceil(stageH / 2);

        var imgFigureDOM = React.findDOMNode(this.refs.imgFigure0),
            imgW = imgFigureDOM.scrollWidth,
            imgH = imgFigureDOM.scrollHeight,
            halfImgW = Math.ceil(imgW / 2),
            halfImgH = Math.ceil(imgH / 2);

        this.Constant.centerPos = {
            left: halfStageW - halfImgW,
            top: halfStageH - halfImgH
        };

        this.Constant.hPosRange.leftSecX[0] = -halfImgW;
        this.Constant.hPosRange.leftSecX[1] = halfStageW - halfImgW * 3;
        this.Constant.hPosRange.rightSecX[0] = halfStageW + halfImgW;
        this.Constant.hPosRange.rightSecX[1] = stageW - halfImgW;
        this.Constant.hPosRange.y[0] = -halfImgH;
        this.Constant.hPosRange.y[1] = stageH - halfImgH;

        this.Constant.vPosRange.topY[0] = -halfImgH;
        this.Constant.vPosRange.topY[1] = halfStageH - halfImgH * 3;
        this.Constant.vPosRange.x[0] = halfStageW - imgW;
        this.Constant.vPosRange.x[1] = halfStageW;

        this.rearrange(0);
    },
コード例 #4
0
 handleSubmit:function (e) {
       e.preventDefault();
       var author = React.findDOMNode(this.refs.author).value.trim();
       var text = React.findDOMNode(this.refs.text).value.trim();
       if (!text || !author) {
             return;
       }
       this.props.onCommentSubmit({author:author,text:text});
       React.findDOMNode(this.refs.author).value='';
       React.findDOMNode(this.refs.text).value='';
       return;
 },
コード例 #5
0
ファイル: login.spec.js プロジェクト: wenhao/fixed-asset
    it('should not be disable when fill in username and password', function(){
      var userName = React.findDOMNode(login.refs.username.refs.input)
      var password = React.findDOMNode(login.refs.password.refs.input)
      login.refs.username.setValue("test")
      login.refs.password.setValue("test")
      React.addons.TestUtils.Simulate.change(userName,{target:{value: 'test'}})
      React.addons.TestUtils.Simulate.change(password,{target:{value: 'test'}})
      login.state.isDisable.should.be.equal(false)

      login.refs.password.setValue(null)
      React.addons.TestUtils.Simulate.change(password,{target:{value: null}})
      login.state.isDisable.should.be.equal(true)
    })
コード例 #6
0
  it('shows message when leader != pid', function() {

    var zookeeperRedirectRendered = TestUtils.renderIntoDocument(
      <ZookeeperRedirect leader='http://127.0.0.1:5050' pid='http://127.0.0.2:5050' redirectTime={3000} />
    );

    var zooKeeperDiv = TestUtils.findRenderedDOMComponentWithTag(
      zookeeperRedirectRendered, 'div');
      expect(React.findDOMNode(zooKeeperDiv).className).toEqual('show');

    var alertSpan = TestUtils.findRenderedDOMComponentWithTag(
      zookeeperRedirectRendered, 'span');
      expect(React.findDOMNode(alertSpan).innerHTML).toEqual('This master is not the leader, redirecting...');
  });
    it('Check onSortChange calling',function() {

        var data = generateMockData({type : 'local',len : 1})
        var SORT_INFO = [ { name: 'firstName', dir: 'asc'}]
        var checkDir = -1

        var onSortChangeHandler = function(sortInfo) {
            sortInfo.length.should.equal(1)
            sortInfo[0].name.should.equal('firstName')
            sortInfo[0].dir.should.equal(checkDir)    
        }

        // table with column menu
        var table = render(
            DataGrid({
                idProperty: 'id',
                dataSource: data,
                columns   : columns,
                sortInfo : SORT_INFO,
                onSortChange : onSortChangeHandler
            })
        )

        var headers = tryWithClass(table,COLUMN_HEADER_CLASS)
        var checkHeader = React.findDOMNode(headers[1])
        checkHeader.className.includes(SORT_ASC_CLASS).should.be.true

        TestUtils.Simulate.mouseDown(checkHeader)
        TestUtils.Simulate.mouseUp(checkHeader)

    })
コード例 #8
0
ファイル: NotePad.js プロジェクト: ipolevoy/notes
 componentDidMount: function () {
     var _this = this;
     NotesStore.addChangeListener(React.findDOMNode(_this), function () {
         _this.setState({notes: NotesStore.getNotes()});
     });
     NotesActions.loadNotes();
 },
コード例 #9
0
    componentDidMount: function() {

        this.unsubscribe = DeskPageFrameStore.listen(this._changeFrameContent);

        var domNode = React.findDOMNode(this);
        domNode.onload = (function(){
            this._renderFrameContent();
        }).bind(this);

        Server.onSocketEmit('compilerWatcher.errors', function(data){
            var messages = [];
            _.each(data, function(item){
                _.each(item, function(message){
                    messages.push(message);
                });
            });
            this._showModalMessageArray(messages);
        }.bind(this));

        Server.onSocketEmit('compilerWatcher.success', function(data){
            if(data.compiledProcessCount >= 1){
                if(domNode.contentWindow && domNode.contentWindow.document && domNode.contentWindow.document.body){
                    this.contentScrollTop = domNode.contentWindow.document.body.scrollTop;
                } else if(domNode.contentDocument && domNode.contentDocument.documentElement){
                    this.contentScrollTop = domNode.contentDocument.documentElement.scrollTop;
                }
                domNode.src = Repository.getHtmlForDesk();
            }
        }.bind(this));
    },
コード例 #10
0
ファイル: menu.js プロジェクト: Ingvildk/Get-Thirsty
  _setScollPosition: function _setScollPosition() {
    var desktop = this.props.desktop;
    var focusedMenuItem = this.refs.focusedMenuItem;
    var menuItemHeight = desktop ? 32 : 48;

    if (focusedMenuItem) {
      var selectedOffSet = React.findDOMNode(focusedMenuItem).offsetTop;

      //Make the focused item be the 2nd item in the list the
      //user sees
      var scrollTop = selectedOffSet - menuItemHeight;
      if (scrollTop < menuItemHeight) scrollTop = 0;

      React.findDOMNode(this.refs.scrollContainer).scrollTop = scrollTop;
    }
  },
コード例 #11
0
ファイル: wordcloud.test.js プロジェクト: isathish/wordcloud
    it('renders title', function (){
      var title = TestUtils.findRenderedDOMComponentWithClass(wordCloud, 'title'),
        node = React.findDOMNode(title);

      node.textContent.should.be.equal(props.title);
      node.tagName.toLowerCase().should.be.equal('span');
    });
コード例 #12
0
ファイル: DatagridTest.js プロジェクト: King-fly/react-admin
        it('should set header with correct label for each field', () => {
            let datagrid = getDatagrid('myView', 'myEntity', fields, view, router, [], null, null);
            datagrid = React.findDOMNode(datagrid);

            const headers = [].slice.call(datagrid.querySelectorAll('thead th')).map(h => h.textContent);
            expect(headers).toEqual(['#', 'Title', 'Creation date']);
        });
コード例 #13
0
        it('Should display label and default size', () => {
            let showButton = TestUtils.renderIntoDocument(<MaShowButton entityName={'MyEntity'} entry={entry} label={'Show'} size={'xs'} />);
            showButton = React.findDOMNode(showButton);

            expect(showButton.className).toEqual('btn btn-show btn-default btn-xs');
            expect(showButton.innerHTML).toContain('Show');
        });
コード例 #14
0
ファイル: tabs.js プロジェクト: sornon/mui
 getEvenWidth: function(){
   return (
     parseInt(window
       .getComputedStyle(React.findDOMNode(this))
       .getPropertyValue('width'), 10)
   );
 },
コード例 #15
0
ファイル: Dropdown.js プロジェクト: raymondmuller/react-kube
	componentDidMount() {
		let element = React.findDOMNode(this.refs.dropdownOwner);
		let dropdownHeight = element.offsetHeight;
		let posTop = element.offsetTop + dropdownHeight;
		let posLeft = element.offsetLeft;

		this.setState({
			left: posLeft,
			top: posTop
		});

		let listStyle = {
			background: this.props.background,
			color: this.props.color ? this.props.color : "inherit",
			cursor: "pointer",
			display: "block !important",
			left: posLeft,
			top: posTop + (this.props.top ? this.props.top : 0),
			zIndex: 100
		};

		this.dropdownStyle = React.addons.update(this.props.style, {$merge: listStyle});

		//mousedown listener, used to detect clicks outside of the dropdown
		window.addEventListener("mousedown", this.closeDropDown.bind(this));
	}
コード例 #16
0
  _getRippleStyle: function _getRippleStyle(e) {
    var style = {};
    var el = React.findDOMNode(this);
    var elHeight = el.offsetHeight;
    var elWidth = el.offsetWidth;
    var offset = Dom.offset(el);
    var isTouchEvent = e.touches && e.touches.length;
    var pageX = isTouchEvent ? e.touches[0].pageX : e.pageX;
    var pageY = isTouchEvent ? e.touches[0].pageY : e.pageY;
    var pointerX = pageX - offset.left;
    var pointerY = pageY - offset.top;
    var topLeftDiag = this._calcDiag(pointerX, pointerY);
    var topRightDiag = this._calcDiag(elWidth - pointerX, pointerY);
    var botRightDiag = this._calcDiag(elWidth - pointerX, elHeight - pointerY);
    var botLeftDiag = this._calcDiag(pointerX, elHeight - pointerY);
    var rippleRadius = Math.max(topLeftDiag, topRightDiag, botRightDiag, botLeftDiag);
    var rippleSize = rippleRadius * 2;
    var left = pointerX - rippleRadius;
    var top = pointerY - rippleRadius;

    style.height = rippleSize + 'px';
    style.width = rippleSize + 'px';
    style.top = top + 'px';
    style.left = left + 'px';

    return style;
  },
コード例 #17
0
        it('Should display label and size', () => {
            let createButton = TestUtils.renderIntoDocument(<MaCreateButton entityName={'MyEntity'} label={'Hello'} size={'xs'} />);
            createButton = React.findDOMNode(createButton);

            expect(createButton.className).toContain('btn btn-create btn-default btn-xs');
            expect(createButton.innerHTML).toContain('Hello');
        });
コード例 #18
0
  it('User data display correct ', function() {
    var data = {
      username: 'user',
      nickname: 'nickname',
      createdAt: new Date()
    };
    var postMeta = TestUtils.renderIntoDocument(
      <PostMeta username={ data.username } nickname={ data.nickname } createdAt={ data.createdAt } />
    );

    var postMetaDOM = React.findDOMNode(postMeta);

    // Assert link
    var a = postMetaDOM.querySelectorAll('a');
    expect(a[0].getAttribute('href')).to.equal('http://keanux.com/@user');
    expect(a[1].getAttribute('href')).to.equal('http://keanux.com/@user');

    // Assert icon
    var img = postMetaDOM.querySelector('img');
    expect(img.getAttribute('src')).to.equal('https://graph.facebook.com/user/picture?width=120&height=120');

    // Assert child control
    var ago = TestUtils.findRenderedComponentWithType(postMeta, Ago);
    expect(ago.props.date).to.equalDate(data.createdAt);
  });
コード例 #19
0
    it('should display given value', () => {
        let field = TestUtils.renderIntoDocument(<StringColumn value={'Hello'} />);
        field = React.findDOMNode(field);

        expect(field.innerHTML).toBe('Hello');
        expect(field.tagName.toLowerCase()).toBe('span');
    });
コード例 #20
0
    _renderFrameContent: function() {

        var domNode = React.findDOMNode(this);
        var doc = domNode.contentDocument;
        var win = domNode.contentWindow;
        if(doc.readyState === 'complete' && win.endpoint && win.endpoint.Page) {

            //console.log('Page is loaded...');

            Repository.setCurrentPageDocument(doc);
            Repository.setCurrentPageWindow(win);

            //var cssList = Common.getCSSClasses(doc);
            //console.log(JSON.stringify(cssList, null, 4));

            this.frameEndpoint = win.endpoint;
            this.frameEndpoint.onComponentDidUpdate = function(){
                this._mapDomNodes();
            }.bind(this);
            this.frameEndpoint.onComponentWillUpdate = function(){
                DeskPageFrameActions.deselectComponent();
            };
            this._changeFrameContent();

            this._hideModalProgress();

            if(domNode.contentWindow && domNode.contentWindow.document && domNode.contentWindow.document.body){
                domNode.contentWindow.document.body.scrollTop = this.contentScrollTop;
            } else if(domNode.contentDocument && domNode.contentDocument.documentElement){
                domNode.contentDocument.documentElement.scrollTop = this.contentScrollTop;
            }
        }
    },
コード例 #21
0
        it('Should display label', () => {
            let listButton = TestUtils.renderIntoDocument(<MaListButton entityName={'MyEntity'} label={'Hello'} />);
            listButton = React.findDOMNode(listButton);

            expect(listButton.className).toContain('btn btn-list btn-default');
            expect(listButton.innerHTML).toContain('Hello');
        });
コード例 #22
0
 getDOMNode: function () {
   // support react-bootstrap elements
   if (this.element.getInputDOMNode) {
     return this.element.getInputDOMNode();
   }
   return React.findDOMNode(this.element);
 },
コード例 #23
0
        it('Should display label and size', () => {
            let deleteButton = TestUtils.renderIntoDocument(<MaDeleteButton entityName={'MyEntity'} entry={entry} label={'Delete'} size={'xs'} />);
            deleteButton = React.findDOMNode(deleteButton);

            expect(deleteButton.className).toContain('btn btn-delete btn-default btn-xs');
            expect(deleteButton.innerHTML).toContain('Delete');
        });
コード例 #24
0
        it('Should display "No record found"', () => {
            let pagination = getPagination(0, 1, 10);

            pagination = React.findDOMNode(pagination);

            expect(pagination.innerHTML).toContain('No record found.');
        });
コード例 #25
0
ファイル: footer-test.js プロジェクト: mitchbox/react-seed
 it('Should have the correct css class', () => {
   let footer = TestUtils.renderIntoDocument(
     <Footer />
   );
   let footerElem = React.findDOMNode(footer);
   expect(footerElem.className).to.equal('footer');
 });
コード例 #26
0
        it('Should display label and size', () => {
            var backButton = TestUtils.renderIntoDocument(<MaBackButton label={'Hello'} size={'xs'} />);
            backButton = React.findDOMNode(backButton);

            expect(backButton.className).toContain('btn-xs');
            expect(backButton.innerHTML).toContain('Hello');
        });
コード例 #27
0
ファイル: Tooltip.js プロジェクト: catalinmiron/elemental
	componentDidMount: function componentDidMount() {
		var target = React.findDOMNode(this.refs.target);
		this.setState({
			targetHeight: target.offsetHeight,
			targetWidth: target.offsetWidth
		});
	},
コード例 #28
0
function expectSuggestions(expectedSuggestions) {
  suggestions = TestUtils.scryRenderedDOMComponentsWithClass(autosuggest, 'react-autosuggest__suggestion');
  expect(suggestions.length).toBe(expectedSuggestions.length);

  for (let i = 0; i < expectedSuggestions.length; i++) {
    expect(React.findDOMNode(suggestions[i]).textContent).toBe(expectedSuggestions[i]);
  }
}
コード例 #29
0
 this.setState({ open: false }, function () {
   //Set focus on the icon button when the menu close
   if (isKeyboard) {
     var iconButton = _this2.refs[_this2.state.iconButtonRef];
     React.findDOMNode(iconButton).focus();
     iconButton.setKeyboardFocus();
   }
 });
コード例 #30
0
  it('should show counts & mode', () => {
    let fun = jest.genMockFunction();
    let component = TestUtils.renderIntoDocument(
      <ReplStatusBar history={entries}
        mode={'REPL_MODE_MAGIC'}
        showConsole={false}
        showBell={false}
        onToggleConsole={fun}/>
    );
    let command = TestUtils.findRenderedDOMComponentWithClass(component, 'repl-status-bar-commands');
    let error = TestUtils.findRenderedDOMComponentWithClass(component, 'repl-status-bar-errors');
    let mode = TestUtils.findRenderedDOMComponentWithClass(component, 'repl-status-bar-mode');

    expect(React.findDOMNode(command).textContent).toEqual('3');
    expect(React.findDOMNode(error).textContent).toEqual('2');
    expect(React.findDOMNode(mode).textContent).toEqual('magic');
  });