@automattic/simple-components
Version:
React components, as used on WordPress.com
105 lines (86 loc) • 3.42 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _chai = require("chai");
var _enzyme = require("enzyme");
var _lodash = require("lodash");
var _react = _interopRequireDefault(require("react"));
var _index = require("../index");
/** @format */
/**
* External dependencies
*/
/**
* Internal dependencies
*/
describe('Notice', function () {
test('should output the component', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.notice').length);
});
test('should have dismiss button when showDismiss passed as true', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
showDismiss: true,
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-dismissable').length);
});
test('should have dismiss button by default if isCompact is false', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
isCompact: false,
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-dismissable').length);
});
test('should have compact look when isCompact passed as true', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
isCompact: true,
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-compact').length);
});
test('should not have dismiss button by default if isCompact is true', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
isCompact: true,
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-dismissable').length === 0);
});
test('should have dismiss button when showDismiss is true and isCompact is true', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
isCompact: true,
showDismiss: true,
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-dismissable').length);
});
test('should have proper class for is-info status parameter', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
status: "is-info",
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-info').length);
});
test('should have proper class for is-success status parameter', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
status: "is-success",
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-success').length);
});
test('should have proper class for is-error status parameter', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
status: "is-error",
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-error').length);
});
test('should have proper class for is-warning status parameter', function () {
var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.Notice, {
status: "is-warning",
translate: _lodash.identity
}));
_chai.assert.isOk(wrapper.find('.is-warning').length);
});
});