|
| 1 | +# Spec file migration: `*.spec.js` + `*-spec.ts` → `*.spec.ts` |
| 2 | + |
| 3 | +## ORIGINAL PROMPT |
| 4 | + |
| 5 | +Goal: migrate runtime source/*.spec.js tests and source/*-spec.ts to source/*.spec.ts form |
| 6 | +1. Write refactor.md at repo root listing every method that has either *.spec.js or *-spec.ts file(or both), grouped into 10 batches of ~10% each, in dependency order. |
| 7 | +2. Each dev next completes one batch: create foo.spec.js using foo-spec.ts(if exists) and foo.spec.js(if exists) |
| 8 | +2.1 Extend TS tests to assert also final result(which is missing in -spec.ts files) |
| 9 | +2.2 If there is error on TS types after moving *.spec.js file, use `any` to make TS happy |
| 10 | +2.3 don't delete the old files. |
| 11 | +3. While running the batch, work file by file because you need to verify new file is correct with "node node_modules/vitest/ |
| 12 | +dist/cli.js run --config vitest.typings.config.js source/foo.spec.ts" and "bun lint:typings" |
| 13 | + |
| 14 | +## Current state |
| 15 | + |
| 16 | +| Category | Count | |
| 17 | +|---|---| |
| 18 | +| Methods with both `*.spec.js` and `*-spec.ts` | 100 | |
| 19 | +| Methods with only `*.spec.js` | 26 | |
| 20 | +| Methods with only `*-spec.ts` | 5 | |
| 21 | +| **Total methods to migrate** | **131** | |
| 22 | + |
| 23 | +## Goal per method |
| 24 | + |
| 25 | +Create `source/foo.spec.ts` that combines: |
| 26 | +1. **Runtime tests** from `source/foo.spec.js` — `test(...)` / `expect(...)` calls |
| 27 | +2. **Type tests** from `source/foo-spec.ts` — `expectTypeOf(...)` calls |
| 28 | +3. **Extend** type tests to assert the **final runtime result value** (current `-spec.ts` files only check types, not values) |
| 29 | +4. If TypeScript complains about types from the JS runtime test code, use `any` to suppress |
| 30 | +5. **Do NOT delete** old `*.spec.js` or `*-spec.ts` files |
| 31 | + |
| 32 | + |
| 33 | +## Verification per file |
| 34 | + |
| 35 | +```bash |
| 36 | +node node_modules/vitest/dist/cli.js source/foo.spec.ts |
| 37 | +bun lint:typings |
| 38 | +``` |
| 39 | + |
| 40 | +## EXAMPLE TARGET |
| 41 | + |
| 42 | +``` |
| 43 | +import { addProp, pipe } from 'rambda' |
| 44 | +import { test, expect, expectTypeOf } from 'vitest'; |
| 45 | +
|
| 46 | +test('happy', () => { |
| 47 | + const result = addProp('a', 1)({ b: 2 }) |
| 48 | + const expected = { a: 1, b: 2 } |
| 49 | +
|
| 50 | + expect(result).toEqual(expected) |
| 51 | +}) |
| 52 | +
|
| 53 | +test('type test', () => { |
| 54 | + const result = pipe({ a: 1, b: 'foo' }, addProp('c', 3)) |
| 55 | + expectTypeOf(result.a).toEqualTypeOf<number>() |
| 56 | + expectTypeOf(result.b).toEqualTypeOf<string>() |
| 57 | + expectTypeOf(result.c).toEqualTypeOf<number>() |
| 58 | + expect(result).toEqual({ a: 1, b: 'foo', c: 3 }) |
| 59 | +}) |
| 60 | +``` |
| 61 | + |
| 62 | +PLEASE NOTE THAT IMPORT ARE IN PLACE AND METHODS ARE IMPORTED `from 'rambda'` |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Batches (~13 files each, alphabetical) |
| 67 | + |
| 68 | +### Batch 1 (13) |
| 69 | +addProp, addPropToObjects, all, allPass, any, anyPass, append, ascend, assertType, checkObjectWithSpec, combinations, compact, complement |
| 70 | + |
| 71 | +| Method | `.spec.js` | `-spec.ts` | |
| 72 | +|---|---|---| |
| 73 | +| addProp | ✓ | ✓ | |
| 74 | +| addPropToObjects | ✓ | ✓ | |
| 75 | +| all | ✓ | ✓ | |
| 76 | +| allPass | ✓ | ✓ | |
| 77 | +| any | ✓ | ✓ | |
| 78 | +| anyPass | ✓ | ✓ | |
| 79 | +| append | ✓ | ✓ | |
| 80 | +| ascend | ✓ | ✓ | |
| 81 | +| assertType | ✓ | ✓ | |
| 82 | +| checkObjectWithSpec | ✓ | — | |
| 83 | +| combinations | ✓ | — | |
| 84 | +| compact | ✓ | ✓ | |
| 85 | +| complement | ✓ | ✓ | |
| 86 | + |
| 87 | +### Batch 2 (13) |
| 88 | +concat, count, countBy, createObjectFromKeys, defaultTo, difference, drop, dropLast, dropLastWhile, dropWhile, duplicateBy, eqBy, eqProps |
| 89 | + |
| 90 | +| Method | `.spec.js` | `-spec.ts` | |
| 91 | +|---|---|---| |
| 92 | +| concat | — | ✓ | |
| 93 | +| count | ✓ | ✓ | |
| 94 | +| countBy | ✓ | ✓ | |
| 95 | +| createObjectFromKeys | ✓ | — | |
| 96 | +| defaultTo | ✓ | ✓ | |
| 97 | +| difference | ✓ | ✓ | |
| 98 | +| drop | ✓ | ✓ | |
| 99 | +| dropLast | ✓ | — | |
| 100 | +| dropLastWhile | ✓ | — | |
| 101 | +| dropWhile | ✓ | ✓ | |
| 102 | +| duplicateBy | ✓ | — | |
| 103 | +| eqBy | ✓ | — | |
| 104 | +| eqProps | ✓ | ✓ | |
| 105 | + |
| 106 | +### Batch 3 (13) |
| 107 | +equals, evolve, excludes, exists, filter, filterAsync, filterMap, filterObject, find, findIndex, findLastIndex, findNth, flatMap |
| 108 | + |
| 109 | +| Method | `.spec.js` | `-spec.ts` | |
| 110 | +|---|---|---| |
| 111 | +| equals | ✓ | ✓ | |
| 112 | +| evolve | ✓ | ✓ | |
| 113 | +| excludes | ✓ | ✓ | |
| 114 | +| exists | ✓ | ✓ | |
| 115 | +| filter | ✓ | ✓ | |
| 116 | +| filterAsync | ✓ | ✓ | |
| 117 | +| filterMap | ✓ | ✓ | |
| 118 | +| filterObject | ✓ | ✓ | |
| 119 | +| find | ✓ | ✓ | |
| 120 | +| findIndex | ✓ | ✓ | |
| 121 | +| findLastIndex | ✓ | ✓ | |
| 122 | +| findNth | ✓ | — | |
| 123 | +| flatMap | ✓ | ✓ | |
| 124 | + |
| 125 | +### Batch 4 (13) |
| 126 | +flatten, flattenObject, groupBy, head, includes, indexBy, indexOf, init, interpolate, intersection, intersectionWith, intersperse, isValid |
| 127 | + |
| 128 | +| Method | `.spec.js` | `-spec.ts` | |
| 129 | +|---|---|---| |
| 130 | +| flatten | ✓ | ✓ | |
| 131 | +| flattenObject | ✓ | ✓ | |
| 132 | +| groupBy | ✓ | ✓ | |
| 133 | +| head | ✓ | ✓ | |
| 134 | +| includes | ✓ | ✓ | |
| 135 | +| indexBy | ✓ | ✓ | |
| 136 | +| indexOf | ✓ | ✓ | |
| 137 | +| init | ✓ | ✓ | |
| 138 | +| interpolate | ✓ | ✓ | |
| 139 | +| intersection | ✓ | ✓ | |
| 140 | +| intersectionWith | ✓ | ✓ | |
| 141 | +| intersperse | ✓ | ✓ | |
| 142 | +| isValid | ✓ | — | |
| 143 | + |
| 144 | +### Batch 5 (13) |
| 145 | +join, last, lastIndexOf, map, mapAsync, mapChain, mapKeys, mapObject, mapObjectAsync, mapParallelAsync, mapPropObject, match, maxBy |
| 146 | + |
| 147 | +| Method | `.spec.js` | `-spec.ts` | |
| 148 | +|---|---|---| |
| 149 | +| join | — | ✓ | |
| 150 | +| last | ✓ | — | |
| 151 | +| lastIndexOf | ✓ | ✓ | |
| 152 | +| map | ✓ | ✓ | |
| 153 | +| mapAsync | ✓ | ✓ | |
| 154 | +| mapChain | ✓ | ✓ | |
| 155 | +| mapKeys | ✓ | ✓ | |
| 156 | +| mapObject | ✓ | ✓ | |
| 157 | +| mapObjectAsync | ✓ | ✓ | |
| 158 | +| mapParallelAsync | ✓ | — | |
| 159 | +| mapPropObject | ✓ | ✓ | |
| 160 | +| match | ✓ | ✓ | |
| 161 | +| maxBy | ✓ | ✓ | |
| 162 | + |
| 163 | +### Batch 6 (13) |
| 164 | +merge, mergeDeep, middle, minBy, modifyItemAtIndex, modifyPath, modifyProp, none, objOf, objectIncludes, omit, partition, partitionObject |
| 165 | + |
| 166 | +| Method | `.spec.js` | `-spec.ts` | |
| 167 | +|---|---|---| |
| 168 | +| merge | ✓ | ✓ | |
| 169 | +| mergeDeep | ✓ | — | |
| 170 | +| middle | ✓ | ✓ | |
| 171 | +| minBy | ✓ | — | |
| 172 | +| modifyItemAtIndex | ✓ | — | |
| 173 | +| modifyPath | ✓ | ✓ | |
| 174 | +| modifyProp | ✓ | ✓ | |
| 175 | +| none | ✓ | ✓ | |
| 176 | +| objOf | ✓ | ✓ | |
| 177 | +| objectIncludes | ✓ | ✓ | |
| 178 | +| omit | ✓ | ✓ | |
| 179 | +| partition | ✓ | ✓ | |
| 180 | +| partitionObject | ✓ | ✓ | |
| 181 | + |
| 182 | +### Batch 7 (13) |
| 183 | +path, pathSatisfies, pick, pipe, pipeAsync, pluck, prepend, prop, propEq, propOr, propSatisfies, random, range |
| 184 | + |
| 185 | +| Method | `.spec.js` | `-spec.ts` | |
| 186 | +|---|---|---| |
| 187 | +| path | ✓ | ✓ | |
| 188 | +| pathSatisfies | ✓ | ✓ | |
| 189 | +| pick | ✓ | ✓ | |
| 190 | +| pipe | ✓ | ✓ | |
| 191 | +| pipeAsync | ✓ | ✓ | |
| 192 | +| pluck | ✓ | ✓ | |
| 193 | +| prepend | ✓ | — | |
| 194 | +| prop | — | ✓ | |
| 195 | +| propEq | ✓ | ✓ | |
| 196 | +| propOr | ✓ | ✓ | |
| 197 | +| propSatisfies | ✓ | ✓ | |
| 198 | +| random | ✓ | — | |
| 199 | +| range | ✓ | ✓ | |
| 200 | + |
| 201 | +### Batch 8 (13) |
| 202 | +rangeDescending, reduce, reject, rejectObject, remove, replace, replaceAll, shuffle, sort, sortBy, sortByDescending, sortByPath, sortByPathDescending |
| 203 | + |
| 204 | +| Method | `.spec.js` | `-spec.ts` | |
| 205 | +|---|---|---| |
| 206 | +| rangeDescending | ✓ | — | |
| 207 | +| reduce | ✓ | ✓ | |
| 208 | +| reject | ✓ | ✓ | |
| 209 | +| rejectObject | ✓ | ✓ | |
| 210 | +| remove | ✓ | — | |
| 211 | +| replace | ✓ | ✓ | |
| 212 | +| replaceAll | ✓ | ✓ | |
| 213 | +| shuffle | — | ✓ | |
| 214 | +| sort | ✓ | ✓ | |
| 215 | +| sortBy | ✓ | ✓ | |
| 216 | +| sortByDescending | ✓ | — | |
| 217 | +| sortByPath | ✓ | ✓ | |
| 218 | +| sortByPathDescending | ✓ | — | |
| 219 | + |
| 220 | +### Batch 9 (13) |
| 221 | +sortByProps, sortObject, sortWith, splitEvery, splitEveryStrict, sum, switcher, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile |
| 222 | + |
| 223 | +| Method | `.spec.js` | `-spec.ts` | |
| 224 | +|---|---|---| |
| 225 | +| sortByProps | — | ✓ | |
| 226 | +| sortObject | ✓ | ✓ | |
| 227 | +| sortWith | ✓ | — | |
| 228 | +| splitEvery | ✓ | ✓ | |
| 229 | +| splitEveryStrict | ✓ | — | |
| 230 | +| sum | ✓ | — | |
| 231 | +| switcher | ✓ | ✓ | |
| 232 | +| symmetricDifference | ✓ | ✓ | |
| 233 | +| tail | ✓ | ✓ | |
| 234 | +| take | ✓ | — | |
| 235 | +| takeLast | ✓ | — | |
| 236 | +| takeLastWhile | ✓ | — | |
| 237 | +| takeWhile | ✓ | ✓ | |
| 238 | + |
| 239 | +### Batch 10 (14) |
| 240 | +test, tryCatch, type, union, unionWith, uniq, uniqBy, uniqWith, unless, unwind, update, when, zip, zipWith |
| 241 | + |
| 242 | +| Method | `.spec.js` | `-spec.ts` | |
| 243 | +|---|---|---| |
| 244 | +| test | ✓ | ✓ | |
| 245 | +| tryCatch | ✓ | ✓ | |
| 246 | +| type | ✓ | ✓ | |
| 247 | +| union | ✓ | ✓ | |
| 248 | +| unionWith | ✓ | ✓ | |
| 249 | +| uniq | ✓ | ✓ | |
| 250 | +| uniqBy | ✓ | ✓ | |
| 251 | +| uniqWith | ✓ | ✓ | |
| 252 | +| unless | ✓ | ✓ | |
| 253 | +| unwind | ✓ | ✓ | |
| 254 | +| update | ✓ | — | |
| 255 | +| when | ✓ | ✓ | |
| 256 | +| zip | ✓ | ✓ | |
| 257 | +| zipWith | ✓ | ✓ | |
0 commit comments