'use strict';
const semver = require('semver');
let shouldPass;
let isFocused;
describe('transform-react-version-pragma', () => {
const originalTest = test;
const _test_react_version = (range, testName, cb) => {
originalTest(testName, (...args) => {
shouldPass = !!semver.satisfies('18.0.0', range);
return cb(...args);
});
};
const _test_react_version_focus = (range, testName, cb) => {
originalTest(testName, (...args) => {
shouldPass = !!semver.satisfies('18.0.0', range);
isFocused = true;
return cb(...args);
});
};
const _test_ignore_for_react_version = (testName, cb) => {
originalTest(testName, (...args) => {
shouldPass = false;
return cb(...args);
});
};
beforeEach(() => {
shouldPass = null;
isFocused = false;
});
it('reactVersion flag is on >=', () => {
expect(shouldPass).toBe(true);
});
it('reactVersion flag is off >=', () => {
expect(shouldPass).toBe(false);
});
it('reactVersion flag is on <=', () => {
expect(shouldPass).toBe(true);
});
it('reactVersion flag is off <=', () => {
expect(shouldPass).toBe(false);
});
it('reactVersion flag is on >', () => {
expect(shouldPass).toBe(true);
});
it('reactVersion flag is off >', () => {
expect(shouldPass).toBe(false);
});
it('reactVersion flag is on <', () => {
expect(shouldPass).toBe(true);
});
it('reactVersion flag is off <', () => {
expect(shouldPass).toBe(false);
});
it('reactVersion flag is on =', () => {
expect(shouldPass).toBe(true);
});
it('reactVersion flag is off =', () => {
expect(shouldPass).toBe(false);
});
it.only('reactVersion fit', () => {
expect(shouldPass).toBe(false);
expect(isFocused).toBe(true);
});
it.only('reactVersion test.only', () => {
expect(shouldPass).toBe(true);
expect(isFocused).toBe(true);
});
it('reactVersion multiple pragmas fail', () => {
expect(shouldPass).toBe(false);
expect(isFocused).toBe(false);
});
it('reactVersion multiple pragmas pass', () => {
expect(shouldPass).toBe(true);
expect(isFocused).toBe(false);
});
it.only('reactVersion focused multiple pragmas fail', () => {
expect(shouldPass).toBe(false);
expect(isFocused).toBe(true);
});
it.only('reactVersion focused multiple pragmas pass', () => {
expect(shouldPass).toBe(true);
expect(isFocused).toBe(true);
});
});