Skip to content

Commit

Permalink
test: use modern Jest API instead of Jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
silvenon committed Apr 6, 2019
1 parent 45426d7 commit 27271b7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
1 change: 0 additions & 1 deletion test/.eslintrc.yml
@@ -1,7 +1,6 @@

env:
jest: true
jasmine: true
rules:
no-require: off
global-require: off
Expand Down
8 changes: 0 additions & 8 deletions test/CSSTransition-test.js
Expand Up @@ -3,14 +3,6 @@ import { mount } from 'enzyme';

import CSSTransition from '../src/CSSTransition';

jasmine.addMatchers({
toExist: () => ({
compare: actual => ({
pass: actual != null,
})
})
});

describe('CSSTransition', () => {

it('should flush new props to the DOM before initiating a transition', (done) => {
Expand Down
9 changes: 7 additions & 2 deletions test/CSSTransitionGroup-test.js
Expand Up @@ -9,6 +9,7 @@ let TransitionGroup;
// makes sure we're wired up correctly.
describe('CSSTransitionGroup', () => {
let container;
let consoleErrorSpy;

function YoloTransition({ id, ...props }) {
return (
Expand All @@ -28,7 +29,11 @@ describe('CSSTransitionGroup', () => {
TransitionGroup = require('../src/TransitionGroup');

container = document.createElement('div');
spyOn(console, 'error');
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
});

afterEach(() => {
consoleErrorSpy.mockRestore();
});


Expand All @@ -55,7 +60,7 @@ describe('CSSTransitionGroup', () => {
jest.runAllTimers();

// No warnings
expect(console.error.calls.count()).toBe(0);
expect(consoleErrorSpy).not.toHaveBeenCalled();

// The leaving child has been removed
expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
Expand Down
17 changes: 11 additions & 6 deletions test/Transition-test.js
Expand Up @@ -11,12 +11,17 @@ import Transition, {
EXITING,
} from '../src/Transition'

jasmine.addMatchers({
toExist: () => ({
compare: actual => ({
pass: actual != null,
}),
}),
expect.extend({
toExist(received) {
const pass = received != null
return pass ? {
message: () => `expected ${received} to be null or undefined`,
pass: true,
} : {
message: () => `expected ${received} not to be null or undefined`,
pass: false,
}
},
})

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

0 comments on commit 27271b7

Please sign in to comment.