epic-loading-animations
Version:
Spinners and Transitions to use in React apps
21 lines (20 loc) • 1 kB
text/typescript
import gradientList from "./gradient-list";
describe('GradientList', () => {
it('should throw an error if a color is not in hexadecimal form', () => {
expect(() => gradientList({startColor: "CICICI", endColor: "111111", numBars: 4}))
.toThrow("Invalid color, must be in hexadecimal format");
});
it('should return list of length 5 if num lines is 5', () => {
const list = gradientList({startColor: "#C1C1C1", endColor: "#111111", numBars: 5});
expect(list.length).toEqual(5);
});
it('should return a list where the start color is first and end color is last', () => {
const list = gradientList({startColor: "#C1C1C1", endColor: "#111111", numBars: 5});
expect(list[0]).toEqual("#C1C1C1");
expect(list.pop()).toEqual("#111111");
});
it('should return an array of colors that form a gradient', () => {
const list = gradientList({startColor: "#333333", endColor: "#111111", numBars: 3});
expect(list).toEqual(["#333333", "#222222", "#111111"])
});
});