cssstyle 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,146 +0,0 @@
1
- 'use strict';
2
-
3
- const parsers = require('./parsers');
4
-
5
- describe('valueType', () => {
6
- it('returns color for red', () => {
7
- let input = 'red';
8
- let output = parsers.valueType(input);
9
-
10
- expect(output).toEqual(parsers.TYPES.COLOR);
11
- });
12
-
13
- it('returns color for #nnnnnn', () => {
14
- let input = '#fefefe';
15
- let output = parsers.valueType(input);
16
-
17
- expect(output).toEqual(parsers.TYPES.COLOR);
18
- });
19
-
20
- it('returns color for rgb(n, n, n)', () => {
21
- let input = 'rgb(10, 10, 10)';
22
- let output = parsers.valueType(input);
23
-
24
- expect(output).toEqual(parsers.TYPES.COLOR);
25
- });
26
-
27
- it('returns color for rgb(p, p, p)', () => {
28
- let input = 'rgb(10%, 10%, 10%)';
29
- let output = parsers.valueType(input);
30
-
31
- expect(output).toEqual(parsers.TYPES.COLOR);
32
- });
33
-
34
- it('returns color for rgba(n, n, n, n)', () => {
35
- let input = 'rgba(10, 10, 10, 1)';
36
- let output = parsers.valueType(input);
37
-
38
- expect(output).toEqual(parsers.TYPES.COLOR);
39
- });
40
-
41
- it('returns color for rgba(n, n, n, n) with decimal alpha', () => {
42
- let input = 'rgba(10, 10, 10, 0.5)';
43
- let output = parsers.valueType(input);
44
-
45
- expect(output).toEqual(parsers.TYPES.COLOR);
46
- });
47
-
48
- it('returns color for rgba(p, p, p, n)', () => {
49
- let input = 'rgba(10%, 10%, 10%, 1)';
50
- let output = parsers.valueType(input);
51
-
52
- expect(output).toEqual(parsers.TYPES.COLOR);
53
- });
54
-
55
- it('returns color for rgba(p, p, p, n) with decimal alpha', () => {
56
- let input = 'rgba(10%, 10%, 10%, 0.5)';
57
- let output = parsers.valueType(input);
58
-
59
- expect(output).toEqual(parsers.TYPES.COLOR);
60
- });
61
-
62
- it('returns length for 100ch', () => {
63
- let input = '100ch';
64
- let output = parsers.valueType(input);
65
-
66
- expect(output).toEqual(parsers.TYPES.LENGTH);
67
- });
68
-
69
- it('returns calc from calc(100px * 2)', () => {
70
- let input = 'calc(100px * 2)';
71
- let output = parsers.valueType(input);
72
-
73
- expect(output).toEqual(parsers.TYPES.CALC);
74
- });
75
- });
76
- describe('parseInteger', () => {
77
- it.todo('test');
78
- });
79
- describe('parseNumber', () => {
80
- it.todo('test');
81
- });
82
- describe('parseLength', () => {
83
- it.todo('test');
84
- });
85
- describe('parsePercent', () => {
86
- it.todo('test');
87
- });
88
- describe('parseMeasurement', () => {
89
- it.todo('test');
90
- });
91
- describe('parseUrl', () => {
92
- it.todo('test');
93
- });
94
- describe('parseString', () => {
95
- it.todo('test');
96
- });
97
- describe('parseColor', () => {
98
- it('should convert hsl to rgb values', () => {
99
- let input = 'hsla(0, 1%, 2%)';
100
- let output = parsers.parseColor(input);
101
-
102
- expect(output).toEqual('rgb(5, 5, 5)');
103
- });
104
- it('should convert hsla to rgba values', () => {
105
- let input = 'hsla(0, 1%, 2%, 0.5)';
106
- let output = parsers.parseColor(input);
107
-
108
- expect(output).toEqual('rgba(5, 5, 5, 0.5)');
109
- });
110
- it.each([
111
- [120, 'rgb(0, 255, 0)'],
112
- [240, 'rgb(0, 0, 255)'],
113
- ])('should convert not zero hsl with non zero hue %s to %s', (hue, rgbValue) => {
114
- let input = 'hsl(' + hue + ', 100%, 50%)';
115
- let output = parsers.parseColor(input);
116
- expect(output).toEqual(rgbValue);
117
- });
118
- it.todo('Add more tests');
119
- });
120
- describe('parseAngle', () => {
121
- it.todo('test');
122
- });
123
- describe('parseKeyword', () => {
124
- it.todo('test');
125
- });
126
- describe('dashedToCamelCase', () => {
127
- it.todo('test');
128
- });
129
- describe('shorthandParser', () => {
130
- it.todo('test');
131
- });
132
- describe('shorthandSetter', () => {
133
- it.todo('test');
134
- });
135
- describe('shorthandGetter', () => {
136
- it.todo('test');
137
- });
138
- describe('implicitSetter', () => {
139
- it.todo('test');
140
- });
141
- describe('subImplicitSetter', () => {
142
- it.todo('test');
143
- });
144
- describe('camelToDashed', () => {
145
- it.todo('test');
146
- });
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- const MAX_HUE = 360;
4
- const COLOR_NB = 12;
5
- const MAX_RGB_VALUE = 255;
6
-
7
- // https://www.w3.org/TR/css-color-4/#hsl-to-rgb
8
- exports.hslToRgb = (hue, sat, light) => {
9
- hue = hue % MAX_HUE;
10
- if (hue < 0) {
11
- hue += MAX_HUE;
12
- }
13
- function f(n) {
14
- const k = (n + hue / (MAX_HUE / COLOR_NB)) % COLOR_NB;
15
- const a = sat * Math.min(light, 1 - light);
16
- return light - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
17
- }
18
- return [f(0), f(8), f(4)].map((value) => Math.round(value * MAX_RGB_VALUE));
19
- };