summaryrefslogtreecommitdiff
path: root/date-fns/src/yearsToMonths/test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'date-fns/src/yearsToMonths/test.ts')
-rw-r--r--date-fns/src/yearsToMonths/test.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/date-fns/src/yearsToMonths/test.ts b/date-fns/src/yearsToMonths/test.ts
new file mode 100644
index 0000000..e91231c
--- /dev/null
+++ b/date-fns/src/yearsToMonths/test.ts
@@ -0,0 +1,21 @@
+/* eslint-env mocha */
+
+import assert from 'assert'
+import yearsToMonths from '.'
+
+describe('yearsToMonths', function () {
+ it('converts years to months', function () {
+ assert(yearsToMonths(1) === 12)
+ assert(yearsToMonths(2) === 24)
+ })
+
+ it('uses floor rounding', () => {
+ assert(yearsToMonths(1.7) === 20)
+ assert(yearsToMonths(0.1) === 1)
+ })
+
+ it('handles border values', () => {
+ assert(yearsToMonths(1.5) === 18)
+ assert(yearsToMonths(0) === 0)
+ })
+})