lil-mocky 1.4.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.
- package/.claude/settings.local.json +7 -0
- package/CLAUDE.md +191 -0
- package/Dockerfile +2 -0
- package/README.md +705 -0
- package/TODO +57 -0
- package/init-docker.sh +4 -0
- package/lil-mocky.sublime-project +8 -0
- package/lil-mocky.sublime-workspace +2405 -0
- package/package.json +14 -0
- package/src/lil-mocky.js +329 -0
- package/test/lilMockyTest.js +867 -0
- package/test-docker.sh +3 -0
package/TODO
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# lil-mocky v2.0 API Design
|
|
2
|
+
|
|
3
|
+
Breaking changes for a future major version.
|
|
4
|
+
|
|
5
|
+
## Function Mocks
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
mock.call(0) // get single call (0-indexed)
|
|
9
|
+
mock.calls // count getter
|
|
10
|
+
|
|
11
|
+
mock.ret('default') // no index = default for all calls
|
|
12
|
+
mock.ret('first', 0) // 0-indexed for specific calls
|
|
13
|
+
|
|
14
|
+
mock.data // object, not function
|
|
15
|
+
mock.reset()
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Class Mocks
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
Mock.inst(0) // get single instance (lazy creation)
|
|
22
|
+
Mock.instance(0) // synonym
|
|
23
|
+
Mock.insts // count getter
|
|
24
|
+
Mock.instances // synonym
|
|
25
|
+
Mock.reset()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Key Changes from v1
|
|
29
|
+
|
|
30
|
+
- `mocky.fn()` synonym for `mocky.function()`
|
|
31
|
+
- `mocky.obj()` synonym for `mocky.object()`
|
|
32
|
+
- `mocky.cls()` synonym for `mocky.class()`
|
|
33
|
+
- `calls(0)` → `call(0)` (singular for single item)
|
|
34
|
+
- `calls()` array → `calls` getter for count
|
|
35
|
+
- `inst()` unchanged, add `instance()` synonym
|
|
36
|
+
- `numInsts()` → `insts` / `instances` getter
|
|
37
|
+
- `ret` indexing: 0-indexed, no index = default (was 1-indexed with 0 as default)
|
|
38
|
+
- `data()` function → `data` object
|
|
39
|
+
|
|
40
|
+
## Additional Changes
|
|
41
|
+
|
|
42
|
+
- `mock.throw(error)` / `mock.throw(error, 0)` - explicit error throwing
|
|
43
|
+
- `argSelect()` → `pick()` - cleaner name
|
|
44
|
+
- `ret()` on builder before `build()` - `mocky.fn().ret('value').build()`
|
|
45
|
+
- Remove or improve `property()` builder
|
|
46
|
+
- Add JSDoc comments for autocomplete (no TypeScript needed)
|
|
47
|
+
- Use `structuredClone()` instead of custom deepClone (Node 17+)
|
|
48
|
+
- Spy replacement: accept plain function with optional args param
|
|
49
|
+
`mocky.spy(obj, 'method', (ctx) => ..., ['x', 'y'])`
|
|
50
|
+
|
|
51
|
+
## Rationale
|
|
52
|
+
|
|
53
|
+
- Singular/plural pattern: `call(0)` gets one, `calls` is count
|
|
54
|
+
- 0-indexed everywhere (matches JS arrays)
|
|
55
|
+
- Getters for counts (they're just values, no args needed)
|
|
56
|
+
- `ret('default')` more intuitive than `ret('default', 0)`
|
|
57
|
+
- Synonyms for readability preference: `inst`/`instance`
|
package/init-docker.sh
ADDED