@davidsouther/jiffies 2026.4.0 → 2026.24.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 (123) hide show
  1. package/README.md +0 -3
  2. package/package.json +13 -6
  3. package/src/404.html +1 -1
  4. package/src/components/accordion.ts +25 -0
  5. package/src/components/alert.ts +47 -0
  6. package/src/components/card.ts +54 -0
  7. package/src/components/children.ts +11 -0
  8. package/src/components/form.ts +25 -0
  9. package/src/components/index.ts +22 -0
  10. package/src/components/link.ts +22 -0
  11. package/src/components/modal.ts +15 -0
  12. package/src/components/nav.ts +42 -0
  13. package/src/components/property.ts +32 -0
  14. package/src/components/tabs.ts +82 -0
  15. package/src/components/virtual_scroll.ts +1 -1
  16. package/src/dom/README.md +8 -3
  17. package/src/dom/SKILL.md +201 -0
  18. package/src/dom/dom.ts +192 -41
  19. package/src/dom/fc.ts +7 -3
  20. package/src/dom/form/form.app.ts +35 -41
  21. package/src/dom/form/form.ts +79 -10
  22. package/src/dom/form/index.html +2 -2
  23. package/src/dom/html.ts +1 -1
  24. package/src/dom/hydrate.ts +206 -0
  25. package/src/dom/navigation/index.ts +349 -0
  26. package/src/dom/render.ts +41 -0
  27. package/src/dom/router/router.ts +1 -1
  28. package/src/dom/svg.ts +6 -2
  29. package/src/fs_node.ts +2 -2
  30. package/src/log.ts +154 -2
  31. package/src/server/http/response.ts +6 -3
  32. package/src/server/http/sitemap.ts +10 -34
  33. package/src/server/http/static.ts +0 -2
  34. package/src/server/live-reload.ts +208 -0
  35. package/src/server/main.ts +14 -7
  36. package/src/server/ws/frame.ts +36 -0
  37. package/src/server/ws/handshake.ts +42 -0
  38. package/src/server/ws/index.ts +100 -0
  39. package/src/ssg/bundle.ts +85 -0
  40. package/src/ssg/copy-public.ts +44 -0
  41. package/src/ssg/discover.ts +143 -0
  42. package/src/ssg/main.ts +168 -0
  43. package/src/ssg/rewrite.ts +18 -0
  44. package/src/ssg/ssg.ts +134 -0
  45. package/src/components/test.ts +0 -5
  46. package/src/components/virtual_scroll.test.ts +0 -30
  47. package/src/context.test.ts +0 -58
  48. package/src/context.ts +0 -67
  49. package/src/diff.test.ts +0 -48
  50. package/src/dom/fc.test.ts +0 -43
  51. package/src/dom/form/form.test.ts +0 -0
  52. package/src/dom/html.test.ts +0 -74
  53. package/src/dom/observable.test.ts +0 -43
  54. package/src/dom/test.ts +0 -11
  55. package/src/equal.test.ts +0 -23
  56. package/src/flags.test.ts +0 -43
  57. package/src/flags.ts +0 -53
  58. package/src/fs.test.ts +0 -106
  59. package/src/fs_win.test.ts +0 -11
  60. package/src/generator.test.ts +0 -27
  61. package/src/index.html +0 -82
  62. package/src/is_browser.js +0 -1
  63. package/src/lock.test.ts +0 -17
  64. package/src/observable/observable.test.ts +0 -73
  65. package/src/pico/_variables.scss +0 -66
  66. package/src/pico/components/_accordion.scss +0 -112
  67. package/src/pico/components/_button-group.scss +0 -51
  68. package/src/pico/components/_card.scss +0 -47
  69. package/src/pico/components/_dropdown.scss +0 -203
  70. package/src/pico/components/_modal.scss +0 -181
  71. package/src/pico/components/_nav.scss +0 -79
  72. package/src/pico/components/_progress.scss +0 -70
  73. package/src/pico/components/_property.scss +0 -34
  74. package/src/pico/content/_button.scss +0 -152
  75. package/src/pico/content/_code.scss +0 -63
  76. package/src/pico/content/_embedded.scss +0 -0
  77. package/src/pico/content/_form-alt.scss +0 -276
  78. package/src/pico/content/_form.scss +0 -259
  79. package/src/pico/content/_misc.scss +0 -0
  80. package/src/pico/content/_table.scss +0 -28
  81. package/src/pico/content/_toggle.scss +0 -132
  82. package/src/pico/content/_typography.scss +0 -232
  83. package/src/pico/layout/_container.scss +0 -40
  84. package/src/pico/layout/_document.scss +0 -0
  85. package/src/pico/layout/_flex.scss +0 -46
  86. package/src/pico/layout/_grid.scss +0 -24
  87. package/src/pico/layout/_scroller.scss +0 -16
  88. package/src/pico/layout/_section.scss +0 -8
  89. package/src/pico/layout/_sectioning.scss +0 -55
  90. package/src/pico/pico.scss +0 -60
  91. package/src/pico/reset/_accessibility.scss +0 -34
  92. package/src/pico/reset/_button.scss +0 -17
  93. package/src/pico/reset/_code.scss +0 -15
  94. package/src/pico/reset/_document.scss +0 -48
  95. package/src/pico/reset/_embedded.scss +0 -39
  96. package/src/pico/reset/_form.scss +0 -97
  97. package/src/pico/reset/_misc.scss +0 -23
  98. package/src/pico/reset/_nav.scss +0 -5
  99. package/src/pico/reset/_progress.scss +0 -4
  100. package/src/pico/reset/_table.scss +0 -8
  101. package/src/pico/reset/_typography.scss +0 -25
  102. package/src/pico/themes/default/_colors.scss +0 -65
  103. package/src/pico/themes/default/_dark.scss +0 -148
  104. package/src/pico/themes/default/_light.scss +0 -149
  105. package/src/pico/themes/default/_styles.scss +0 -272
  106. package/src/pico/themes/default.scss +0 -34
  107. package/src/pico/utilities/_accessibility.scss +0 -3
  108. package/src/pico/utilities/_loading.scss +0 -52
  109. package/src/pico/utilities/_reduce-motion.scss +0 -27
  110. package/src/pico/utilities/_tooltip.scss +0 -101
  111. package/src/result.test.ts +0 -101
  112. package/src/scope/describe.ts +0 -81
  113. package/src/scope/display/console.ts +0 -26
  114. package/src/scope/display/dom.ts +0 -36
  115. package/src/scope/display/junit.ts +0 -64
  116. package/src/scope/execute.ts +0 -110
  117. package/src/scope/expect.ts +0 -169
  118. package/src/scope/fix.ts +0 -30
  119. package/src/scope/index.ts +0 -11
  120. package/src/scope/scope.ts +0 -21
  121. package/src/scope/state.ts +0 -13
  122. package/src/test.mjs +0 -33
  123. package/src/test_all.ts +0 -35
