is-dotted-decimal.test.js 559 B

123456789101112131415161718192021222324
  1. 'use strict'
  2. const tap = require('tap')
  3. const isDottedDecimal = require('./is-dotted-decimal')
  4. tap.test('false for non-string', async t => {
  5. t.equal(isDottedDecimal(), false)
  6. })
  7. tap.test('false for empty string', async t => {
  8. t.equal(isDottedDecimal(''), false)
  9. })
  10. tap.test('false for alpha string', async t => {
  11. t.equal(isDottedDecimal('foo'), false)
  12. })
  13. tap.test('false for alpha-num string', async t => {
  14. t.equal(isDottedDecimal('foo.123'), false)
  15. })
  16. tap.test('true for valid string', async t => {
  17. t.equal(isDottedDecimal('1.2.3'), true)
  18. })