From 2637c94fbffc3e88fc36b52b6f4407582055a2db Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Wed, 4 Jan 2023 16:44:48 +0800 Subject: [PATCH] fupengfei6@huawei.com Signed-off-by: fupengfei001 --- .../src/generate/generateCommonUtil.ts | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/mock-generate/src/generate/generateCommonUtil.ts b/mock-generate/src/generate/generateCommonUtil.ts index 8e75e8d4..c1a422ee 100644 --- a/mock-generate/src/generate/generateCommonUtil.ts +++ b/mock-generate/src/generate/generateCommonUtil.ts @@ -54,16 +54,46 @@ export function getReturnStatement(returnType: ReturnTypeEntity, sourceFile: Sou return `return new ${returnType.returnKindName}()`; } else if (returnType.returnKindName.startsWith('IterableIterator')) { if (returnType.returnKindName.includes(',')) { - return `const IteratorEntriesMock = { + return `let index = 0; + const IteratorEntriesMock = { *[Symbol.iterator]() { yield ['[PC Preview] unkonwn paramIterMock_K', '[PC Preview] unkonwn paramIterMock_V']; + }, + next: () => { + if (index < 1) { + const returnValue = ['[PC Previwe] unkonwn paramIterMock_K', '[PC Previwe] unkonwn paramIterMock_V']; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } }; return IteratorEntriesMock;`; } else { - return `const IteratorStringMock = { + return `let index = 0; + const IteratorStringMock = { *[Symbol.iterator]() { yield '[PC Preview] unkonwn string'; + }, + next: () => { + if (index < 1) { + const returnValue = '[PC Previwe] unkonwn string'; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } }; return IteratorStringMock;`;