diff --git a/format.js b/format.js index 7c41960..00725dc 100644 --- a/format.js +++ b/format.js @@ -68,7 +68,7 @@ function toOffset(offsetMinutes) { const absoluteOffset = Math.abs(offsetMinutes); const hours = toTwoDigits(Math.floor(absoluteOffset / 60)); const minutes = toTwoDigits(absoluteOffset % 60); - const sign = offsetMinutes >= 0 ? '-' : '+'; + const sign = offsetMinutes > 0 ? '-' : '+'; return `${sign}${hours}${minutes}`; } diff --git a/test/format.spec.js b/test/format.spec.js index 9c43d52..1d73b61 100644 --- a/test/format.spec.js +++ b/test/format.spec.js @@ -16,19 +16,19 @@ describe('toTwoDigits', () => { expect(toTwoDigits(value)).toBe(expected) }) - test('throws TypeError if provided value is Infinity', () => { + it('throws TypeError if provided value is Infinity', () => { expect(() => toTwoDigits(Infinity)).toThrow(TypeError) }) - test('throws TypeError if provided value is NaN', () => { + it('throws TypeError if provided value is NaN', () => { expect(() => toTwoDigits(NaN)).toThrow(TypeError) }) - test('throws TypeError if provided value is a decimal number', () => { + it('throws TypeError if provided value is a decimal number', () => { expect(() => toTwoDigits(0.99)).toThrow(TypeError) }) - test('throws TypeError if provided value is a string', () => { + it('throws TypeError if provided value is a string', () => { expect(() => toTwoDigits('0')).toThrow(TypeError) }) }) @@ -42,19 +42,19 @@ describe('toOffset', () => { expect(toOffset(value)).toBe(expected) }) - test('throws TypeError if provided value is Infinity', () => { + it('throws TypeError if provided value is Infinity', () => { expect(() => toOffset(Infinity)).toThrow(TypeError) }) - test('throws TypeError if provided value is NaN', () => { + it('throws TypeError if provided value is NaN', () => { expect(() => toOffset(NaN)).toThrow(TypeError) }) - test('throws TypeError if provided value is a decimal number', () => { + it('throws TypeError if provided value is a decimal number', () => { expect(() => toOffset(60.5)).toThrow(TypeError) }) - test('throws TypeError if provided value is a string', () => { + it('throws TypeError if provided value is a string', () => { expect(() => toOffset('60')).toThrow(TypeError) }) }) @@ -77,19 +77,19 @@ describe('toShortMonth', () => { expect(toShortMonth(value)).toBe(expected) }) - test('throws TypeError for a non-valid month number', () => { + it('throws TypeError for a non-valid month number', () => { expect(() => toShortMonth(13)).toThrow(TypeError) }) }) describe('toCommonAccessLogDateFormat', () => { - test('correctly formats a date', () => { + it('correctly formats a date', () => { const date = new Date('2020-01-01T12:34:56Z') const expectedValue = '01/Jan/2020:10:34:56 +0200' expect(toCommonAccessLogDateFormat(date)).toBe(expectedValue) }) - test('throws TypeError for non-Date value', () => { + it('throws TypeError for non-Date value', () => { expect(() => toCommonAccessLogDateFormat({})).toThrow(TypeError) }) }) \ No newline at end of file