@deessejs/type-testing 0.1.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.
Files changed (119) hide show
  1. package/.eslintrc.json +7 -0
  2. package/.turbo/turbo-lint.log +24 -0
  3. package/.turbo/turbo-test.log +23 -0
  4. package/.turbo/turbo-typecheck.log +4 -0
  5. package/CHANGELOG.md +7 -0
  6. package/README.md +303 -0
  7. package/coverage/base.css +224 -0
  8. package/coverage/block-navigation.js +87 -0
  9. package/coverage/coverage-final.json +15 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +146 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/sort-arrow-sprite.png +0 -0
  15. package/coverage/sorter.js +210 -0
  16. package/coverage/src/api/assert.ts.html +229 -0
  17. package/coverage/src/api/check.ts.html +586 -0
  18. package/coverage/src/api/expect.ts.html +220 -0
  19. package/coverage/src/api/index.html +161 -0
  20. package/coverage/src/api/index.ts.html +106 -0
  21. package/coverage/src/index.html +131 -0
  22. package/coverage/src/index.ts.html +127 -0
  23. package/coverage/src/types/equality.ts.html +190 -0
  24. package/coverage/src/types/function.ts.html +139 -0
  25. package/coverage/src/types/index.html +221 -0
  26. package/coverage/src/types/index.ts.html +121 -0
  27. package/coverage/src/types/inhabitation.ts.html +160 -0
  28. package/coverage/src/types/length.ts.html +109 -0
  29. package/coverage/src/types/property.ts.html +124 -0
  30. package/coverage/src/types/special.ts.html +274 -0
  31. package/coverage/src/types/union.ts.html +193 -0
  32. package/coverage/src/utils.ts.html +136 -0
  33. package/dist/api/assert.d.ts +43 -0
  34. package/dist/api/assert.d.ts.map +1 -0
  35. package/dist/api/assert.js +7 -0
  36. package/dist/api/assert.js.map +1 -0
  37. package/dist/api/check.d.ts +138 -0
  38. package/dist/api/check.d.ts.map +1 -0
  39. package/dist/api/check.js +17 -0
  40. package/dist/api/check.js.map +1 -0
  41. package/dist/api/expect.d.ts +35 -0
  42. package/dist/api/expect.d.ts.map +1 -0
  43. package/dist/api/expect.js +21 -0
  44. package/dist/api/expect.js.map +1 -0
  45. package/dist/api/index.d.ts +7 -0
  46. package/dist/api/index.d.ts.map +1 -0
  47. package/dist/api/index.js +7 -0
  48. package/dist/api/index.js.map +1 -0
  49. package/dist/index.d.ts +9 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +12 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/index.test.d.ts +8 -0
  54. package/dist/index.test.d.ts.map +1 -0
  55. package/dist/index.test.js +264 -0
  56. package/dist/index.test.js.map +1 -0
  57. package/dist/types/equality.d.ts +30 -0
  58. package/dist/types/equality.d.ts.map +1 -0
  59. package/dist/types/equality.js +5 -0
  60. package/dist/types/equality.js.map +1 -0
  61. package/dist/types/function.d.ts +16 -0
  62. package/dist/types/function.d.ts.map +1 -0
  63. package/dist/types/function.js +5 -0
  64. package/dist/types/function.js.map +1 -0
  65. package/dist/types/index.d.ts +11 -0
  66. package/dist/types/index.d.ts.map +1 -0
  67. package/dist/types/index.js +12 -0
  68. package/dist/types/index.js.map +1 -0
  69. package/dist/types/inhabitation.d.ts +24 -0
  70. package/dist/types/inhabitation.d.ts.map +1 -0
  71. package/dist/types/inhabitation.js +5 -0
  72. package/dist/types/inhabitation.js.map +1 -0
  73. package/dist/types/length.d.ts +8 -0
  74. package/dist/types/length.d.ts.map +1 -0
  75. package/dist/types/length.js +5 -0
  76. package/dist/types/length.js.map +1 -0
  77. package/dist/types/property.d.ts +12 -0
  78. package/dist/types/property.d.ts.map +1 -0
  79. package/dist/types/property.js +5 -0
  80. package/dist/types/property.js.map +1 -0
  81. package/dist/types/special.d.ts +55 -0
  82. package/dist/types/special.d.ts.map +1 -0
  83. package/dist/types/special.js +5 -0
  84. package/dist/types/special.js.map +1 -0
  85. package/dist/types/union.d.ts +34 -0
  86. package/dist/types/union.d.ts.map +1 -0
  87. package/dist/types/union.js +5 -0
  88. package/dist/types/union.js.map +1 -0
  89. package/dist/utils.d.ts +14 -0
  90. package/dist/utils.d.ts.map +1 -0
  91. package/dist/utils.js +5 -0
  92. package/dist/utils.js.map +1 -0
  93. package/package.json +27 -0
  94. package/public/icon.png +0 -0
  95. package/src/api/assert.ts +48 -0
  96. package/src/api/check.ts +167 -0
  97. package/src/api/expect.ts +45 -0
  98. package/src/api/index.ts +7 -0
  99. package/src/index.ts +14 -0
  100. package/src/types/equality.ts +35 -0
  101. package/src/types/function.ts +18 -0
  102. package/src/types/index.ts +12 -0
  103. package/src/types/inhabitation.ts +25 -0
  104. package/src/types/length.ts +8 -0
  105. package/src/types/property.ts +13 -0
  106. package/src/types/special.ts +63 -0
  107. package/src/types/union.ts +36 -0
  108. package/src/utils.ts +17 -0
  109. package/tests/api.test.ts +40 -0
  110. package/tests/equality.test.ts +57 -0
  111. package/tests/function.test.ts +32 -0
  112. package/tests/inhabitation.test.ts +40 -0
  113. package/tests/length.test.ts +18 -0
  114. package/tests/property.test.ts +35 -0
  115. package/tests/special.test.ts +132 -0
  116. package/tests/union.test.ts +58 -0
  117. package/tests/utils.test.ts +20 -0
  118. package/tsconfig.json +9 -0
  119. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../eslint.config.js",
