UNPKG

tprompter

Version:
66 lines (60 loc) 3.3 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { Service } from 'typedi'; import { StdinDataReader } from '../utils/StdinDataReader.js'; import { TextDataEnricher } from '../textDataEnricher/TextDataEnricher.js'; let WriteUnitTestsPrompt = class WriteUnitTestsPrompt { constructor(stdinReader, enricher) { this.stdinReader = stdinReader; this.enricher = enricher; this.name = 'write_unit_tests'; } generate() { return __awaiter(this, void 0, void 0, function* () { const inputExamplesRaw = yield this.stdinReader.readData('Enter unit test examples:'); const inputCodeRaw = yield this.stdinReader.readData('Enter the code that should be tested:'); const inputCode = yield this.enricher.enrichRawInput(inputCodeRaw.trim()); const inputExamples = yield this.enricher.enrichRawInput(inputExamplesRaw.trim()); return ` You are a senior developer at a software company. You have been tasked with writing unit tests a code. You can use the following unit test examples for reference: \`\`\` ${inputExamples} \`\`\` You are provided with the following code that needs to be tested: \`\`\` ${inputCode} \`\`\` Your task is to: 1. Write a new unit test file that thoroughly tests the provided code. 2. Use the examples as a guide to ensure consistent structure, style, and patterns. 3. Use proper mocking and assertions where necessary to simulate real-world behavior and dependencies. The output should include: • A complete unit test file in that adheres to best practices. • Avoid long comments and explanation. Instead, focus on writing clean, concise, and maintainable code. `.trim(); }); } }; WriteUnitTestsPrompt = __decorate([ Service(), __metadata("design:paramtypes", [StdinDataReader, TextDataEnricher]) ], WriteUnitTestsPrompt); export { WriteUnitTestsPrompt };