Skip to content

Commit 142f7a1

Browse files
committed
add tests for hexToRGB function and _arrowCSS border color
1 parent 518399e commit 142f7a1

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

public/js/spec/models/arrow_spec.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ describe("CSSArrowPlease.Arrow", function () {
9696

9797
});
9898

99+
describe('convert hex color to rgb color', function () {
100+
101+
it('converts "#888"', function () {
102+
expect( arrow.hexToRGB('#888') ).toEqual([136 , 136 , 136]);
103+
});
104+
105+
it('converts "#88B7D5"', function () {
106+
expect( arrow.hexToRGB('#88B7D5') ).toEqual([136, 183, 213]);
107+
});
108+
109+
it('converts "#C2E1F5"', function () {
110+
expect( arrow.hexToRGB('#C2E1F5') ).toEqual([194, 225, 245]);
111+
});
112+
113+
it('returns [0, 0, 0] if there is no input color', function () {
114+
expect( arrow.hexToRGB() ).toEqual([0, 0, 0]);
115+
});
116+
117+
it('returns [0, 0, 0] if the input color is invalid', function () {
118+
expect( arrow.hexToRGB('invalid') ).toEqual([0, 0, 0]);
119+
});
120+
121+
});
122+
99123
describe('toCSS', function () {
100124

101125
describe('baseCSS', function () {
@@ -177,8 +201,9 @@ describe("CSSArrowPlease.Arrow", function () {
177201
});
178202

179203
it('it has the correct color', function () {
180-
var expected = 'border-bottom-color: #888';
181-
expect( arrow._arrowCSS('#888', 20) ).toMatch( expected );
204+
var css = arrow._arrowCSS('#888', 20);
205+
expect( css ).toMatch( 'border-bottom-color: #888' );
206+
expect( css ).toMatch( 'border-color: rgba\\(136, 136, 136, 0\\)' );
182207
});
183208

184209
describe('position top', function () {

0 commit comments

Comments
 (0)