shape.test.scss 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. @use 'sass:map';
  2. @use 'sass:meta';
  3. @use 'sass:list';
  4. @use 'true' as test;
  5. @use '../shape';
  6. @include test.describe('shape') {
  7. @include test.describe('resolver($shape)') {
  8. @include test.it('should return null for all corners if given null') {
  9. // Test Case.
  10. $result: shape.resolver(
  11. $shape: null,
  12. );
  13. // Assertion.
  14. $is-map: meta.type-of($result) == 'map';
  15. @include test.assert-true(
  16. $is-map,
  17. $description: 'Should always return a Map'
  18. );
  19. @include test.assert-equal(
  20. map.get($result, start-start),
  21. null,
  22. $description: 'start-start should be null'
  23. );
  24. @include test.assert-equal(
  25. map.get($result, start-end),
  26. null,
  27. $description: 'start-end should be null'
  28. );
  29. @include test.assert-equal(
  30. map.get($result, end-end),
  31. null,
  32. $description: 'end-end should be null'
  33. );
  34. @include test.assert-equal(
  35. map.get($result, end-start),
  36. null,
  37. $description: 'end-start should be null'
  38. );
  39. }
  40. @include test.it('should expand radius number to all corners') {
  41. // Test Case.
  42. $result: shape.resolver(
  43. $shape: 8px,
  44. );
  45. // Assertion.
  46. $is-map: meta.type-of($result) == 'map';
  47. @include test.assert-true(
  48. $is-map,
  49. $description: 'Should always return a Map'
  50. );
  51. @include test.assert-equal(
  52. map.get($result, start-start),
  53. 8px,
  54. $description: 'start-start should be same as input'
  55. );
  56. @include test.assert-equal(
  57. map.get($result, start-end),
  58. 8px,
  59. $description: 'start-end should be same as input'
  60. );
  61. @include test.assert-equal(
  62. map.get($result, end-end),
  63. 8px,
  64. $description: 'end-end should be same as input'
  65. );
  66. @include test.assert-equal(
  67. map.get($result, end-start),
  68. 8px,
  69. $description: 'end-start should be same as input'
  70. );
  71. }
  72. @include test.it('should expand radius list with 1 to all corners') {
  73. // Test Case.
  74. $result: shape.resolver(
  75. $shape: (
  76. 16px,
  77. ),
  78. );
  79. // Assertion.
  80. $is-map: meta.type-of($result) == 'map';
  81. @include test.assert-true(
  82. $is-map,
  83. $description: 'Should always return a Map'
  84. );
  85. @include test.assert-equal(
  86. map.get($result, start-start),
  87. 16px,
  88. $description: 'start-start should be the first corner'
  89. );
  90. @include test.assert-equal(
  91. map.get($result, start-end),
  92. 16px,
  93. $description: 'start-end should be the first corner'
  94. );
  95. @include test.assert-equal(
  96. map.get($result, end-end),
  97. 16px,
  98. $description: 'end-end should be the first corner'
  99. );
  100. @include test.assert-equal(
  101. map.get($result, end-start),
  102. 16px,
  103. $description: 'end-start should be the first corner'
  104. );
  105. }
  106. @include test.it('should expand radius list with 2 to correct corners') {
  107. // Test Case.
  108. $result: shape.resolver(
  109. $shape: (
  110. 8px,
  111. 16px,
  112. ),
  113. );
  114. // Assertion.
  115. $is-map: meta.type-of($result) == 'map';
  116. @include test.assert-true(
  117. $is-map,
  118. $description: 'Should always return a Map'
  119. );
  120. @include test.assert-equal(
  121. map.get($result, start-start),
  122. 8px,
  123. $description: 'start-start should be the first corner'
  124. );
  125. @include test.assert-equal(
  126. map.get($result, start-end),
  127. 16px,
  128. $description: 'start-end should be the second corner'
  129. );
  130. @include test.assert-equal(
  131. map.get($result, end-end),
  132. 8px,
  133. $description: 'end-end should be the first corner'
  134. );
  135. @include test.assert-equal(
  136. map.get($result, end-start),
  137. 16px,
  138. $description: 'end-start should be the second corner'
  139. );
  140. }
  141. @include test.it('should expand radius list with 3 to correct corners') {
  142. // Test Case.
  143. $result: shape.resolver(
  144. $shape: (
  145. 8px,
  146. 16px,
  147. 24px,
  148. ),
  149. );
  150. // Assertion.
  151. $is-map: meta.type-of($result) == 'map';
  152. @include test.assert-true(
  153. $is-map,
  154. $description: 'Should always return a Map'
  155. );
  156. @include test.assert-equal(
  157. map.get($result, start-start),
  158. 8px,
  159. $description: 'start-start should be the first corner'
  160. );
  161. @include test.assert-equal(
  162. map.get($result, start-end),
  163. 16px,
  164. $description: 'start-end should be the second corner'
  165. );
  166. @include test.assert-equal(
  167. map.get($result, end-end),
  168. 24px,
  169. $description: 'end-end should be the third corner'
  170. );
  171. @include test.assert-equal(
  172. map.get($result, end-start),
  173. 16px,
  174. $description: 'end-start should be the second corner'
  175. );
  176. }
  177. @include test.it('should expand radius list with 4 to correct corners') {
  178. // Test Case.
  179. $result: shape.resolver(
  180. $shape: (
  181. 8px,
  182. 16px,
  183. 24px,
  184. 0,
  185. ),
  186. );
  187. // Assertion.
  188. $is-map: meta.type-of($result) == 'map';
  189. @include test.assert-true(
  190. $is-map,
  191. $description: 'Should always return a Map'
  192. );
  193. @include test.assert-equal(
  194. map.get($result, start-start),
  195. 8px,
  196. $description: 'start-start should be the first corner'
  197. );
  198. @include test.assert-equal(
  199. map.get($result, start-end),
  200. 16px,
  201. $description: 'start-end should be the second corner'
  202. );
  203. @include test.assert-equal(
  204. map.get($result, end-end),
  205. 24px,
  206. $description: 'end-end should be the third corner'
  207. );
  208. @include test.assert-equal(
  209. map.get($result, end-start),
  210. 0,
  211. $description: 'end-start should be the fourth corner'
  212. );
  213. }
  214. }
  215. }