also looking at this
test: make CI exercise maintained integrations
#18
16 files
+390
-139
| @@ -1,19 +1,34 @@ | ||
| 1 | 1 | const std = ; |
| 2 | const ztf = ; | |
| 2 | 3 | |
| 3 | // Placeholder tests for mock module | |
| 4 | // TODO: Implement comprehensive tests for mocking and spying | |
| 5 | ||
| 6 | test "mock function call tracking" { | |
| 7 | // Test mock call recording | |
| 8 | try std.testing.expect(true); | |
| 4 | test "mock records calls and exposes the latest invocation" { | |
| 5 | var mock = ztf.createMock(std.testing.allocator, i32); | |
| 6 | defer mock.deinit(); | |
| 7 | try mock.recordCall("first"); | |
| 8 | try mock.recordCall("second"); | |
| 9 | try std.testing.expectEqual(@as(usize, 2), mock.callCount()); | |
| 10 | try std.testing.expectEqualStrings("second", mock.getLastCall().?.args); | |
| 11 | try mock.toHaveBeenCalledWith("first"); | |
| 9 | 12 | } |
| 10 | 13 | |
| 11 | test "mock return values" { | |
| 12 | // Test mock return value functionality | |
| 13 | try std.testing.expect(true); | |
| 14 | test "mock returns configured values in order" { | |
| 15 | var mock = ztf.createMock(std.testing.allocator, i32); | |
| 16 | defer mock.deinit(); | |
| 17 | _ = try mock.mockReturnValueOnce(10); | |
| 18 | _ = try mock.mockReturnValue(20); | |
| 19 | try std.testing.expectEqual(@as(?i32, 10), mock.getReturnValue()); | |
| 20 | try std.testing.expectEqual(@as(?i32, 20), mock.getReturnValue()); | |
| 21 | try std.testing.expectEqual(@as(?i32, 20), mock.getReturnValue()); | |
| 14 | 22 | } |
| 15 | 23 | |
| 16 | test "spy functionality" { | |
| 17 | // Test spy wrapping of functions | |
| 18 | try std.testing.expect(true); | |
| 24 | test "mock clear preserves return values while reset removes them" { | |
| 25 | var mock = ztf.createMock(std.testing.allocator, i32); | |
| 26 | defer mock.deinit(); | |
| 27 | try mock.recordCall("call"); | |
| 28 | _ = try mock.mockReturnValue(7); | |
| 29 | _ = mock.mockClear(); | |
| 30 | try std.testing.expectEqual(@as(usize, 0), mock.callCount()); | |
| 31 | try std.testing.expectEqual(@as(?i32, 7), mock.getReturnValue()); | |
| 32 | _ = mock.mockReset(); | |
| 33 | try std.testing.expectEqual(@as(?i32, null), mock.getReturnValue()); | |
| 19 | 34 | } |