Skip to content

Commit 522efd4

Browse files
authored
test(profile): fix user.service.spec
* test(profile): user controller unit tests v3 * test(profile): user service unit tests v3 * test(profile): user repository unit tests v3 * fix(profile): fix package-lock.json * fix(profile): fix user.service.spec
1 parent be35eeb commit 522efd4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/notifications/gateway.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('NotificationsGateway', () => {
4141
jwt_service = module.get(JwtService);
4242
config_service = module.get(ConfigService);
4343

44-
gateway.server = mock_server as Server;
44+
gateway.server = mock_server;
4545
});
4646

4747
afterEach(() => {
@@ -79,7 +79,7 @@ describe('NotificationsGateway', () => {
7979

8080
const console_spy = jest.spyOn(console, 'log').mockImplementation();
8181

82-
gateway.handleConnection(mock_client as Socket);
82+
gateway.handleConnection(mock_client);
8383

8484
expect(mock_client.join).toHaveBeenCalledWith('user-456');
8585
expect(console_spy).toHaveBeenCalledWith(
@@ -100,7 +100,7 @@ describe('NotificationsGateway', () => {
100100
disconnect: jest.fn(),
101101
};
102102

103-
gateway.handleConnection(mock_client as Socket);
103+
gateway.handleConnection(mock_client);
104104

105105
expect(mock_client.disconnect).toHaveBeenCalled();
106106
expect(mock_client.join).not.toHaveBeenCalled();
@@ -114,7 +114,7 @@ describe('NotificationsGateway', () => {
114114
disconnect: jest.fn(),
115115
};
116116

117-
gateway.handleConnection(mock_client as Socket);
117+
gateway.handleConnection(mock_client);
118118

119119
expect(mock_client.disconnect).toHaveBeenCalled();
120120
expect(mock_client.join).not.toHaveBeenCalled();

src/user/user.service.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { TweetType } from 'src/shared/enums/tweet-types.enum';
3535
import { UsernameService } from 'src/auth/username.service';
3636
import { UsernameRecommendationsResponseDto } from './dto/username-recommendations-response.dto';
3737
import { PaginationService } from 'src/shared/services/pagination/pagination.service';
38+
import { FollowJobService } from 'src/background-jobs/notifications/follow/follow.service';
3839

3940
describe('UserService', () => {
4041
let service: UserService;
@@ -45,6 +46,7 @@ describe('UserService', () => {
4546
let azure_storage_service: jest.Mocked<AzureStorageService>;
4647
let config_service: jest.Mocked<ConfigService>;
4748
let category_repository: jest.Mocked<Repository<Category>>;
49+
let follow_job_service: jest.Mocked<FollowJobService>;
4850

4951
beforeEach(async () => {
5052
const mock_user_repository = {
@@ -87,6 +89,10 @@ describe('UserService', () => {
8789
generateNextCursor: jest.fn(),
8890
};
8991

92+
const mock_follow_job_service = {
93+
queueFollowNotification: jest.fn(),
94+
};
95+
9096
const mock_azure_storage_service = {
9197
uploadFile: jest.fn(),
9298
deleteFile: jest.fn(),
@@ -115,6 +121,7 @@ describe('UserService', () => {
115121
{ provide: getRepositoryToken(Category), useValue: mock_category_repository },
116122
{ provide: UsernameService, useValue: mock_username_service },
117123
{ provide: PaginationService, useValue: mock_pagination_service },
124+
{ provide: FollowJobService, useValue: mock_follow_job_service },
118125
],
119126
}).compile();
120127

@@ -126,6 +133,7 @@ describe('UserService', () => {
126133
category_repository = module.get(getRepositoryToken(Category));
127134
username_service = module.get(UsernameService);
128135
pagination_service = module.get(PaginationService);
136+
follow_job_service = module.get(FollowJobService);
129137
});
130138

131139
afterEach(() => jest.clearAllMocks());

0 commit comments

Comments
 (0)