parsers.test.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. 'use strict';
  2. const parsers = require('./parsers');
  3. describe('valueType', () => {
  4. it('returns color for red', () => {
  5. let input = 'red';
  6. let output = parsers.valueType(input);
  7. expect(output).toEqual(parsers.TYPES.COLOR);
  8. });
  9. it('returns color for #nnnnnn', () => {
  10. let input = '#fefefe';
  11. let output = parsers.valueType(input);
  12. expect(output).toEqual(parsers.TYPES.COLOR);
  13. });
  14. it('returns color for rgb(n, n, n)', () => {
  15. let input = 'rgb(10, 10, 10)';
  16. let output = parsers.valueType(input);
  17. expect(output).toEqual(parsers.TYPES.COLOR);
  18. });
  19. it('returns color for rgb(p, p, p)', () => {
  20. let input = 'rgb(10%, 10%, 10%)';
  21. let output = parsers.valueType(input);
  22. expect(output).toEqual(parsers.TYPES.COLOR);
  23. });
  24. it('returns color for rgba(n, n, n, n)', () => {
  25. let input = 'rgba(10, 10, 10, 1)';
  26. let output = parsers.valueType(input);
  27. expect(output).toEqual(parsers.TYPES.COLOR);
  28. });
  29. it('returns color for rgba(n, n, n, n) with decimal alpha', () => {
  30. let input = 'rgba(10, 10, 10, 0.5)';
  31. let output = parsers.valueType(input);
  32. expect(output).toEqual(parsers.TYPES.COLOR);
  33. });
  34. it('returns color for rgba(p, p, p, n)', () => {
  35. let input = 'rgba(10%, 10%, 10%, 1)';
  36. let output = parsers.valueType(input);
  37. expect(output).toEqual(parsers.TYPES.COLOR);
  38. });
  39. it('returns color for rgba(p, p, p, n) with decimal alpha', () => {
  40. let input = 'rgba(10%, 10%, 10%, 0.5)';
  41. let output = parsers.valueType(input);
  42. expect(output).toEqual(parsers.TYPES.COLOR);
  43. });
  44. it('returns length for 100ch', () => {
  45. let input = '100ch';
  46. let output = parsers.valueType(input);
  47. expect(output).toEqual(parsers.TYPES.LENGTH);
  48. });
  49. it('returns calc from calc(100px * 2)', () => {
  50. let input = 'calc(100px * 2)';
  51. let output = parsers.valueType(input);
  52. expect(output).toEqual(parsers.TYPES.CALC);
  53. });
  54. });
  55. describe('parseInteger', () => {
  56. it.todo('test');
  57. });
  58. describe('parseNumber', () => {
  59. it.todo('test');
  60. });
  61. describe('parseLength', () => {
  62. it.todo('test');
  63. });
  64. describe('parsePercent', () => {
  65. it.todo('test');
  66. });
  67. describe('parseMeasurement', () => {
  68. it.todo('test');
  69. });
  70. describe('parseUrl', () => {
  71. it.todo('test');
  72. });
  73. describe('parseString', () => {
  74. it.todo('test');
  75. });
  76. describe('parseColor', () => {
  77. it('should convert hsl to rgb values', () => {
  78. let input = 'hsla(0, 1%, 2%)';
  79. let output = parsers.parseColor(input);
  80. expect(output).toEqual('rgb(5, 5, 5)');
  81. });
  82. it('should convert hsla to rgba values', () => {
  83. let input = 'hsla(0, 1%, 2%, 0.5)';
  84. let output = parsers.parseColor(input);
  85. expect(output).toEqual('rgba(5, 5, 5, 0.5)');
  86. });
  87. it.todo('Add more tests');
  88. });
  89. describe('parseAngle', () => {
  90. it.todo('test');
  91. });
  92. describe('parseKeyword', () => {
  93. it.todo('test');
  94. });
  95. describe('dashedToCamelCase', () => {
  96. it.todo('test');
  97. });
  98. describe('shorthandParser', () => {
  99. it.todo('test');
  100. });
  101. describe('shorthandSetter', () => {
  102. it.todo('test');
  103. });
  104. describe('shorthandGetter', () => {
  105. it.todo('test');
  106. });
  107. describe('implicitSetter', () => {
  108. it.todo('test');
  109. });
  110. describe('subImplicitSetter', () => {
  111. it.todo('test');
  112. });
  113. describe('camelToDashed', () => {
  114. it.todo('test');
  115. });