mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Increase prettier line width to 100 (#20535)
* Increase prettier line width to 100 * Fix packages JS prettier * Change style guide to 100 width * Fix line-width in latest master changes
This commit is contained in:
parent
433f8a919c
commit
cb5ee01c6a
126 changed files with 380 additions and 1272 deletions
|
@ -33,10 +33,7 @@ const isValidDate = d => isDate(d) && !isNaN(d.valueOf());
|
|||
* will be done using this (and its locale settings) instead of the one bundled
|
||||
* with this library.
|
||||
*/
|
||||
function parse(
|
||||
text,
|
||||
{ roundUp = false, momentInstance = moment, forceNow } = {}
|
||||
) {
|
||||
function parse(text, { roundUp = false, momentInstance = moment, forceNow } = {}) {
|
||||
if (!text) return undefined;
|
||||
if (momentInstance.isMoment(text)) return text;
|
||||
if (isDate(text)) return momentInstance(text);
|
||||
|
|
|
@ -54,12 +54,9 @@ describe('dateMath', function() {
|
|||
expect(dateMath.parse('now&1d')).to.be(undefined);
|
||||
});
|
||||
|
||||
it(
|
||||
'should return undefined if I pass a unit besides' + spans.toString(),
|
||||
function() {
|
||||
expect(dateMath.parse('now+5f')).to.be(undefined);
|
||||
}
|
||||
);
|
||||
it('should return undefined if I pass a unit besides' + spans.toString(), function() {
|
||||
expect(dateMath.parse('now+5f')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('should return undefined if rounding unit is not 1', function() {
|
||||
expect(dateMath.parse('now/2y')).to.be(undefined);
|
||||
|
@ -74,21 +71,16 @@ describe('dateMath', function() {
|
|||
|
||||
describe('forceNow', function() {
|
||||
it('should throw an Error if passed a string', function() {
|
||||
const fn = () =>
|
||||
dateMath.parse('now', { forceNow: '2000-01-01T00:00:00.000Z' });
|
||||
const fn = () => dateMath.parse('now', { forceNow: '2000-01-01T00:00:00.000Z' });
|
||||
expect(fn).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an Error if passed a moment', function() {
|
||||
expect(() =>
|
||||
dateMath.parse('now', { forceNow: moment() })
|
||||
).to.throwError();
|
||||
expect(() => dateMath.parse('now', { forceNow: moment() })).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an Error if passed an invalid date', function() {
|
||||
expect(() =>
|
||||
dateMath.parse('now', { forceNow: new Date('foobar') })
|
||||
).to.throwError();
|
||||
expect(() => dateMath.parse('now', { forceNow: new Date('foobar') })).to.throwError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -128,9 +120,7 @@ describe('dateMath', function() {
|
|||
});
|
||||
|
||||
it('should use the forceNow parameter when parsing now', function() {
|
||||
expect(
|
||||
dateMath.parse('now', { forceNow: anchoredDate }).valueOf()
|
||||
).to.eql(unix);
|
||||
expect(dateMath.parse('now', { forceNow: anchoredDate }).valueOf()).to.eql(unix);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -164,9 +154,7 @@ describe('dateMath', function() {
|
|||
});
|
||||
|
||||
it('should return ' + len + span + ' before forceNow', function() {
|
||||
const parsed = dateMath
|
||||
.parse(nowEx, { forceNow: anchoredDate })
|
||||
.valueOf();
|
||||
const parsed = dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf();
|
||||
expect(parsed).to.eql(anchored.subtract(len, span).valueOf());
|
||||
});
|
||||
});
|
||||
|
@ -193,9 +181,7 @@ describe('dateMath', function() {
|
|||
const thenEx = `${anchor}||+${len}${span}`;
|
||||
|
||||
it('should return ' + len + span + ' from now', function() {
|
||||
expect(dateMath.parse(nowEx).format(format)).to.eql(
|
||||
now.add(len, span).format(format)
|
||||
);
|
||||
expect(dateMath.parse(nowEx).format(format)).to.eql(now.add(len, span).format(format));
|
||||
});
|
||||
|
||||
it('should return ' + len + span + ' after ' + anchor, function() {
|
||||
|
@ -205,9 +191,9 @@ describe('dateMath', function() {
|
|||
});
|
||||
|
||||
it('should return ' + len + span + ' after forceNow', function() {
|
||||
expect(
|
||||
dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf()
|
||||
).to.eql(anchored.add(len, span).valueOf());
|
||||
expect(dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf()).to.eql(
|
||||
anchored.add(len, span).valueOf()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -235,22 +221,20 @@ describe('dateMath', function() {
|
|||
});
|
||||
|
||||
it(`should round now to the beginning of forceNow's ${span}`, function() {
|
||||
expect(
|
||||
dateMath.parse('now/' + span, { forceNow: anchoredDate }).valueOf()
|
||||
).to.eql(anchored.startOf(span).valueOf());
|
||||
expect(dateMath.parse('now/' + span, { forceNow: anchoredDate }).valueOf()).to.eql(
|
||||
anchored.startOf(span).valueOf()
|
||||
);
|
||||
});
|
||||
|
||||
it(`should round now to the end of the ${span}`, function() {
|
||||
expect(
|
||||
dateMath.parse('now/' + span, { roundUp: true }).format(format)
|
||||
).to.eql(now.endOf(span).format(format));
|
||||
expect(dateMath.parse('now/' + span, { roundUp: true }).format(format)).to.eql(
|
||||
now.endOf(span).format(format)
|
||||
);
|
||||
});
|
||||
|
||||
it(`should round now to the end of forceNow's ${span}`, function() {
|
||||
expect(
|
||||
dateMath
|
||||
.parse('now/' + span, { roundUp: true, forceNow: anchoredDate })
|
||||
.valueOf()
|
||||
dateMath.parse('now/' + span, { roundUp: true, forceNow: anchoredDate }).valueOf()
|
||||
).to.eql(anchored.endOf(span).valueOf());
|
||||
});
|
||||
});
|
||||
|
@ -336,9 +320,7 @@ describe('dateMath', function() {
|
|||
});
|
||||
|
||||
it('should round relative to forceNow', function() {
|
||||
const val = dateMath
|
||||
.parse('now-0s/s', { forceNow: anchoredDate })
|
||||
.valueOf();
|
||||
const val = dateMath.parse('now-0s/s', { forceNow: anchoredDate }).valueOf();
|
||||
expect(val).to.eql(anchored.startOf('s').valueOf());
|
||||
});
|
||||
|
||||
|
@ -402,29 +384,11 @@ describe('dateMath', function() {
|
|||
|
||||
describe('units', function() {
|
||||
it('should have units descending for unitsDesc', function() {
|
||||
expect(dateMath.unitsDesc).to.eql([
|
||||
'y',
|
||||
'M',
|
||||
'w',
|
||||
'd',
|
||||
'h',
|
||||
'm',
|
||||
's',
|
||||
'ms',
|
||||
]);
|
||||
expect(dateMath.unitsDesc).to.eql(['y', 'M', 'w', 'd', 'h', 'm', 's', 'ms']);
|
||||
});
|
||||
|
||||
it('should have units ascending for unitsAsc', function() {
|
||||
expect(dateMath.unitsAsc).to.eql([
|
||||
'ms',
|
||||
's',
|
||||
'm',
|
||||
'h',
|
||||
'd',
|
||||
'w',
|
||||
'M',
|
||||
'y',
|
||||
]);
|
||||
expect(dateMath.unitsAsc).to.eql(['ms', 's', 'm', 'h', 'd', 'w', 'M', 'y']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue