generated from codibre/boilerplate-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea61ab1
commit 50a10b1
Showing
12 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ module.exports = { | |
'build/**', | ||
'bin/**', | ||
'templates/**', | ||
'docs/**', | ||
'*.py', | ||
'.eslintrc.js', | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { SonicDate } from 'src/sonic-date'; | ||
|
||
describe('addYears', () => { | ||
it('adds the given number of years', () => { | ||
const result = new SonicDate(2014, 8 /* Sep */, 1).addYears(5); | ||
expect(result).toEqual(new Date(2019, 8 /* Sep */, 1)); | ||
}); | ||
|
||
it('does mutate the original date', () => { | ||
const date = new SonicDate(2014, 8 /* Sep */, 1); | ||
date.addYears(12); | ||
expect(date).toEqual(new Date(2026, 8 /* Sep */, 1)); | ||
}); | ||
|
||
it('handles the leap years properly', () => { | ||
const result = new SonicDate(2016, 1 /* Feb */, 29).addYears(1); | ||
expect(result).toEqual(new Date(2017, 1 /* Feb */, 28)); | ||
}); | ||
|
||
it('handles dates before 100 AD', () => { | ||
const initialDate = new SonicDate(0); | ||
initialDate.setFullYear(0, 1 /* Feb */, 29); | ||
initialDate.setHours(0, 0, 0, 0); | ||
const expectedResult = new Date(0); | ||
expectedResult.setFullYear(1, 1 /* Feb */, 28); | ||
expectedResult.setHours(0, 0, 0, 0); | ||
const result = initialDate.addYears(1); | ||
expect(result).toEqual(expectedResult); | ||
}); | ||
|
||
it('returns `Invalid Date` if the given date is invalid', () => { | ||
const result = new SonicDate(NaN).addYears(5); | ||
expect(result instanceof Date && isNaN(result.getTime())).toBe(true); | ||
}); | ||
|
||
it('returns `Invalid Date` if the given amount is NaN', () => { | ||
const result = new SonicDate(2014, 8 /* Sep */, 1).addYears(NaN); | ||
expect(result instanceof Date && isNaN(result.getTime())).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"sourceMap": false | ||
"sourceMap": false, | ||
"rootDir": "src" | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"test", | ||
"dist", | ||
"**/*spec.ts" | ||
] | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters