jarvis-arch-hexagonal-gen 1.0.6 → 1.0.8

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.
@@ -16,7 +16,6 @@ class PluginManager {
16
16
  if (this.cache.has(pluginName))
17
17
  return this.cache.get(pluginName);
18
18
  const foundPath = this.findPluginPath(pluginName);
19
- console.log(foundPath);
20
19
  if (!foundPath) {
21
20
  throw new Error(`Manifest não encontrado para o plugin "${pluginName}"`);
22
21
  }
@@ -45,12 +44,9 @@ class PluginManager {
45
44
  findPluginPath(pluginName) {
46
45
  const search = (dir) => {
47
46
  const items = fs_extra_1.default.readdirSync(dir);
48
- console.log("item", JSON.stringify(items, null, 2));
49
47
  for (const item of items) {
50
48
  const fullPath = path_1.default.join(dir, item);
51
49
  const stat = fs_extra_1.default.statSync(fullPath);
52
- console.log("fullPath: ", fullPath);
53
- console.log("stat: ", stat);
54
50
  if (stat.isDirectory()) {
55
51
  if (item === pluginName && fs_extra_1.default.existsSync(path_1.default.join(fullPath, 'manifest.json'))) {
56
52
  return fullPath;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "tests",
3
+ "description": "Gera testes unitários e de integração para a entidade",
4
+ "dependencies": [],
5
+ "files": [
6
+ {
7
+ "template": "usecase.spec.ejs",
8
+ "output": "src/tests/unit/<%= entity %>/create-<%= entityLower %>.usecase.spec.ts"
9
+ },
10
+ {
11
+ "template": "usecase.spec.ejs",
12
+ "output": "src/tests/unit/<%= entity %>/update-<%= entityLower %>.usecase.spec.ts"
13
+ },
14
+ {
15
+ "template": "usecase.spec.ejs",
16
+ "output": "src/tests/unit/<%= entity %>/delete-<%= entityLower %>.usecase.spec.ts"
17
+ },
18
+ {
19
+ "template": "usecase.spec.ejs",
20
+ "output": "src/tests/unit/<%= entity %>/find-<%= entityLower %>-by-id.usecase.spec.ts"
21
+ },
22
+ {
23
+ "template": "usecase.spec.ejs",
24
+ "output": "src/tests/unit/<%= entity %>/find-all-<%= pluralLower %>.usecase.spec.ts"
25
+ },
26
+ {
27
+ "template": "integration.ejs",
28
+ "output": "src/tests/integration/<%= route %>.integration.spec.ts"
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,61 @@
1
+ import request from 'supertest';
2
+ import { app } from '../../src/app'; // ajuste conforme sua estrutura
3
+
4
+ describe('<%= entity %> Integration Tests', () => {
5
+ it('should create a new <%= entityLower %>', async () => {
6
+ const res = await request(app)
7
+ .post('/api/<%= route %>')
8
+ .send({
9
+ <% columns.filter(c => !c.primary).forEach(c => { %> <%= c.name %>: '<%= c.type === 'number' ? 123 : 'test' %>',
10
+ <% }) %> });
11
+ expect(res.status).toBe(201);
12
+ expect(res.body).toHaveProperty('id');
13
+ });
14
+
15
+ it('should list all <%= pluralLower %>', async () => {
16
+ const res = await request(app).get('/api/<%= route %>');
17
+ expect(res.status).toBe(200);
18
+ expect(Array.isArray(res.body)).toBe(true);
19
+ });
20
+
21
+ it('should get a <%= entityLower %> by id', async () => {
22
+ const createRes = await request(app)
23
+ .post('/api/<%= route %>')
24
+ .send({
25
+ <% columns.filter(c => !c.primary).forEach(c => { %> <%= c.name %>: '<%= c.type === 'number' ? 123 : 'test' %>',
26
+ <% }) %> });
27
+ const id = createRes.body.id;
28
+ const res = await request(app).get(`/api/<%= route %>/${id}`);
29
+ expect(res.status).toBe(200);
30
+ expect(res.body.id).toBe(id);
31
+ });
32
+
33
+ it('should update a <%= entityLower %>', async () => {
34
+ const createRes = await request(app)
35
+ .post('/api/<%= route %>')
36
+ .send({
37
+ <% columns.filter(c => !c.primary).forEach(c => { %> <%= c.name %>: '<%= c.type === 'number' ? 123 : 'test' %>',
38
+ <% }) %> });
39
+ const id = createRes.body.id;
40
+ const res = await request(app)
41
+ .put(`/api/<%= route %>/${id}`)
42
+ .send({
43
+ name: 'updated',
44
+ });
45
+ expect(res.status).toBe(200);
46
+ expect(res.body.name).toBe('updated');
47
+ });
48
+
49
+ it('should delete a <%= entityLower %>', async () => {
50
+ const createRes = await request(app)
51
+ .post('/api/<%= route %>')
52
+ .send({
53
+ <% columns.filter(c => !c.primary).forEach(c => { %> <%= c.name %>: '<%= c.type === 'number' ? 123 : 'test' %>',
54
+ <% }) %> });
55
+ const id = createRes.body.id;
56
+ const res = await request(app).delete(`/api/<%= route %>/${id}`);
57
+ expect(res.status).toBe(204);
58
+ const getRes = await request(app).get(`/api/<%= route %>/${id}`);
59
+ expect(getRes.status).toBe(404);
60
+ });
61
+ });
@@ -0,0 +1,35 @@
1
+ import { Create<%= entity %>UseCase } from './create-<%= entityLower %>.usecase';
2
+ import { I<%= entity %>Repository } from '../repositories/I<%= entity %>Repository';
3
+
4
+ describe('Create<%= entity %>UseCase', () => {
5
+ let useCase: Create<%= entity %>UseCase;
6
+ let mockRepo: jest.Mocked<I<%= entity %>Repository>;
7
+
8
+ beforeEach(() => {
9
+ mockRepo = {
10
+ create: jest.fn(),
11
+ update: jest.fn(),
12
+ delete: jest.fn(),
13
+ findById: jest.fn(),
14
+ findAll: jest.fn(),
15
+ };
16
+ useCase = new Create<%= entity %>UseCase(mockRepo);
17
+ });
18
+
19
+ it('should create a new <%= entityLower %> successfully', async () => {
20
+ const input = {
21
+ <% columns.filter(c => !c.primary).forEach(c => { %> <%= c.name %>: '<%= c.type === 'number' ? 123 : 'test' %>',
22
+ <% }) %> };
23
+ const expected = { id: 1, ...input };
24
+ mockRepo.create.mockResolvedValue(expected);
25
+
26
+ const result = await useCase.execute(input);
27
+ expect(result).toEqual(expected);
28
+ expect(mockRepo.create).toHaveBeenCalledWith(input);
29
+ });
30
+
31
+ it('should throw error if repository fails', async () => {
32
+ mockRepo.create.mockRejectedValue(new Error('Database error'));
33
+ await expect(useCase.execute({})).rejects.toThrow('Database error');
34
+ });
35
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jarvis-arch-hexagonal-gen",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Gerador de recursos para projetos Node.js com TypeScript",
5
5
  "keywords": [
6
6
  "Arquitetura Hexagonal",