unit.test.js 623 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const assert = require('assert');
  3. const unit = require('../util/unit');
  4. describe('unit', function () {
  5. it('unit', function () {
  6. assert.deepEqual(unit('.23rem'), {
  7. number: '.23',
  8. unit: 'rem',
  9. });
  10. assert.deepEqual(unit('.2.3rem'), {
  11. number: '.2',
  12. unit: '.3rem',
  13. });
  14. assert.deepEqual(unit('2.'), {
  15. number: '2.',
  16. unit: '',
  17. });
  18. assert.deepEqual(unit('+2.'), {
  19. number: '+2.',
  20. unit: '',
  21. });
  22. assert.deepEqual(unit('+-2.'), false);
  23. assert.deepEqual(unit('.'), false);
  24. assert.deepEqual(unit('.rem'), false);
  25. });
  26. });