3
+ "rules": {
4
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "typeParamsIgnorePattern": "^_" }],
5
+ "@typescript-eslint/no-explicit-any": "off"
6
+ }
7
+ }
@@ -0,0 +1,24 @@
1
+
2
+ > @deessejs/type-testing@0.1.0 lint C:\Users\dpereira\Documents\github\type-testing\packages\type-testing
3
+ > eslint src --ext .ts,.tsx
4
+
5
+ (node:10876) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///C:/Users/dpereira/Documents/github/type-testing/eslint.config.js?mtime=1772199688344 is not specified and it doesn't parse as CommonJS.
6
+ Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
7
+ To eliminate this warning, add "type": "module" to C:\Users\dpereira\Documents\github\type-testing\package.json.
8
+ (Use `node --trace-warnings ...` to show where the warning was created)
9
+
10
+ C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\assert.ts
11
+ 43:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
12
+
13
+ C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\check.ts
14
+ 21:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
15
+
16
+ C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\expect.ts
17
+ 25:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
18
+
19
+ C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\utils.ts
20
+ 11:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
21
+
22
+ ✖ 4 problems (0 errors, 4 warnings)
23
+ 0 errors and 4 warnings potentially fixable with the `--fix` option.
24
+
@@ -0,0 +1,23 @@
1
+
2
+ > @deessejs/type-testing@0.1.0 test C:\Users\dpereira\Documents\github\type-testing\packages\type-testing
3
+ > vitest run
4
+
5
+ The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
6
+
7
+  RUN  v2.1.9 C:/Users/dpereira/Documents/github/type-testing/packages/type-testing
8
+
9
+ ✓ tests/inhabitation.test.ts (6 tests) 4ms
10
+ ✓ tests/property.test.ts (5 tests) 4ms
11
+ ✓ tests/equality.test.ts (9 tests) 5ms
12
+ ✓ tests/special.test.ts (22 tests) 7ms
13
+ ✓ tests/function.test.ts (4 tests) 4ms
14
+ ✓ tests/union.test.ts (9 tests) 5ms
15
+ ✓ tests/length.test.ts (2 tests) 3ms
16
+ ✓ tests/utils.test.ts (2 tests) 4ms
17
+ ✓ tests/api.test.ts (4 tests) 5ms
18
+
19
+  Test Files  9 passed (9)
20
+  Tests  63 passed (63)
21
+  Start at  15:29:08
22
+  Duration  1.15s (transform 557ms, setup 0ms, collect 1.04s, tests 40ms, environment 3ms, prepare 2.60s)
23
+
@@ -0,0 +1,4 @@
1
+
2
+ > @deessejs/type-testing@0.1.0 typecheck C:\Users\dpereira\Documents\github\type-testing\packages\type-testing
3
+ > tsc --noEmit
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @deessejs/type-testing
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Initial release of @deessejs/type-testing - A micro library for compile-time type testing in TypeScript
package/README.md ADDED
@@ -0,0 +1,303 @@
1
+ # @deessejs/type-testing
2
+
3
+ ![Type Testing](./public/icon.png)
4
+
5
+ A micro library for compile-time type testing in TypeScript.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@deessejs/type-testing.svg)](https://www.npmjs.com/package/@deessejs/type-testing)
8
+ [![npm bundle size](https://img.shields.io/bundlejs/size/@deessejs/type-testing)](https://www.npmjs.com/package/@deessejs/type-testing)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @deessejs/type-testing
16
+ ```
17
+
18
+ Or with pnpm:
19
+
20
+ ```bash
21
+ pnpm add @deessejs/type-testing
22
+ ```
23
+
24
+ Or with yarn:
25
+
26
+ ```bash
27
+ yarn add @deessejs/type-testing
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```typescript
33
+ import { Equal, check, assert, expect } from '@deessejs/type-testing'
34
+
35
+ // Simple type equality
36
+ type Test = Equal<string, string> // true
37
+
38
+ // Chainable API
39
+ check<string>().equals<string>() // passes
40
+
41
+ // Assert with clear errors
42
+ assert<{ a: string }>().hasProperty('a')
43
+
44
+ // Expect syntax
45
+ expect<string, string>().toBeEqual()
46
+ ```
47
+
48
+ ## Core Types
49
+
50
+ ### Type Equality
51
+
52
+ ```typescript
53
+ import { Equal, NotEqual, SimpleEqual } from '@deessejs/type-testing'
54
+
55
+ // Strict equality (handles any, never, etc.)
56
+ Equal<string, string> // true
57
+ Equal<string, number> // false
58
+
59
+ // Inequality check
60
+ NotEqual<string, number> // true
61
+
62
+ // Simple equality (for plain objects)
63
+ SimpleEqual<{ a: string }, { a: string }> // true
64
+ ```
65
+
66
+ ### Special Type Detection
67
+
68
+ ```typescript
69
+ import {
70
+ IsAny,
71
+ IsNever,
72
+ IsUnknown,
73
+ IsVoid,
74
+ IsUndefined,
75
+ IsNull,
76
+ IsNullable,
77
+ IsOptional
78
+ } from '@deessejs/type-testing'
79
+
80
+ IsAny<any> // true
81
+ IsNever<never> // true
82
+ IsUnknown<unknown> // true
83
+ IsVoid<void> // true
84
+ IsUndefined<undefined> // true
85
+ IsNull<null> // true
86
+
87
+ // Nullable = null | undefined
88
+ IsNullable<string | null> // true
89
+ IsNullable<string | undefined> // true
90
+
91
+ // Optional = may include undefined
92
+ IsOptional<string | undefined> // true
93
+ ```
94
+
95
+ ### Union, Tuple & Array
96
+
97
+ ```typescript
98
+ import { IsUnion, IsTuple, IsArray } from '@deessejs/type-testing'
99
+
100
+ // Unions
101
+ IsUnion<'a' | 'b'> // true
102
+ IsUnion<'a'> // false
103
+
104
+ // Tuples (fixed-length arrays)
105
+ IsTuple<[string, number]> // true
106
+ IsTuple<[]> // true
107
+ IsTuple<string[]> // false
108
+
109
+ // Arrays (dynamic-length)
110
+ IsArray<string[]> // true
111
+ IsArray<[string]> // false
112
+ ```
113
+
114
+ ### Type Inhabitation
115
+
116
+ ```typescript
117
+ import { IsInhabited, IsUninhabited } from '@deessejs/type-testing'
118
+
119
+ // Has at least one value
120
+ IsInhabited<string> // true
121
+ IsInhabited<never> // false
122
+
123
+ // Has no values (never)
124
+ IsUninhabited<never> // true
125
+ IsUninhabited<string> // false
126
+ ```
127
+
128
+ ### Property Testing
129
+
130
+ ```typescript
131
+ import { HasProperty, PropertyType } from '@deessejs/type-testing'
132
+
133
+ // Check if type has a property
134
+ HasProperty<{ a: string }, 'a'> // true
135
+ HasProperty<{ a: string }, 'b'> // false
136
+
137
+ // Get property type
138
+ PropertyType<{ a: string }, 'a'> // string
139
+ ```
140
+
141
+ ### Function Types
142
+
143
+ ```typescript
144
+ import { Parameters, ReturnType, Parameter } from '@deessejs/type-testing'
145
+
146
+ // Get parameters as tuple
147
+ Parameters<(a: string, b: number) => void> // [string, number]
148
+
149
+ // Get return type
150
+ ReturnType<(a: string) => number> // number
151
+
152
+ // Get parameter at index
153
+ Parameter<(a: string, b: number), 0> // string
154
+ Parameter<(a: string, b: number), 1> // number
155
+ ```
156
+
157
+ ### Length
158
+
159
+ ```typescript
160
+ import { Length } from '@deessejs/type-testing'
161
+
162
+ Length<['a', 'b', 'c']> // 3
163
+ Length<[]> // 0
164
+ ```
165
+
166
+ ## Chainable API
167
+
168
+ ### check() - Soft type checking
169
+
170
+ ```typescript
171
+ import { check } from '@deessejs/type-testing'
172
+
173
+ // Type equality
174
+ check<string>().equals<string>() // passes
175
+ check<string>().equals<number>() // fails at compile time
176
+
177
+ // Type extends
178
+ check<string>().extends<string>() // passes
179
+ check<string>().extends<any>() // passes
180
+
181
+ // Property check
182
+ check<{ a: string }>().hasProperty('a') // passes
183
+ check<{ a: string }>().hasProperty('b') // fails
184
+
185
+ // Special types
186
+ check<any>().isAny() // passes
187
+ check<never>().isNever() // passes
188
+ check<unknown>().isUnknown() // passes
189
+
190
+ // Nullable/Optional
191
+ check<string | null>().isNullable() // passes
192
+ check<string | undefined>().isOptional() // passes
193
+
194
+ // Union/Tuple/Array
195
+ check<'a' | 'b'>().isUnion() // passes
196
+ check<[string, number]>().isTuple() // passes
197
+ check<string[]>().isArray() // passes
198
+ ```
199
+
200
+ ### assert() - Strict type checking
201
+
202
+ Similar to `check()` but throws at compile time on failure with a clearer error message.
203
+
204
+ ```typescript
205
+ import { assert } from '@deessejs/type-testing'
206
+
207
+ // Fails with a clear error message
208
+ assert<string>().equals<number>() // compile error
209
+ assert<{ a: string }>().hasProperty('b') // compile error
210
+ ```
211
+
212
+ ### expect() - BDD-style API
213
+
214
+ ```typescript
215
+ import { expect } from '@deessejs/type-testing'
216
+
217
+ // Compare two types
218
+ expect<string, string>().toBeEqual() // passes
219
+ expect<string, number>().toBeNotEqual() // passes
220
+
221
+ // Type extends
222
+ expect<string>().toExtend<string>() // passes
223
+
224
+ // Special types
225
+ expect<any>().toBeAny() // passes
226
+ expect<never>().toBeNever() // passes
227
+
228
+ // Nullable/Optional
229
+ expect<string | null>().toBeNullable() // passes
230
+ expect<string | undefined>().toBeOptional() // passes
231
+ ```
232
+
233
+ ## Compile-time Assertions
234
+
235
+ ### ExpectTrue & ExpectEqual
236
+
237
+ ```typescript
238
+ import { ExpectTrue, ExpectEqual } from '@deessejs/type-testing'
239
+
240
+ // Assert a type is true
241
+ type Test1 = ExpectTrue<true> // true
242
+
243
+ // Assert equality - throws if not equal
244
+ type Test2 = ExpectEqual<string, string> // string
245
+
246
+ // Using with type tests
247
+ type IsString<T> = ExpectEqual<T, string>
248
+ type Result = IsString<string> // string (passes)
249
+ ```
250
+
251
+ ### expectFalse
252
+
253
+ ```typescript
254
+ import { expectFalse } from '@deessejs/type-testing'
255
+
256
+ // Assert T is false at compile time
257
+ expectFalse<false>() // passes
258
+ expectFalse<true>() // compile error
259
+ ```
260
+
261
+ ## API Reference
262
+
263
+ ### Types
264
+
265
+ | Type | Description |
266
+ |------|-------------|
267
+ | `Equal<T, U>` | Strict equality check |
268
+ | `NotEqual<T, U>` | Inequality check |
269
+ | `SimpleEqual<T, U>` | Simple equality for plain types |
270
+ | `IsAny<T>` | Check if type is `any` |
271
+ | `IsNever<T>` | Check if type is `never` |
272
+ | `IsUnknown<T>` | Check if type is `unknown` |
273
+ | `IsVoid<T>` | Check if type is `void` |
274
+ | `IsUndefined<T>` | Check if type is `undefined` |
275
+ | `IsNull<T>` | Check if type is `null` |
276
+ | `IsNullable<T>` | Check if type is `null \| undefined` |
277
+ | `IsOptional<T>` | Check if type may be `undefined` |
278
+ | `IsUnion<T>` | Check if type is a union |
279
+ | `IsTuple<T>` | Check if type is a tuple |
280
+ | `IsArray<T>` | Check if type is an array |
281
+ | `IsInhabited<T>` | Check if type has at least one value |
282
+ | `IsUninhabited<T>` | Check if type has no values |
283
+ | `HasProperty<T, K>` | Check if type has property K |
284
+ | `PropertyType<T, K>` | Get type of property K |
285
+ | `Parameters<T>` | Get function parameters as tuple |
286
+ | `ReturnType<T>` | Get function return type |
287
+ | `Parameter<T, N>` | Get parameter at index N |
288
+ | `Length<T>` | Get tuple/array length |
289
+ | `ExpectTrue<T>` | Assert T is true |
290
+ | `ExpectEqual<T, U>` | Assert T equals U |
291
+
292
+ ### Functions
293
+
294
+ | Function | Description |
295
+ |----------|-------------|
296
+ | `check<T>()` | Create a chainable type checker |
297
+ | `assert<T>()` | Create an assert type checker (throws on failure) |
298
+ | `expect<T, U>()` | Create an expect-style type checker |
299
+ | `expectFalse<T>()` | Assert T is false at compile time |
300
+
301
+ ## License
302
+
303
+ MIT
@@ -0,0 +1,224 @@
1
+ body, html {
2
+ margin:0; padding: 0;
3
+ height: 100%;
4
+ }
5
+ body {
6
+ font-family: Helvetica Neue, Helvetica, Arial;
7
+ font-size: 14px;
8
+ color:#333;
9
+ }
10
+ .small { font-size: 12px; }
11
+ *, *:after, *:before {
12
+ -webkit-box-sizing:border-box;
13
+ -moz-box-sizing:border-box;
14
+ box-sizing:border-box;
15
+ }
16
+ h1 { font-size: 20px; margin: 0;}
17
+ h2 { font-size: 14px; }
18
+ pre {
19
+ font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
20
+ margin: 0;
21
+ padding: 0;
22
+ -moz-tab-size: 2;
23
+ -o-tab-size: 2;
24
+ tab-size: 2;
25
+ }
26
+ a { color:#0074D9; text-decoration:none; }
27
+ a:hover { text-decoration:underline; }
28
+ .strong { font-weight: bold; }
29
+ .space-top1 { padding: 10px 0 0 0; }
30
+ .pad2y { padding: 20px 0; }
31
+ .pad1y { padding: 10px 0; }
32
+ .pad2x { padding: 0 20px; }
33
+ .pad2 { padding: 20px; }
34
+ .pad1 { padding: 10px; }
35
+ .space-left2 { padding-left:55px; }
36
+ .space-right2 { padding-right:20px; }
37
+ .center { text-align:center; }
38
+ .clearfix { display:block; }
39
+ .clearfix:after {
40
+ content:'';
41
+ display:block;
42
+ height:0;
43
+ clear:both;
44
+ visibility:hidden;
45
+ }
46
+ .fl { float: left; }
47
+ @media only screen and (max-width:640px) {
48
+ .col3 { width:100%; max-width:100%; }
49
+ .hide-mobile { display:none!important; }
50
+ }
51
+
52
+ .quiet {
53
+ color: #7f7f7f;
54
+ color: rgba(0,0,0,0.5);
55
+ }
56
+ .quiet a { opacity: 0.7; }
57
+
58
+ .fraction {
59
+ font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
60
+ font-size: 10px;
61
+ color: #555;
62
+ background: #E8E8E8;
63
+ padding: 4px 5px;
64
+ border-radius: 3px;
65
+ vertical-align: middle;
66
+ }
67
+
68
+ div.path a:link, div.path a:visited { color: #333; }
69
+ table.coverage {
70
+ border-collapse: collapse;
71
+ margin: 10px 0 0 0;
72
+ padding: 0;
73
+ }
74
+
75
+ table.coverage td {
76
+ margin: 0;
77
+ padding: 0;
78
+ vertical-align: top;
79
+ }
80
+ table.coverage td.line-count {
81
+ text-align: right;
82
+ padding: 0 5px 0 20px;
83
+ }
84
+ table.coverage td.line-coverage {
85
+ text-align: right;
86
+ padding-right: 10px;
87
+ min-width:20px;
88
+ }
89
+
90
+ table.coverage td span.cline-any {
91
+ display: inline-block;
92
+ padding: 0 5px;
93
+ width: 100%;
94
+ }
95
+ .missing-if-branch {
96
+ display: inline-block;
97
+ margin-right: 5px;
98
+ border-radius: 3px;
99
+ position: relative;
100
+ padding: 0 4px;
101
+ background: #333;
102
+ color: yellow;
103
+ }
104
+
105
+ .skip-if-branch {
106
+ display: none;
107
+ margin-right: 10px;
108
+ position: relative;
109
+ padding: 0 4px;
110
+ background: #ccc;
111
+ color: white;
112
+ }
113
+ .missing-if-branch .typ, .skip-if-branch .typ {
114
+ color: inherit !important;
115
+ }
116
+ .coverage-summary {
117
+ border-collapse: collapse;
118
+ width: 100%;
119
+ }
120
+ .coverage-summary tr { border-bottom: 1px solid #bbb; }
121
+ .keyline-all { border: 1px solid #ddd; }
122
+ .coverage-summary td, .coverage-summary th { padding: 10px; }
123
+ .coverage-summary tbody { border: 1px solid #bbb; }
124
+ .coverage-summary td { border-right: 1px solid #bbb; }
125
+ .coverage-summary td:last-child { border-right: none; }
126
+ .coverage-summary th {
127
+ text-align: left;
128
+ font-weight: normal;
129
+ white-space: nowrap;
130
+ }
131
+ .coverage-summary th.file { border-right: none !important; }
132
+ .coverage-summary th.pct { }
133
+ .coverage-summary th.pic,
134
+ .coverage-summary th.abs,
135
+ .coverage-summary td.pct,
136
+ .coverage-summary td.abs { text-align: right; }
137
+ .coverage-summary td.file { white-space: nowrap; }
138
+ .coverage-summary td.pic { min-width: 120px !important; }
139
+ .coverage-summary tfoot td { }
140
+
141
+ .coverage-summary .sorter {
142
+ height: 10px;
143
+ width: 7px;
144
+ display: inline-block;
145
+ margin-left: 0.5em;
146
+ background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
147
+ }
148
+ .coverage-summary .sorted .sorter {
149
+ background-position: 0 -20px;
150
+ }
151
+ .coverage-summary .sorted-desc .sorter {
152
+ background-position: 0 -10px;
153
+ }
154
+ .status-line { height: 10px; }
155
+ /* yellow */
156
+ .cbranch-no { background: yellow !important; color: #111; }
157
+ /* dark red */
158
+ .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
159
+ .low .chart { border:1px solid #C21F39 }
160
+ .highlighted,
161
+ .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
162
+ background: #C21F39 !important;
163
+ }
164
+ /* medium red */
165
+ .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
166
+ /* light red */
167
+ .low, .cline-no { background:#FCE1E5 }
168
+ /* light green */
169
+ .high, .cline-yes { background:rgb(230,245,208) }
170
+ /* medium green */
171
+ .cstat-yes { background:rgb(161,215,106) }
172
+ /* dark green */
173
+ .status-line.high, .high .cover-fill { background:rgb(77,146,33) }
174
+ .high .chart { border:1px solid rgb(77,146,33) }
175
+ /* dark yellow (gold) */
176
+ .status-line.medium, .medium .cover-fill { background: #f9cd0b; }
177
+ .medium .chart { border:1px solid #f9cd0b; }
178
+ /* light yellow */
179
+ .medium { background: #fff4c2; }
180
+
181
+ .cstat-skip { background: #ddd; color: #111; }
182
+ .fstat-skip { background: #ddd; color: #111 !important; }
183
+ .cbranch-skip { background: #ddd !important; color: #111; }
184
+
185
+ span.cline-neutral { background: #eaeaea; }
186
+
187
+ .coverage-summary td.empty {
188
+ opacity: .5;
189
+ padding-top: 4px;
190
+ padding-bottom: 4px;
191
+ line-height: 1;
192
+ color: #888;
193
+ }
194
+
195
+ .cover-fill, .cover-empty {
196
+ display:inline-block;
197
+ height: 12px;
198
+ }
199
+ .chart {
200
+ line-height: 0;
201
+ }
202
+ .cover-empty {
203
+ background: white;
204
+ }
205
+ .cover-full {
206
+ border-right: none !important;
207
+ }
208
+ pre.prettyprint {
209
+ border: none !important;
210
+ padding: 0 !important;
211
+ margin: 0 !important;
212
+ }
213
+ .com { color: #999 !important; }
214
+ .ignore-none { color: #999; font-weight: normal; }
215
+
216
+ .wrapper {
217
+ min-height: 100%;
218
+ height: auto !important;
219
+ height: 100%;
220
+ margin: 0 auto -48px;
221
+ }
222
+ .footer, .push {
223
+ height: 48px;
224
+ }
@@ -0,0 +1,87 @@
1
+ /* eslint-disable */
2
+ var jumpToCode = (function init() {
3
+ // Classes of code we would like to highlight in the file view
4
+ var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
5
+
6
+ // Elements to highlight in the file listing view
7
+ var fileListingElements = ['td.pct.low'];
8
+
9
+ // We don't want to select elements that are direct descendants of another match
10
+ var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
+
12
+ // Selector that finds elements on the page to which we can jump
13
+ var selector =
14
+ fileListingElements.join(', ') +
15
+ ', ' +
16
+ notSelector +
17
+ missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
+
19
+ // The NodeList of matching elements
20
+ var missingCoverageElements = document.querySelectorAll(selector);
21
+
22
+ var currentIndex;
23
+
24
+ function toggleClass(index) {
25
+ missingCoverageElements
26
+ .item(currentIndex)
27
+ .classList.remove('highlighted');
28
+ missingCoverageElements.item(index).classList.add('highlighted');
29
+ }
30
+
31
+ function makeCurrent(index) {
32
+ toggleClass(index);
33
+ currentIndex = index;
34
+ missingCoverageElements.item(index).scrollIntoView({
35
+ behavior: 'smooth',
36
+ block: 'center',
37
+ inline: 'center'
38
+ });
39
+ }
40
+
41
+ function goToPrevious() {
42
+ var nextIndex = 0;
43
+ if (typeof currentIndex !== 'number' || currentIndex === 0) {
44
+ nextIndex = missingCoverageElements.length - 1;
45
+ } else if (missingCoverageElements.length > 1) {
46
+ nextIndex = currentIndex - 1;
47
+ }
48
+
49
+ makeCurrent(nextIndex);
50
+ }
51
+
52
+ function goToNext() {
53
+ var nextIndex = 0;
54
+
55
+ if (
56
+ typeof currentIndex === 'number' &&
57
+ currentIndex < missingCoverageElements.length - 1
58
+ ) {
59
+ nextIndex = currentIndex + 1;
60
+ }
61
+
62
+ makeCurrent(nextIndex);
63
+ }
64
+
65
+ return function jump(event) {
66
+ if (
67
+ document.getElementById('fileSearch') === document.activeElement &&
68
+ document.activeElement != null
69
+ ) {
70
+ // if we're currently focused on the search input, we don't want to navigate
71
+ return;
72
+ }
73
+
74
+ switch (event.which) {
75
+ case 78: // n
76
+ case 74: // j
77
+ goToNext();
78
+ break;
79
+ case 66: // b
80
+ case 75: // k
81
+ case 80: // p
82
+ goToPrevious();
83
+ break;
84
+ }
85
+ };
86
+ })();
87
+ window.addEventListener('keydown', jumpToCode);