Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(CSSTransition): pass 'appearing' param from Transition to CSSTransition #144

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/CSSTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class CSSTransition extends React.Component {
const { className } = this.getClassNames(appearing ? 'appear' : 'enter')

this.removeClasses(node, 'exit');
addClass(node, className)
addClass(node, className);

if (this.props.onEnter) {
this.props.onEnter(node)
this.props.onEnter(node, appearing);
}
}

Expand All @@ -128,10 +128,10 @@ class CSSTransition extends React.Component {
appearing ? 'appear' : 'enter'
);

this.reflowAndAddClass(node, activeClassName)
this.reflowAndAddClass(node, activeClassName);

if (this.props.onEntering) {
this.props.onEntering(node)
this.props.onEntering(node, appearing);
}
}

Expand All @@ -142,7 +142,7 @@ class CSSTransition extends React.Component {
addClass(node, doneClassName);

if (this.props.onEntered) {
this.props.onEntered(node)
this.props.onEntered(node, appearing);
}
}

Expand Down
67 changes: 66 additions & 1 deletion test/CSSTransition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ describe('CSSTransition', () => {
>
<div/>
</CSSTransition>
);
)
.render();

instance.setProps({
in: true,
Expand All @@ -111,6 +112,70 @@ describe('CSSTransition', () => {
}
});
});

describe('isAppearing', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored it to create 2 new tests - one for false and one for true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was also a bit confusing that this didn't work for the false part (because this pattern did work for the 'true' part):

it('should be false', done => {

        instance = tsp(
          <CSSTransition
            timeout={10}
            classNames="test"
            in={true}
          >
            <div/>
          </CSSTransition>
        )
          .render();


        instance.props({
          /* no in:true goes here..*/
         onEnter() ....


it('should be false', done => {

instance = tsp(
<CSSTransition
timeout={10}
classNames="test"
>
<div/>
</CSSTransition>
)
.render();


instance.props({
in: true,
onEnter(node, isAppearing){
expect(isAppearing).toEqual(false);
},

onEntering(node, isAppearing){
expect(isAppearing).toEqual(false);
},

onEntered(node, isAppearing){
expect(isAppearing).toEqual(false);
done();
}
});
});

it('should be true', done => {

instance = tsp(
<CSSTransition
timeout={10}
appear={true}
in={true}
classNames="test"
>
<div/>
</CSSTransition>
)
.render();

instance.props({
onEnter(node, isAppearing){
expect(isAppearing).toEqual(true);
},

onEntering(node, isAppearing){
expect(isAppearing).toEqual(true);
},

onEntered(node, isAppearing){
expect(isAppearing).toEqual(true);
done();
}
});
});

});
});

describe('exiting', ()=> {
Expand Down