@flusys/nestjs-task-manager 6.0.2 → 6.1.0

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.
Files changed (35) hide show
  1. package/cjs/controllers/task-board.controller.spec.js +132 -0
  2. package/cjs/controllers/task-comment.controller.spec.js +86 -0
  3. package/cjs/controllers/task-label.controller.spec.js +88 -0
  4. package/cjs/controllers/task-list.controller.spec.js +112 -0
  5. package/cjs/controllers/task.controller.spec.js +131 -0
  6. package/cjs/docs/task-manager-swagger.config.spec.js +28 -0
  7. package/cjs/entities/index.spec.js +30 -0
  8. package/cjs/gateways/task-board.gateway.spec.js +243 -0
  9. package/cjs/modules/task-manager.module.spec.js +144 -0
  10. package/cjs/services/task-activity.service.spec.js +125 -0
  11. package/cjs/services/task-board.service.spec.js +429 -0
  12. package/cjs/services/task-comment.service.spec.js +160 -0
  13. package/cjs/services/task-label.service.spec.js +138 -0
  14. package/cjs/services/task-list.service.spec.js +214 -0
  15. package/cjs/services/task-manager-config.service.spec.js +98 -0
  16. package/cjs/services/task-manager-datasource.provider.spec.js +131 -0
  17. package/cjs/services/task.service.spec.js +610 -0
  18. package/fesm/controllers/task-board.controller.spec.js +128 -0
  19. package/fesm/controllers/task-comment.controller.spec.js +82 -0
  20. package/fesm/controllers/task-label.controller.spec.js +84 -0
  21. package/fesm/controllers/task-list.controller.spec.js +108 -0
  22. package/fesm/controllers/task.controller.spec.js +127 -0
  23. package/fesm/docs/task-manager-swagger.config.spec.js +24 -0
  24. package/fesm/entities/index.spec.js +26 -0
  25. package/fesm/gateways/task-board.gateway.spec.js +239 -0
  26. package/fesm/modules/task-manager.module.spec.js +140 -0
  27. package/fesm/services/task-activity.service.spec.js +121 -0
  28. package/fesm/services/task-board.service.spec.js +425 -0
  29. package/fesm/services/task-comment.service.spec.js +156 -0
  30. package/fesm/services/task-label.service.spec.js +134 -0
  31. package/fesm/services/task-list.service.spec.js +210 -0
  32. package/fesm/services/task-manager-config.service.spec.js +94 -0
  33. package/fesm/services/task-manager-datasource.provider.spec.js +127 -0
  34. package/fesm/services/task.service.spec.js +606 -0
  35. package/package.json +3 -3
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
6
+ const _taskboardcontroller = require("./task-board.controller");
7
+ function buildBoard(overrides = {}) {
8
+ return {
9
+ id: 'board-uuid-1',
10
+ name: 'Sprint Board',
11
+ description: null,
12
+ isActive: true,
13
+ readOnly: false,
14
+ createdAt: new Date(),
15
+ updatedAt: new Date(),
16
+ ...overrides
17
+ };
18
+ }
19
+ describe('TaskBoardController', ()=>{
20
+ let controller;
21
+ let mockBoardService;
22
+ beforeEach(()=>{
23
+ mockBoardService = {
24
+ insert: jest.fn(),
25
+ findById: jest.fn(),
26
+ getAll: jest.fn(),
27
+ update: jest.fn(),
28
+ delete: jest.fn(),
29
+ addMember: jest.fn(),
30
+ removeMember: jest.fn(),
31
+ getMembers: jest.fn()
32
+ };
33
+ controller = new _taskboardcontroller.TaskBoardController(mockBoardService);
34
+ });
35
+ describe('insert', ()=>{
36
+ it('creates a board and returns the mapped response', async ()=>{
37
+ const user = (0, _loggedusermock.buildMockUser)();
38
+ mockBoardService.insert.mockResolvedValue(buildBoard());
39
+ const result = await controller.insert({
40
+ name: 'Sprint Board'
41
+ }, user);
42
+ expect(mockBoardService.insert).toHaveBeenCalledWith({
43
+ name: 'Sprint Board'
44
+ }, user);
45
+ expect(result.success).toBe(true);
46
+ expect(result.data).toEqual(expect.objectContaining({
47
+ id: 'board-uuid-1'
48
+ }));
49
+ });
50
+ });
51
+ describe('getAll', ()=>{
52
+ it('paginates boards and maps the response list', async ()=>{
53
+ mockBoardService.getAll.mockResolvedValue({
54
+ data: [
55
+ buildBoard()
56
+ ],
57
+ total: 1
58
+ });
59
+ const result = await controller.getAll({}, (0, _loggedusermock.buildMockUser)(), '');
60
+ expect(mockBoardService.getAll).toHaveBeenCalledWith('', {}, (0, _loggedusermock.buildMockUser)());
61
+ expect(result.data).toHaveLength(1);
62
+ });
63
+ });
64
+ describe('addMember', ()=>{
65
+ it('adds a member to the board and maps the response', async ()=>{
66
+ const user = (0, _loggedusermock.buildMockUser)();
67
+ mockBoardService.addMember.mockResolvedValue({
68
+ id: 'member-1',
69
+ boardId: 'board-uuid-1',
70
+ userId: 'user-2',
71
+ role: 'member'
72
+ });
73
+ const result = await controller.addMember({
74
+ boardId: 'board-uuid-1',
75
+ userId: 'user-2'
76
+ }, user);
77
+ expect(mockBoardService.addMember).toHaveBeenCalledWith({
78
+ boardId: 'board-uuid-1',
79
+ userId: 'user-2'
80
+ }, user);
81
+ expect(result.success).toBe(true);
82
+ expect(result.data).toEqual(expect.objectContaining({
83
+ userId: 'user-2'
84
+ }));
85
+ });
86
+ });
87
+ describe('removeMember', ()=>{
88
+ it('removes a member from the board', async ()=>{
89
+ mockBoardService.removeMember.mockResolvedValue(undefined);
90
+ const result = await controller.removeMember({
91
+ boardId: 'board-uuid-1',
92
+ userId: 'user-2'
93
+ });
94
+ expect(mockBoardService.removeMember).toHaveBeenCalledWith({
95
+ boardId: 'board-uuid-1',
96
+ userId: 'user-2'
97
+ });
98
+ expect(result.success).toBe(true);
99
+ });
100
+ });
101
+ describe('getMembers', ()=>{
102
+ it('returns all members for a board with a computed pagination meta', async ()=>{
103
+ mockBoardService.getMembers.mockResolvedValue([
104
+ {
105
+ id: 'member-1',
106
+ userId: 'user-2',
107
+ role: 'member'
108
+ }
109
+ ]);
110
+ const result = await controller.getMembers({
111
+ boardId: 'board-uuid-1'
112
+ });
113
+ expect(mockBoardService.getMembers).toHaveBeenCalledWith('board-uuid-1');
114
+ expect(result.data).toHaveLength(1);
115
+ expect(result.meta).toEqual(expect.objectContaining({
116
+ total: 1,
117
+ count: 1
118
+ }));
119
+ });
120
+ it('returns an empty list with zeroed meta when the board has no members', async ()=>{
121
+ mockBoardService.getMembers.mockResolvedValue([]);
122
+ const result = await controller.getMembers({
123
+ boardId: 'board-uuid-1'
124
+ });
125
+ expect(result.data).toEqual([]);
126
+ expect(result.meta).toEqual(expect.objectContaining({
127
+ total: 0,
128
+ count: 0
129
+ }));
130
+ });
131
+ });
132
+ });
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
6
+ const _taskcommentcontroller = require("./task-comment.controller");
7
+ function buildComment(overrides = {}) {
8
+ return {
9
+ id: 'comment-1',
10
+ taskId: 'task-uuid-1',
11
+ userId: 'user-uuid-1',
12
+ body: 'Looks good to me',
13
+ readOnly: false,
14
+ createdAt: new Date(),
15
+ updatedAt: new Date(),
16
+ ...overrides
17
+ };
18
+ }
19
+ describe('TaskCommentController', ()=>{
20
+ let controller;
21
+ let mockCommentService;
22
+ beforeEach(()=>{
23
+ mockCommentService = {
24
+ insert: jest.fn(),
25
+ findById: jest.fn(),
26
+ getAll: jest.fn(),
27
+ update: jest.fn(),
28
+ delete: jest.fn()
29
+ };
30
+ controller = new _taskcommentcontroller.TaskCommentController(mockCommentService);
31
+ });
32
+ it('wires the injected service onto the generated controller base', ()=>{
33
+ expect(controller.service).toBe(mockCommentService);
34
+ });
35
+ describe('insert', ()=>{
36
+ it('creates a comment and returns the mapped response', async ()=>{
37
+ const user = (0, _loggedusermock.buildMockUser)();
38
+ mockCommentService.insert.mockResolvedValue(buildComment());
39
+ const result = await controller.insert({
40
+ taskId: 'task-uuid-1',
41
+ body: 'Looks good to me'
42
+ }, user);
43
+ expect(mockCommentService.insert).toHaveBeenCalledWith({
44
+ taskId: 'task-uuid-1',
45
+ body: 'Looks good to me'
46
+ }, user);
47
+ expect(result.success).toBe(true);
48
+ expect(result.data).toEqual(expect.objectContaining({
49
+ id: 'comment-1'
50
+ }));
51
+ });
52
+ });
53
+ describe('getAll', ()=>{
54
+ it('paginates comments and maps the response list', async ()=>{
55
+ mockCommentService.getAll.mockResolvedValue({
56
+ data: [
57
+ buildComment()
58
+ ],
59
+ total: 1
60
+ });
61
+ const result = await controller.getAll({}, (0, _loggedusermock.buildMockUser)(), '');
62
+ expect(mockCommentService.getAll).toHaveBeenCalledWith('', {}, (0, _loggedusermock.buildMockUser)());
63
+ expect(result.data).toHaveLength(1);
64
+ });
65
+ });
66
+ describe('delete', ()=>{
67
+ it('delegates soft-delete to the service', async ()=>{
68
+ mockCommentService.delete.mockResolvedValue({
69
+ count: 1
70
+ });
71
+ const result = await controller.delete({
72
+ id: [
73
+ 'comment-1'
74
+ ],
75
+ type: 'delete'
76
+ }, (0, _loggedusermock.buildMockUser)());
77
+ expect(mockCommentService.delete).toHaveBeenCalledWith({
78
+ id: [
79
+ 'comment-1'
80
+ ],
81
+ type: 'delete'
82
+ }, (0, _loggedusermock.buildMockUser)());
83
+ expect(result.success).toBe(true);
84
+ });
85
+ });
86
+ });
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
6
+ const _tasklabelcontroller = require("./task-label.controller");
7
+ function buildLabel(overrides = {}) {
8
+ return {
9
+ id: 'label-1',
10
+ boardId: 'board-uuid-1',
11
+ name: 'Bug',
12
+ color: '#ff0000',
13
+ readOnly: false,
14
+ createdAt: new Date(),
15
+ updatedAt: new Date(),
16
+ ...overrides
17
+ };
18
+ }
19
+ describe('TaskLabelController', ()=>{
20
+ let controller;
21
+ let mockLabelService;
22
+ beforeEach(()=>{
23
+ mockLabelService = {
24
+ insert: jest.fn(),
25
+ findById: jest.fn(),
26
+ getAll: jest.fn(),
27
+ update: jest.fn(),
28
+ delete: jest.fn()
29
+ };
30
+ controller = new _tasklabelcontroller.TaskLabelController(mockLabelService);
31
+ });
32
+ it('wires the injected service onto the generated controller base', ()=>{
33
+ expect(controller.service).toBe(mockLabelService);
34
+ });
35
+ describe('insert', ()=>{
36
+ it('creates a label and returns the mapped response', async ()=>{
37
+ const user = (0, _loggedusermock.buildMockUser)();
38
+ mockLabelService.insert.mockResolvedValue(buildLabel());
39
+ const result = await controller.insert({
40
+ boardId: 'board-uuid-1',
41
+ name: 'Bug',
42
+ color: '#ff0000'
43
+ }, user);
44
+ expect(mockLabelService.insert).toHaveBeenCalledWith({
45
+ boardId: 'board-uuid-1',
46
+ name: 'Bug',
47
+ color: '#ff0000'
48
+ }, user);
49
+ expect(result.success).toBe(true);
50
+ expect(result.data).toEqual(expect.objectContaining({
51
+ id: 'label-1'
52
+ }));
53
+ });
54
+ });
55
+ describe('getAll', ()=>{
56
+ it('paginates labels and maps the response list', async ()=>{
57
+ mockLabelService.getAll.mockResolvedValue({
58
+ data: [
59
+ buildLabel()
60
+ ],
61
+ total: 1
62
+ });
63
+ const result = await controller.getAll({}, (0, _loggedusermock.buildMockUser)(), '');
64
+ expect(mockLabelService.getAll).toHaveBeenCalledWith('', {}, (0, _loggedusermock.buildMockUser)());
65
+ expect(result.data).toHaveLength(1);
66
+ });
67
+ });
68
+ describe('delete', ()=>{
69
+ it('delegates soft-delete to the service', async ()=>{
70
+ mockLabelService.delete.mockResolvedValue({
71
+ count: 1
72
+ });
73
+ const result = await controller.delete({
74
+ id: [
75
+ 'label-1'
76
+ ],
77
+ type: 'delete'
78
+ }, (0, _loggedusermock.buildMockUser)());
79
+ expect(mockLabelService.delete).toHaveBeenCalledWith({
80
+ id: [
81
+ 'label-1'
82
+ ],
83
+ type: 'delete'
84
+ }, (0, _loggedusermock.buildMockUser)());
85
+ expect(result.success).toBe(true);
86
+ });
87
+ });
88
+ });
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
6
+ const _tasklistcontroller = require("./task-list.controller");
7
+ function buildList(overrides = {}) {
8
+ return {
9
+ id: 'list-uuid-1',
10
+ boardId: 'board-uuid-1',
11
+ name: 'To Do',
12
+ position: 0,
13
+ readOnly: false,
14
+ createdAt: new Date(),
15
+ updatedAt: new Date(),
16
+ ...overrides
17
+ };
18
+ }
19
+ describe('TaskListController', ()=>{
20
+ let controller;
21
+ let mockListService;
22
+ let mockGateway;
23
+ beforeEach(()=>{
24
+ mockListService = {
25
+ insert: jest.fn(),
26
+ findById: jest.fn(),
27
+ getAll: jest.fn(),
28
+ update: jest.fn(),
29
+ delete: jest.fn(),
30
+ reorderLists: jest.fn()
31
+ };
32
+ mockGateway = {
33
+ emitToBoardRoom: jest.fn()
34
+ };
35
+ controller = new _tasklistcontroller.TaskListController(mockListService, mockGateway);
36
+ });
37
+ it('wires the injected service onto the generated controller base', ()=>{
38
+ expect(controller.service).toBe(mockListService);
39
+ });
40
+ describe('insert', ()=>{
41
+ it('creates a list and returns the mapped response', async ()=>{
42
+ const user = (0, _loggedusermock.buildMockUser)();
43
+ mockListService.insert.mockResolvedValue(buildList());
44
+ const result = await controller.insert({
45
+ boardId: 'board-uuid-1',
46
+ name: 'To Do'
47
+ }, user);
48
+ expect(mockListService.insert).toHaveBeenCalledWith({
49
+ boardId: 'board-uuid-1',
50
+ name: 'To Do'
51
+ }, user);
52
+ expect(result.success).toBe(true);
53
+ expect(result.data).toEqual(expect.objectContaining({
54
+ id: 'list-uuid-1'
55
+ }));
56
+ });
57
+ });
58
+ describe('getAll', ()=>{
59
+ it('paginates lists and maps the response list', async ()=>{
60
+ mockListService.getAll.mockResolvedValue({
61
+ data: [
62
+ buildList()
63
+ ],
64
+ total: 1
65
+ });
66
+ const result = await controller.getAll({}, (0, _loggedusermock.buildMockUser)(), '');
67
+ expect(mockListService.getAll).toHaveBeenCalledWith('', {}, (0, _loggedusermock.buildMockUser)());
68
+ expect(result.data).toHaveLength(1);
69
+ });
70
+ });
71
+ describe('reorder', ()=>{
72
+ it('reorders lists and broadcasts a list:reordered event to the board room', async ()=>{
73
+ mockListService.reorderLists.mockResolvedValue(undefined);
74
+ const result = await controller.reorder({
75
+ boardId: 'board-uuid-1',
76
+ orderedIds: [
77
+ 'list-2',
78
+ 'list-1'
79
+ ]
80
+ });
81
+ expect(mockListService.reorderLists).toHaveBeenCalledWith({
82
+ boardId: 'board-uuid-1',
83
+ orderedIds: [
84
+ 'list-2',
85
+ 'list-1'
86
+ ]
87
+ });
88
+ expect(mockGateway.emitToBoardRoom).toHaveBeenCalledWith('board-uuid-1', expect.objectContaining({
89
+ type: 'list:reordered',
90
+ boardId: 'board-uuid-1',
91
+ payload: {
92
+ orderedIds: [
93
+ 'list-2',
94
+ 'list-1'
95
+ ]
96
+ }
97
+ }));
98
+ expect(result.success).toBe(true);
99
+ });
100
+ it('still succeeds when no gateway is wired (optional dependency)', async ()=>{
101
+ const controllerNoGateway = new _tasklistcontroller.TaskListController(mockListService, undefined);
102
+ mockListService.reorderLists.mockResolvedValue(undefined);
103
+ const result = await controllerNoGateway.reorder({
104
+ boardId: 'board-uuid-1',
105
+ orderedIds: [
106
+ 'list-1'
107
+ ]
108
+ });
109
+ expect(result.success).toBe(true);
110
+ });
111
+ });
112
+ });
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
6
+ const _entities = require("../entities");
7
+ const _taskcontroller = require("./task.controller");
8
+ function buildTask(overrides = {}) {
9
+ return {
10
+ id: 'task-uuid-1',
11
+ boardId: 'board-uuid-1',
12
+ listId: 'list-uuid-1',
13
+ title: 'Fix bug',
14
+ description: null,
15
+ priority: _entities.TaskPriority.MEDIUM,
16
+ dueDate: null,
17
+ position: 0,
18
+ assignees: [],
19
+ reporterId: 'user-uuid-1',
20
+ parentTaskId: null,
21
+ estimatedHours: null,
22
+ createdAt: new Date(),
23
+ updatedAt: new Date(),
24
+ ...overrides
25
+ };
26
+ }
27
+ describe('TaskController', ()=>{
28
+ let controller;
29
+ let mockTaskService;
30
+ let mockGateway;
31
+ beforeEach(async ()=>{
32
+ mockTaskService = {
33
+ moveTask: jest.fn(),
34
+ assignTask: jest.fn(),
35
+ insert: jest.fn(),
36
+ update: jest.fn(),
37
+ getAll: jest.fn(),
38
+ findById: jest.fn(),
39
+ delete: jest.fn()
40
+ };
41
+ mockGateway = {
42
+ emitToBoardRoom: jest.fn()
43
+ };
44
+ controller = new _taskcontroller.TaskController(mockTaskService, mockGateway);
45
+ });
46
+ describe('moveTask', ()=>{
47
+ it('moves the task and broadcasts a task:moved event to the board room', async ()=>{
48
+ const task = buildTask({
49
+ listId: 'list-new',
50
+ position: 2
51
+ });
52
+ mockTaskService.moveTask.mockResolvedValue(task);
53
+ const user = (0, _loggedusermock.buildMockUser)();
54
+ const result = await controller.moveTask({
55
+ taskId: 'task-uuid-1',
56
+ targetListId: 'list-new',
57
+ position: 2
58
+ }, user);
59
+ expect(mockTaskService.moveTask).toHaveBeenCalledWith({
60
+ taskId: 'task-uuid-1',
61
+ targetListId: 'list-new',
62
+ position: 2
63
+ }, user);
64
+ expect(result.success).toBe(true);
65
+ expect(result.data).toEqual(expect.objectContaining({
66
+ id: 'task-uuid-1',
67
+ listId: 'list-new'
68
+ }));
69
+ expect(mockGateway.emitToBoardRoom).toHaveBeenCalledWith('board-uuid-1', expect.objectContaining({
70
+ type: 'task:moved',
71
+ boardId: 'board-uuid-1'
72
+ }));
73
+ });
74
+ it('still returns successfully when no gateway is wired (optional dependency)', async ()=>{
75
+ const controllerNoGateway = new _taskcontroller.TaskController(mockTaskService, undefined);
76
+ mockTaskService.moveTask.mockResolvedValue(buildTask());
77
+ const result = await controllerNoGateway.moveTask({
78
+ taskId: 'task-uuid-1',
79
+ targetListId: 'list-1'
80
+ }, (0, _loggedusermock.buildMockUser)());
81
+ expect(result.success).toBe(true);
82
+ });
83
+ it('propagates a NotFoundException from the service when the task does not exist', async ()=>{
84
+ mockTaskService.moveTask.mockRejectedValue(new Error('Task not found'));
85
+ await expect(controller.moveTask({
86
+ taskId: 'missing',
87
+ targetListId: 'list-1'
88
+ }, (0, _loggedusermock.buildMockUser)())).rejects.toThrow('Task not found');
89
+ expect(mockGateway.emitToBoardRoom).not.toHaveBeenCalled();
90
+ });
91
+ });
92
+ describe('assignTask', ()=>{
93
+ it('assigns the task and broadcasts a task:updated event to the board room', async ()=>{
94
+ const task = buildTask({
95
+ assignees: [
96
+ {
97
+ userId: 'user-2',
98
+ userName: 'Bob'
99
+ }
100
+ ]
101
+ });
102
+ mockTaskService.assignTask.mockResolvedValue(task);
103
+ const user = (0, _loggedusermock.buildMockUser)();
104
+ const result = await controller.assignTask({
105
+ taskId: 'task-uuid-1',
106
+ assigneeIds: [
107
+ 'user-2'
108
+ ]
109
+ }, user);
110
+ expect(mockTaskService.assignTask).toHaveBeenCalledWith({
111
+ taskId: 'task-uuid-1',
112
+ assigneeIds: [
113
+ 'user-2'
114
+ ]
115
+ }, user);
116
+ expect(result.success).toBe(true);
117
+ expect(mockGateway.emitToBoardRoom).toHaveBeenCalledWith('board-uuid-1', expect.objectContaining({
118
+ type: 'task:updated'
119
+ }));
120
+ });
121
+ it('propagates a BadRequestException when an assignee is not a board member', async ()=>{
122
+ mockTaskService.assignTask.mockRejectedValue(new Error('Assignee is not a board member'));
123
+ await expect(controller.assignTask({
124
+ taskId: 'task-uuid-1',
125
+ assigneeIds: [
126
+ 'stranger'
127
+ ]
128
+ }, (0, _loggedusermock.buildMockUser)())).rejects.toThrow('Assignee is not a board member');
129
+ });
130
+ });
131
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _taskmanagerswaggerconfig = require("./task-manager-swagger.config");
6
+ describe('taskManagerSwaggerConfig', ()=>{
7
+ it('should build a static swagger config with the expected identity fields', ()=>{
8
+ const config = (0, _taskmanagerswaggerconfig.taskManagerSwaggerConfig)();
9
+ expect(config.title).toBe('Task Manager API');
10
+ expect(config.path).toBe('api/docs/task-manager');
11
+ expect(config.version).toBe('1.0');
12
+ expect(config.bearerAuth).toBe(true);
13
+ });
14
+ it('should describe every top-level resource endpoint group', ()=>{
15
+ const config = (0, _taskmanagerswaggerconfig.taskManagerSwaggerConfig)();
16
+ expect(config.description).toContain('/task-manager/board/*');
17
+ expect(config.description).toContain('/task-manager/list/*');
18
+ expect(config.description).toContain('/task-manager/task/*');
19
+ expect(config.description).toContain('/task-manager/label/*');
20
+ expect(config.description).toContain('/task-manager/comment/*');
21
+ });
22
+ it('should return a fresh object on every call rather than a shared mutable singleton', ()=>{
23
+ const first = (0, _taskmanagerswaggerconfig.taskManagerSwaggerConfig)();
24
+ const second = (0, _taskmanagerswaggerconfig.taskManagerSwaggerConfig)();
25
+ expect(first).not.toBe(second);
26
+ expect(first).toEqual(second);
27
+ });
28
+ });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _index = require("./index");
6
+ const _taskboardentity = require("./task-board.entity");
7
+ const _taskboardwithcompanyentity = require("./task-board-with-company.entity");
8
+ const _tasklistentity = require("./task-list.entity");
9
+ const _taskentity = require("./task.entity");
10
+ describe('getTaskManagerEntitiesByConfig', ()=>{
11
+ it('returns the core entities when the company feature is disabled', ()=>{
12
+ expect((0, _index.getTaskManagerEntitiesByConfig)(false)).toBe(_index.TaskManagerCoreEntities);
13
+ expect((0, _index.getTaskManagerEntitiesByConfig)(false)).toContain(_taskboardentity.TaskBoard);
14
+ expect((0, _index.getTaskManagerEntitiesByConfig)(false)).not.toContain(_taskboardwithcompanyentity.TaskBoardWithCompany);
15
+ });
16
+ it('returns the company-scoped entities when the company feature is enabled', ()=>{
17
+ expect((0, _index.getTaskManagerEntitiesByConfig)(true)).toBe(_index.TaskManagerCompanyEntities);
18
+ expect((0, _index.getTaskManagerEntitiesByConfig)(true)).toContain(_taskboardwithcompanyentity.TaskBoardWithCompany);
19
+ expect((0, _index.getTaskManagerEntitiesByConfig)(true)).not.toContain(_taskboardentity.TaskBoard);
20
+ });
21
+ it('shares non-board entities (TaskList, Task, ...) between core and company sets', ()=>{
22
+ expect((0, _index.getTaskManagerEntitiesByConfig)(false)).toContain(_tasklistentity.TaskList);
23
+ expect((0, _index.getTaskManagerEntitiesByConfig)(true)).toContain(_tasklistentity.TaskList);
24
+ expect((0, _index.getTaskManagerEntitiesByConfig)(false)).toContain(_taskentity.Task);
25
+ expect((0, _index.getTaskManagerEntitiesByConfig)(true)).toContain(_taskentity.Task);
26
+ });
27
+ it('both entity sets have the same length (only the board entity swaps)', ()=>{
28
+ expect(_index.TaskManagerCoreEntities).toHaveLength(_index.TaskManagerCompanyEntities.length);
29
+ });
30
+ });