Repository URL to install this package:
|
Version:
1.2.9 ▾
|
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @flow
const react_1 = __importDefault(require("react"));
const enzyme_1 = require("enzyme");
const utils_1 = require("./utils");
let styled;
describe('warn too many classes', () => {
const nativeWarn = console.warn;
let warnCallCount;
/**
* Make sure the setup is the same for every test
*/
beforeEach(() => {
;
console.warn = () => warnCallCount++;
warnCallCount = 0;
styled = utils_1.resetStyled();
});
afterEach(() => {
;
console.warn = nativeWarn;
});
it('should warn once', () => {
const Comp = styled.div `
width: ${props => props.size};
`;
for (let i = 0; i < 300; i++) {
enzyme_1.shallow(react_1.default.createElement(Comp, { size: i }));
}
expect(warnCallCount).toEqual(1);
});
it('should warn if number of classes is 200', () => {
const Comp = styled.div `
width: ${props => props.size};
`;
for (let i = 0; i < 200; i++) {
enzyme_1.shallow(react_1.default.createElement(Comp, { size: i }));
}
expect(warnCallCount).toEqual(1);
});
it('should not warn if number of classes is below 200', () => {
const Comp = styled.div `
width: ${props => props.size};
`;
for (let i = 0; i < 199; i++) {
enzyme_1.shallow(react_1.default.createElement(Comp, { size: i }));
}
expect(warnCallCount).toEqual(0);
});
});
//# sourceMappingURL=warnTooManyClasses.test.js.map