@scoir/date
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -5,6 +5,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
@@ -16,4 +14,4 @@ var _momentTimezone = _interopRequireDefault(require("moment-timezone")); | ||
var DateFormatter = { | ||
format: function format(date) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
format: function format(date, _temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
defaultText = _ref.defaultText, | ||
@@ -24,10 +22,10 @@ inputFormat = _ref.inputFormat, | ||
if (!(0, _isCredibleDate.default)(date)) { | ||
if (!(0, _isCredibleDate["default"])(date)) { | ||
return defaultText; | ||
} | ||
return (0, _momentTimezone.default)(date, inputFormat).format(outputFormat); | ||
return (0, _momentTimezone["default"])(date, inputFormat).format(outputFormat); | ||
} | ||
}; | ||
var _default = DateFormatter; | ||
exports.default = _default; | ||
exports["default"] = _default; |
@@ -24,34 +24,34 @@ "use strict"; | ||
beforeEach(function () { | ||
_isCredibleDate.default.mockReturnValueOnce(true); | ||
_isCredibleDate["default"].mockReturnValueOnce(true); | ||
(0, _momentTimezone.default)().format.mockClear(); | ||
(0, _momentTimezone["default"])().format.mockClear(); | ||
}); | ||
it('should return the default date if the input is invalid', function () { | ||
_isCredibleDate.default.mockReset(); | ||
_isCredibleDate["default"].mockReset(); | ||
_isCredibleDate.default.mockReturnValueOnce(false); | ||
_isCredibleDate["default"].mockReturnValueOnce(false); | ||
expect(_formatter.default.format('my bad date')).toBeUndefined(); | ||
expect(_isCredibleDate.default).toHaveBeenCalledWith('my bad date'); | ||
expect(_formatter["default"].format('my bad date')).toBeUndefined(); | ||
expect(_isCredibleDate["default"]).toHaveBeenCalledWith('my bad date'); | ||
_isCredibleDate.default.mockClear(); | ||
_isCredibleDate["default"].mockClear(); | ||
expect(_formatter.default.format('my bad date', { | ||
expect(_formatter["default"].format('my bad date', { | ||
defaultText: 'N/A' | ||
})).toEqual('N/A'); | ||
expect(_isCredibleDate.default).toHaveBeenCalledWith('my bad date'); | ||
expect(_isCredibleDate["default"]).toHaveBeenCalledWith('my bad date'); | ||
}); | ||
it('should allow the formatting of the input type', function () { | ||
expect(_formatter.default.format('01-02-03', { | ||
expect(_formatter["default"].format('01-02-03', { | ||
inputFormat: 'MM-YY-DD' | ||
})).toEqual('format-result'); | ||
expect(_momentTimezone.default).toHaveBeenCalledWith('01-02-03', 'MM-YY-DD'); | ||
expect(_momentTimezone["default"]).toHaveBeenCalledWith('01-02-03', 'MM-YY-DD'); | ||
}); | ||
it('should allow the formatting of the output type', function () { | ||
expect(_formatter.default.format('01-02-03', { | ||
expect(_formatter["default"].format('01-02-03', { | ||
outputFormat: 'Mon DD' | ||
})).toEqual('format-result'); | ||
var mockInstance = (0, _momentTimezone.default)(); | ||
var mockInstance = (0, _momentTimezone["default"])(); | ||
expect(mockInstance.format).toHaveBeenCalledWith('Mon DD'); | ||
}); | ||
}); |
@@ -5,20 +5,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "formatter", { | ||
enumerable: true, | ||
get: function get() { | ||
return _formatter.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isCredibleDate", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isCredibleDate.default; | ||
} | ||
}); | ||
exports.__esModule = true; | ||
exports.isCredibleDate = exports.formatter = void 0; | ||
var _formatter = _interopRequireDefault(require("./formatter")); | ||
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date")); | ||
exports.formatter = _formatter["default"]; | ||
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date")); | ||
exports.isCredibleDate = _isCredibleDate["default"]; |
@@ -5,6 +5,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.__esModule = true; | ||
exports["default"] = void 0; | ||
@@ -16,5 +14,5 @@ var _includes = _interopRequireDefault(require("lodash/includes")); | ||
var _default = function _default(input) { | ||
return !(0, _includes.default)(EMPTY_FORMAT, input); | ||
return !(0, _includes["default"])(EMPTY_FORMAT, input); | ||
}; | ||
exports.default = _default; | ||
exports["default"] = _default; |
@@ -8,10 +8,10 @@ "use strict"; | ||
it('should return false for "invalid" dates', function () { | ||
expect((0, _isCredibleDate.default)(undefined)).toBe(false); | ||
expect((0, _isCredibleDate.default)(null)).toBe(false); | ||
expect((0, _isCredibleDate.default)('0001-01-01')).toBe(false); | ||
expect((0, _isCredibleDate.default)('')).toBe(false); | ||
expect((0, _isCredibleDate.default)('0001-01-01T00:00:00Z')).toBe(false); | ||
expect((0, _isCredibleDate["default"])(undefined)).toBe(false); | ||
expect((0, _isCredibleDate["default"])(null)).toBe(false); | ||
expect((0, _isCredibleDate["default"])('0001-01-01')).toBe(false); | ||
expect((0, _isCredibleDate["default"])('')).toBe(false); | ||
expect((0, _isCredibleDate["default"])('0001-01-01T00:00:00Z')).toBe(false); | ||
}); | ||
it('should return true for actual dates', function () { | ||
expect((0, _isCredibleDate.default)('2012-02-05')).toBe(true); | ||
expect((0, _isCredibleDate["default"])('2012-02-05')).toBe(true); | ||
}); |
{ | ||
"name": "@scoir/date", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "@scoir", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
9093
177