|
1 | 1 | import { BlockNoteEditor } from "@blocknote/core"; |
2 | 2 | import { beforeEach, describe, expect, it } from "vitest"; |
3 | 3 | import { tools } from "../api/formats/json/tools/index.js"; |
4 | | -import { |
5 | | - preprocessOperationsNonStreaming, |
6 | | - preprocessOperationsStreaming, |
7 | | -} from "./preprocess.js"; |
| 4 | +import { preprocessOperationsStreaming } from "./preprocess.js"; |
8 | 5 | import { StreamTool } from "./streamTool.js"; |
9 | 6 |
|
10 | 7 | const addOperationValid = { |
@@ -148,68 +145,37 @@ describe("preprocess", () => { |
148 | 145 | }); |
149 | 146 | }); |
150 | 147 |
|
151 | | - describe("preprocessOperationsNonStreaming", () => { |
152 | | - it("should pass valid operations", async () => { |
153 | | - async function* mockStream() { |
154 | | - yield { |
155 | | - partialOperation: addOperationValid, |
156 | | - isUpdateToPreviousOperation: false, |
157 | | - isPossiblyPartial: false, |
158 | | - metadata: undefined, |
159 | | - }; |
160 | | - } |
161 | | - |
162 | | - const results = await collectStreamToArray( |
163 | | - preprocessOperationsNonStreaming(mockStream(), streamTools), |
164 | | - ); |
165 | | - |
166 | | - expect(results.length).toBe(1); |
167 | | - }); |
168 | | - |
169 | | - it("should throw an error on invalid operations (invalid id)", async () => { |
170 | | - async function* mockStream() { |
171 | | - yield { |
172 | | - partialOperation: addOperationInvalidId, |
173 | | - isUpdateToPreviousOperation: false, |
174 | | - isPossiblyPartial: false, |
175 | | - metadata: undefined, |
176 | | - }; |
177 | | - } |
178 | | - |
179 | | - await expect( |
180 | | - collectStreamToArray( |
181 | | - preprocessOperationsNonStreaming(mockStream(), streamTools), |
182 | | - ), |
183 | | - ).rejects.toThrow(); |
184 | | - }); |
185 | | - |
186 | | - it("should throw an error on invalid operations (invalid type)", async () => { |
187 | | - async function* mockStream() { |
188 | | - yield { |
189 | | - partialOperation: invalidOperationType, |
190 | | - isUpdateToPreviousOperation: false, |
191 | | - isPossiblyPartial: false, |
192 | | - metadata: undefined, |
193 | | - }; |
194 | | - } |
195 | | - |
196 | | - await expect( |
197 | | - collectStreamToArray( |
198 | | - preprocessOperationsNonStreaming(mockStream(), streamTools), |
199 | | - ), |
200 | | - ).rejects.toThrow(); |
201 | | - }); |
202 | | - |
203 | | - it("should handle empty operation streams", async () => { |
204 | | - async function* mockStream() { |
205 | | - // Empty stream |
206 | | - } |
207 | | - |
208 | | - const results = await collectStreamToArray( |
209 | | - preprocessOperationsNonStreaming(mockStream(), streamTools), |
210 | | - ); |
| 148 | + it("should throw an error on invalid operations (invalid id)", async () => { |
| 149 | + async function* mockStream() { |
| 150 | + yield { |
| 151 | + partialOperation: addOperationInvalidId, |
| 152 | + isUpdateToPreviousOperation: false, |
| 153 | + isPossiblyPartial: false, |
| 154 | + metadata: undefined, |
| 155 | + }; |
| 156 | + } |
| 157 | + |
| 158 | + await expect( |
| 159 | + collectStreamToArray( |
| 160 | + preprocessOperationsStreaming(mockStream(), streamTools), |
| 161 | + ), |
| 162 | + ).rejects.toThrow(); |
| 163 | + }); |
211 | 164 |
|
212 | | - expect(results).toHaveLength(0); |
213 | | - }); |
| 165 | + it("should throw an error on invalid operations (invalid type)", async () => { |
| 166 | + async function* mockStream() { |
| 167 | + yield { |
| 168 | + partialOperation: invalidOperationType, |
| 169 | + isUpdateToPreviousOperation: false, |
| 170 | + isPossiblyPartial: false, |
| 171 | + metadata: undefined, |
| 172 | + }; |
| 173 | + } |
| 174 | + |
| 175 | + await expect( |
| 176 | + collectStreamToArray( |
| 177 | + preprocessOperationsStreaming(mockStream(), streamTools), |
| 178 | + ), |
| 179 | + ).rejects.toThrow(); |
214 | 180 | }); |
215 | 181 | }); |
0 commit comments