@@ -1,272 +0,0 @@
1
- // Commons Styles
2
- :root {
3
- // Typography
4
- --font-family: system-ui, -apple-system, "Segoe UI", "Roboto", "Ubuntu",
5
- "Cantarell", "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
6
- "Segoe UI Symbol", "Noto Color Emoji";
7
- --font-family-monospace: "Menlo", "Consolas", "Roboto Mono",
8
- "Ubuntu Monospace", "Noto Mono", "Oxygen Mono", "Liberation Mono", monospace,
9
- "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
10
- --line-height: 1.5;
11
- --font-weight: 400;
12
- --font-size: 16px;
13
-
14
- // Responsive typography
15
- @if $enable-responsive-typography {
16
- @if map-get($breakpoints, "sm") {
17
- @media (min-width: map-get($breakpoints, "sm")) {
18
- --font-size: 17px;
19
- }
20
- }
21
-
22
- @if map-get($breakpoints, "md") {
23
- @media (min-width: map-get($breakpoints, "md")) {
24
- --font-size: 18px;
25
- }
26
- }
27
-
28
- @if map-get($breakpoints, "lg") {
29
- @media (min-width: map-get($breakpoints, "lg")) {
30
- --font-size: 19px;
31
- }
32
- }
33
-
34
- @if map-get($breakpoints, "xl") {
35
- @media (min-width: map-get($breakpoints, "xl")) {
36
- --font-size: 20px;
37
- }
38
- }
39
- }
40
-
41
- // Borders
42
- --border-radius: 0.25rem;
43
- --border-width: 1px;
44
- --outline-width: 3px;
45
-
46
- // Spacings
47
- --spacing: 1rem;
48
-
49
- // Spacings for typography elements
50
- --typography-spacing-vertical: 1.5rem;
51
-
52
- // Spacings for body > header, body > main, body > footer, section, article
53
- --block-spacing-vertical: calc(var(--spacing) * 2);
54
- --block-spacing-horizontal: var(--spacing);
55
-
56
- @if ($enable-classes and $enable-grid) {
57
- --grid-spacing-vertical: 0;
58
- --grid-spacing-horizontal: var(--spacing);
59
- }
60
-
61
- // Spacings for form elements and button
62
- --form-element-spacing-vertical: 0.75rem;
63
- --form-element-spacing-horizontal: 1rem;
64
-
65
- // Spacings for nav component
66
- --nav-element-spacing-vertical: 1rem;
67
- --nav-element-spacing-horizontal: 0.5rem;
68
- --nav-link-spacing-vertical: 0.5rem;
69
- --nav-link-spacing-horizontal: 0.5rem;
70
-
71
- // Font weight for form labels & fieldsets legend
72
- --form-label-font-weight: var(--font-weight);
73
-
74
- // Transitions
75
- --transition: 0.2s ease-in-out;
76
- }
77
-
78
- @mixin centered-viewport {
79
- @if map-get($breakpoints, "sm") {
80
- @media (min-width: map-get($breakpoints, "sm")) {
81
- max-width: map-get($viewports, "sm");
82
- margin: 0 auto;
83
- padding: 0;
84
- }
85
- }
86
-
87
- @if map-get($breakpoints, "md") {
88
- @media (min-width: map-get($breakpoints, "md")) {
89
- max-width: map-get($viewports, "md");
90
- }
91
- }
92
-
93
- @if map-get($breakpoints, "lg") {
94
- @media (min-width: map-get($breakpoints, "lg")) {
95
- max-width: map-get($viewports, "lg");
96
- }
97
- }
98
-
99
- @if map-get($breakpoints, "xl") {
100
- @media (min-width: map-get($breakpoints, "xl")) {
101
- max-width: map-get($viewports, "xl");
102
- }
103
- }
104
- }
105
-
106
- // Responsives spacings
107
- @if $enable-responsive-spacings {
108
- // Sectionning
109
- body > header,
110
- body > main,
111
- body > footer,
112
- section {
113
- @if map-get($breakpoints, "sm") {
114
- @media (min-width: map-get($breakpoints, "sm")) {
115
- --block-spacing-vertical: calc(var(--spacing) * 1.25);
116
- }
117
- }
118
-
119
- @if map-get($breakpoints, "md") {
120
- @media (min-width: map-get($breakpoints, "md")) {
121
- --block-spacing-vertical: calc(var(--spacing) * 1.5);
122
- }
123
- }
124
-
125
- @if map-get($breakpoints, "lg") {
126
- @media (min-width: map-get($breakpoints, "lg")) {
127
- --block-spacing-vertical: calc(var(--spacing) * 1.75);
128
- }
129
- }
130
-
131
- @if map-get($breakpoints, "xl") {
132
- @media (min-width: map-get($breakpoints, "xl")) {
133
- --block-spacing-vertical: calc(var(--spacing) * 2);
134
- }
135
- }
136
- }
137
-
138
- // Card (<article>)
139
- article {
140
- @if map-get($breakpoints, "sm") {
141
- @media (min-width: map-get($breakpoints, "sm")) {
142
- --block-spacing-horizontal: calc(var(--spacing) * 1.25);
143
- }
144
- }
145
-
146
- @if map-get($breakpoints, "md") {
147
- @media (min-width: map-get($breakpoints, "md")) {
148
- --block-spacing-horizontal: calc(var(--spacing) * 1.5);
149
- }
150
- }
151
-
152
- @if map-get($breakpoints, "lg") {
153
- @media (min-width: map-get($breakpoints, "lg")) {
154
- --block-spacing-horizontal: calc(var(--spacing) * 1.75);
155
- }
156
- }
157
-
158
- @if map-get($breakpoints, "xl") {
159
- @media (min-width: map-get($breakpoints, "xl")) {
160
- --block-spacing-horizontal: calc(var(--spacing) * 2);
161
- }
162
- }
163
- }
164
-
165
- // Modal
166
- dialog > article {
167
- --block-spacing-vertical: calc(var(--spacing) * 2);
168
- --block-spacing-horizontal: var(--spacing);
169
-
170
- @if map-get($breakpoints, "sm") {
171
- @media (min-width: map-get($breakpoints, "sm")) {
172
- --block-spacing-vertical: calc(var(--spacing) * 2.5);
173
- --block-spacing-horizontal: calc(var(--spacing) * 1.25);
174
- }
175
- }
176
-
177
- @if map-get($breakpoints, "md") {
178
- @media (min-width: map-get($breakpoints, "md")) {
179
- --block-spacing-vertical: calc(var(--spacing) * 3);
180
- --block-spacing-horizontal: calc(var(--spacing) * 1.5);
181
- }
182
- }
183
- }
184
- }
185
-
186
- // Link
187
- a {
188
- --text-decoration: none;
189
-
190
- // Secondary & Contrast
191
- @if $enable-classes {
192
- &.secondary,
193
- &.contrast {
194
- --text-decoration: underline;
195
- }
196
- }
197
- }
198
-
199
- // Small
200
- small {
201
- --font-size: 0.875em;
202
- }
203
-
204
- // Headings
205
- h1,
206
- h2,
207
- h3,
208
- h4,
209
- h5,
210
- h6 {
211
- --font-weight: 700;
212
- }
213
-
214
- h1 {
215
- --font-size: 2rem;
216
- --typography-spacing-vertical: 3rem;
217
- }
218
-
219
- h2 {
220
- --font-size: 1.75rem;
221
- --typography-spacing-vertical: 2.625rem;
222
- }
223
-
224
- h3 {
225
- --font-size: 1.5rem;
226
- --typography-spacing-vertical: 2.25rem;
227
- }
228
-
229
- h4 {
230
- --font-size: 1.25rem;
231
- --typography-spacing-vertical: 1.874rem;
232
- }
233
-
234
- h5 {
235
- --font-size: 1.125rem;
236
- --typography-spacing-vertical: 1.6875rem;
237
- }
238
-
239
- // Forms elements
240
- [type="checkbox"],
241
- [type="radio"] {
242
- --border-width: 2px;
243
- }
244
-
245
- [type="checkbox"][role="switch"] {
246
- --border-width: 3px;
247
- }
248
-
249
- // Table
250
- thead,
251
- tfoot {
252
- th,
253
- td {
254
- --border-width: 3px;
255
- }
256
- }
257
-
258
- :not(thead):not(tfoot) > * > td {
259
- --font-size: 0.875em;
260
- }
261
-
262
- // Code
263
- pre,
264
- code,
265
- kbd,
266
- samp {
267
- --font-family: var(--font-family-monospace);
268
- }
269
-
270
- kbd {
271
- --font-weight: bolder;
272
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Theme: default
3
- */
4
-
5
- // Variables
6
- @import "../variables";
7
- @import "default/colors";
8
-
9
- // Common styles
10
- @import "default/styles";
11
-
12
- @import "default/light";
13
- @import "default/dark";
14
-
15
- // Light theme (Default)
16
- // Can be forced with data-theme="light"
17
- [data-theme="light"],
18
- :root:not([data-theme="dark"]) {
19
- @include light;
20
- }
21
-
22
- // Dark theme (Auto)
23
- // Automatically enabled if user has Dark mode enabled
24
- @media only screen and (prefers-color-scheme: dark) {
25
- :root:not([data-theme="light"]) {
26
- @include dark;
27
- }
28
- }
29
-
30
- // Dark theme (Forced)
31
- // Enabled if forced with data-theme="dark"
32
- [data-theme="dark"] {
33
- @include dark;
34
- }
@@ -1,3 +0,0 @@
1
- [dir="rtl"] {
2
- direction: rtl;
3
- }
@@ -1,52 +0,0 @@
1
- // Cursor
2
- [aria-busy="true"] {
3
- cursor: progress;
4
- }
5
-
6
- // Everyting except form elements
7
- [aria-busy="true"]:not(input):not(select):not(textarea) {
8
- &::before {
9
- display: inline-block;
10
- width: 1em;
11
- height: 1em;
12
- border: 0.1875em solid currentColor;
13
- border-radius: 1em;
14
- border-right-color: transparent;
15
- content: "";
16
- vertical-align: text-bottom;
17
- vertical-align: -0.125em; // Visual alignment
18
- animation: spinner 0.75s linear infinite;
19
- opacity: var(--loading-spinner-opacity);
20
- }
21
-
22
- &:not(:empty) {
23
- &::before {
24
- margin-right: calc(var(--spacing) * 0.5);
25
- margin-left: 0;
26
- margin-inline-start: 0;
27
- margin-inline-end: calc(var(--spacing) * 0.5);
28
- }
29
- }
30
-
31
- &:empty {
32
- text-align: center;
33
- }
34
- }
35
-
36
- // Buttons and links
37
- button,
38
- input[type="submit"],
39
- input[type="button"],
40
- input[type="reset"],
41
- a {
42
- &[aria-busy="true"] {
43
- pointer-events: none;
44
- }
45
- }
46
-
47
- // Animation: rotate
48
- @keyframes spinner {
49
- to {
50
- transform: rotate(360deg);
51
- }
52
- }
@@ -1,27 +0,0 @@
1
- @if $enable-transitions and $enable-important {
2
- /**
3
- * Reduce Motion Features
4
- */
5
-
6
- // Based on :
7
- // - sanitize.css v13.0.0 | CC0 1.0 Universal | github.com/csstools/sanitize.css
8
- // ––––––––––––––––––––
9
-
10
- // 1. Remove animations when motion is reduced (opinionated)
11
- // 2. Remove fixed background attachments when motion is reduced (opinionated)
12
- // 3. Remove timed scrolling behaviors when motion is reduced (opinionated)
13
- // 4. Remove transitions when motion is reduced (opinionated)
14
- @media (prefers-reduced-motion: reduce) {
15
- *:not([aria-busy="true"]),
16
- :not([aria-busy="true"])::before,
17
- :not([aria-busy="true"])::after {
18
- background-attachment: initial !important; // 2
19
- animation-duration: 1ms !important; // 1
20
- animation-delay: -1ms !important; // 1
21
- animation-iteration-count: 1 !important; // 1
22
- scroll-behavior: auto !important; // 3
23
- transition-delay: 0s !important; // 4
24
- transition-duration: 0s !important; // 4
25
- }
26
- }
27
- }
@@ -1,101 +0,0 @@
1
- [data-tooltip] {
2
- position: relative;
3
-
4
- &:not(a):not(button):not(input) {
5
- border-bottom: 1px dotted;
6
- text-decoration: none;
7
- cursor: help;
8
- }
9
-
10
- &::before,
11
- &::after {
12
- display: block;
13
- z-index: 99;
14
- position: absolute;
15
- bottom: 100%;
16
- left: 50%;
17
- padding: 0.25rem 0.5rem;
18
- overflow: hidden;
19
- transform: translate(-50%, -0.25rem);
20
- border-radius: var(--border-radius);
21
- background: var(--tooltip-background-color);
22
- content: attr(data-tooltip);
23
- color: var(--tooltip-color);
24
- font-style: normal;
25
- font-weight: var(--font-weight);
26
- font-size: 0.875rem;
27
- text-decoration: none;
28
- text-overflow: ellipsis;
29
- white-space: nowrap;
30
- opacity: 0;
31
- pointer-events: none;
32
- }
33
-
34
- // Caret
35
- &::after {
36
- padding: 0;
37
- transform: translate(-50%, 0rem);
38
- border-top: 0.3rem solid;
39
- border-right: 0.3rem solid transparent;
40
- border-left: 0.3rem solid transparent;
41
- border-radius: 0;
42
- background-color: transparent;
43
- content: "";
44
- color: var(--tooltip-background-color);
45
- }
46
-
47
- // Display
48
- &:focus,
49
- &:hover {
50
- &::before,
51
- &::after {
52
- opacity: 1;
53
- }
54
- }
55
-
56
- // Animations, excluding touch devices
57
- @if $enable-transitions {
58
- @media (hover: hover) and (pointer: fine) {
59
- &:focus,
60
- &:hover {
61
- &::before,
62
- &::after {
63
- animation-duration: 0.2s;
64
- animation-name: slide;
65
- }
66
-
67
- &::after {
68
- animation-name: slideCaret;
69
- }
70
- }
71
- }
72
- }
73
- }
74
-
75
- // Animations
76
- @if $enable-transitions {
77
- @keyframes slide {
78
- from {
79
- transform: translate(-50%, 0.75rem);
80
- opacity: 0;
81
- }
82
- to {
83
- transform: translate(-50%, -0.25rem);
84
- opacity: 1;
85
- }
86
- }
87
-
88
- @keyframes slideCaret {
89
- from {
90
- opacity: 0;
91
- }
92
- 50% {
93
- transform: translate(-50%, -0.25rem);
94
- opacity: 0;
95
- }
96
- to {
97
- transform: translate(-50%, 0rem);
98
- opacity: 1;
99
- }
100
- }
101
- }
@@ -1,101 +0,0 @@
1
- import {
2
- Err,
3
- None,
4
- Ok,
5
- type Result,
6
- Some,
7
- unwrap,
8
- unwrapOr,
9
- unwrapOrElse,
10
- } from "./result.ts";
11
- import { describe, it } from "./scope/describe.ts";
12
- import { expect } from "./scope/expect.ts";
13
-
14
- describe("Result", () => {
15
- it("converts Nones", () => {
16
- const a = None<string>();
17
- expect(a).toBeNull();
18
-
19
- const b = None<string>();
20
- expect(b).toBeNull();
21
-
22
- const c = Some(a);
23
- expect(c).toBeNull();
24
-
25
- const d = Some(b);
26
- expect(d).toBeNull();
27
- });
28
-
29
- it("converts Somes", () => {
30
- const a = Some("a");
31
- expect(a).toBe("a");
32
-
33
- const b = Some(a);
34
- expect(b).toBe("a");
35
- });
36
-
37
- it("converts Errs", () => {
38
- const a = Err(new Error("a error"));
39
- const b = Err(a);
40
- expect(b).toMatchObject({ message: "a error" });
41
-
42
- // Assign Err to Result
43
- const _c: Result<string> = a;
44
- });
45
-
46
- it("converts Oks", () => {
47
- const a = Ok("a ok");
48
- const b = Ok(a);
49
- expect(b).toBe("a ok");
50
-
51
- // Assign ok to Result
52
- const _c: Result<string> = a;
53
- });
54
-
55
- it("unwraps", () => {
56
- const a = Some("some");
57
- const b = None<string>();
58
- const c = Ok("ok");
59
- const d = Err(new Error("err"));
60
- const e: string = "else";
61
-
62
- expect(unwrap(a)).toBe("some");
63
- expect(unwrap<string, Error>(c)).toBe("ok");
64
- expect(() => unwrap(b)).toThrow("Attempted to unwrap None");
65
- expect(() => unwrap(d)).toThrow("err");
66
- expect(unwrap(e)).toBe("else");
67
- });
68
-
69
- it("unwrapsOrs", () => {
70
- const a = Some<string>("some");
71
- const b = None<string>();
72
- const c = Ok<string>("ok");
73
- const d = Err(new Error("err"));
74
- const e: string = "else";
75
-
76
- expect(unwrapOr(a, "z")).toBe("some");
77
- expect(unwrapOr(c, "z")).toBe("ok");
78
- expect(unwrapOr(b, "z")).toBe("z");
79
- expect(unwrapOr(d, "z")).toBe("z");
80
- expect(unwrapOr(e, "z")).toBe("else");
81
- });
82
-
83
- it("unwrapsOrElse", () => {
84
- const a = Some<string>("some");
85
- const b = None();
86
- const c = Ok("ok");
87
- const d = Err(new Error("err"));
88
- const e = "else";
89
-
90
- expect(unwrapOrElse(a, () => "z")).toBe("some");
91
- expect(unwrapOrElse(c, () => "z")).toBe("ok");
92
- expect(unwrapOrElse(b, () => "z")).toBe("z");
93
- expect(unwrapOrElse(d, () => "z")).toBe("z");
94
- expect(unwrapOrElse(e, () => "z")).toBe("else");
95
- });
96
-
97
- it("allows Result<void> with Ok()", () => {
98
- const a: Result<void> = Ok();
99
- expect(unwrap(a)).toBe(undefined);
100
- });
101
- });
@@ -1,81 +0,0 @@
1
- import { assert } from "../assert.ts";
2
- import { getLogger } from "../log.ts";
3
- import type { TestCase } from "./scope.ts";
4
- import * as state from "./state.ts";
5
-
6
- export const beforeall = Symbol("beforeAll");
7
- export const beforeeach = Symbol("beforeEach");
8
- export const afterall = Symbol("afterAll");
9
- export const aftereach = Symbol("afterEach");
10
-
11
- const logger = getLogger("scope");
12
-
13
- const CASES: TestCase = {};
14
- const cases = [CASES];
15
- let totalCases = 0;
16
- let skippedCases = 0;
17
-
18
- function push(title: string) {
19
- cases[0][title] = cases[0][title] ?? {};
20
- const next = cases[0][title] as TestCase;
21
- cases.unshift(next);
22
- }
23
-
24
- function pop() {
25
- cases.shift();
26
- }
27
-
28
- export function rootCases(): TestCase {
29
- return CASES;
30
- }
31
-
32
- export function getTotalCases() {
33
- return totalCases;
34
- }
35
-
36
- export function getSkippedCases() {
37
- return skippedCases;
38
- }
39
-
40
- export function describe(title: string, block: CallableFunction) {
41
- logger.debug(`describe(${title})`);
42
- push(title);
43
- block();
44
- pop();
45
- }
46
-
47
- export function it(title: string, block: CallableFunction) {
48
- logger.debug(`it(${title})`);
49
- assert(cases[0][title] === undefined, `Block already has test ${title}`);
50
- totalCases += 1;
51
- cases[0][title] = block;
52
- }
53
-
54
- it.skip = (title: string, _block: CallableFunction) => {
55
- logger.debug(`it.skip(${title})`);
56
- totalCases += 1;
57
- skippedCases += 1;
58
- };
59
-
60
- export function beforeEach(fn: () => void) {
61
- cases[0][beforeeach] = fn;
62
- }
63
-
64
- export function beforeAll(fn: () => void) {
65
- cases[0][beforeall] = fn;
66
- }
67
-
68
- export function afterEach(fn: () => void) {
69
- cases[0][aftereach] = fn;
70
- }
71
-
72
- export function afterAll(fn: () => void) {
73
- cases[0][afterall] = fn;
74
- }
75
-
76
- export function cleanState<State extends {}>(
77
- init: () => State,
78
- runner: (action: () => void) => void = beforeEach,
79
- ): State {
80
- return state.cleanState(init, runner);
81
- }
@@ -1,26 +0,0 @@
1
- import { getLogger } from "../../log.ts";
2
- import { getTotalCases } from "../describe.ts";
3
- import { flattenResults } from "../execute.ts";
4
- import type { TestResult } from "../scope.ts";
5
-
6
- const logger = getLogger("Scope Test Runner");
7
-
8
- export function onConsole(results: TestResult) {
9
- const { executed, failed } = results;
10
- logger.info("Executed test suite.", {
11
- executed,
12
- total: getTotalCases(),
13
- failed,
14
- });
15
- const flat = flattenResults(results);
16
-
17
- for (const { test } of flat) {
18
- logger.debug(test);
19
- }
20
-
21
- for (const { test, stack } of flat) {
22
- if (stack) {
23
- logger.error(test, { stack });
24
- }
25
- }
26
- }