summaryrefslogtreecommitdiff
path: root/date-fns/src/getDecade/test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'date-fns/src/getDecade/test.ts')
-rw-r--r--date-fns/src/getDecade/test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/date-fns/src/getDecade/test.ts b/date-fns/src/getDecade/test.ts
new file mode 100644
index 0000000..8e93bb7
--- /dev/null
+++ b/date-fns/src/getDecade/test.ts
@@ -0,0 +1,26 @@
+// @flow
+/* eslint-env mocha */
+
+import assert from 'power-assert'
+import getDecade from '.'
+
+describe('getDecade', function() {
+ it('returns the decade for a the given date', function() {
+ const result = getDecade(new Date(1971, 10 /* Nov */, 8))
+ assert(result === 1970)
+ })
+
+ it('accepts a timestamp', function() {
+ const result = getDecade(new Date(1969, 6 /* Jul */, 20).getTime())
+ assert(result === 1960)
+ })
+
+ it('returns NaN if the given date is invalid', function() {
+ const result = getDecade(new Date(NaN))
+ assert(isNaN(result))
+ })
+
+ it('throws TypeError exception if passed less than 1 argument', function() {
+ assert.throws(getDecade.bind(null), TypeError)
+ })
+})