Skip to content

Commit

Permalink
Merge pull request #239 from boostcampwm-2024/revert-236-test/stockIndex
Browse files Browse the repository at this point in the history
Revert "[BE] 주가 지수 서비스 테스트 코드 작성"
  • Loading branch information
sieunie authored Dec 2, 2024
2 parents 4d93680 + fd3bdde commit f8b41ef
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 127 deletions.
3 changes: 2 additions & 1 deletion BE/src/news/news.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource, In } from 'typeorm';
import { NaverApiDomianService } from './naver-api-domian.service';
Expand Down Expand Up @@ -47,7 +48,7 @@ export class NewsService {
};
}

// @Cron('*/30 8-16 * * 1-5')
@Cron('*/1 * * * *')
async cronNewsData() {
const queryRunner = this.dataSource.createQueryRunner();

Expand Down
12 changes: 1 addition & 11 deletions BE/src/stock/index/stock-index.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { StockIndexListChartElementDto } from './dto/stock-index-list-chart.element.dto';
import { StockIndexValueElementDto } from './dto/stock-index-value-element.dto';
import {
Expand Down Expand Up @@ -87,11 +87,6 @@ export class StockIndexService {
queryParams,
);

if (result.rt_cd !== '0')
throw new InternalServerErrorException(
'데이터를 정상적으로 조회하지 못했습니다.',
);

return result.output.map((element) => {
return new StockIndexListChartElementDto(
element.bsop_hour,
Expand All @@ -114,11 +109,6 @@ export class StockIndexService {
queryParams,
);

if (result.rt_cd !== '0')
throw new InternalServerErrorException(
'데이터를 정상적으로 조회하지 못했습니다.',
);

const data = result.output;

return new StockIndexValueElementDto(
Expand Down
86 changes: 0 additions & 86 deletions BE/src/stock/index/stock.index.service.spec.ts

This file was deleted.

49 changes: 49 additions & 0 deletions BE/test/stock/index/stock.index.list.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Test } from '@nestjs/testing';
import axios from 'axios';
import { StockIndexService } from '../../../src/stock/index/stock-index.service';
import { STOCK_INDEX_LIST_MOCK } from './mockdata/stock.index.list.mockdata';

jest.mock('axios');

describe('stock index list test', () => {
let stockIndexService: StockIndexService;

beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [StockIndexService],
}).compile();

stockIndexService = module.get(StockIndexService);
});

it('주가 지수 차트 조회 API에서 정상적인 데이터를 조회한 경우, 형식에 맞춰 정상적으로 반환한다.', async () => {
(axios.get as jest.Mock).mockResolvedValue(
STOCK_INDEX_LIST_MOCK.VALID_DATA,
);

expect(
await stockIndexService.getDomesticStockIndexListByCode(
'code',
'accessToken',
),
).toEqual({
code: 'code',
chart: [
{
time: STOCK_INDEX_LIST_MOCK.VALID_DATA.data.output[0].bsop_hour,
value: STOCK_INDEX_LIST_MOCK.VALID_DATA.data.output[0].bstp_nmix_prpr,
},
],
});
});

it('주가 지수 차트 조회 API에서 데이터를 조회하지 못한 경우, 에러를 발생시킨다.', async () => {
(axios.get as jest.Mock).mockResolvedValue(
STOCK_INDEX_LIST_MOCK.INVALID_DATA,
);

await expect(
stockIndexService.getDomesticStockIndexListByCode('code', 'accessToken'),
).rejects.toThrow('데이터를 정상적으로 조회하지 못했습니다.');
});
});
48 changes: 48 additions & 0 deletions BE/test/stock/index/stock.index.value.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Test } from '@nestjs/testing';
import axios from 'axios';
import { StockIndexService } from '../../../src/stock/index/stock-index.service';
import { STOCK_INDEX_VALUE_MOCK } from './mockdata/stock.index.value.mockdata';

jest.mock('axios');

describe('stock index list test', () => {
let stockIndexService: StockIndexService;

beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [StockIndexService],
}).compile();

stockIndexService = module.get(StockIndexService);
});

it('주가 지수 값 조회 API에서 정상적인 데이터를 조회한 경우, 형식에 맞춰 정상적으로 반환한다.', async () => {
(axios.get as jest.Mock).mockResolvedValue(
STOCK_INDEX_VALUE_MOCK.VALID_DATA,
);

expect(
await stockIndexService.getDomesticStockIndexValueByCode(
'code',
'accessToken',
),
).toEqual({
code: 'code',
value: STOCK_INDEX_VALUE_MOCK.VALID_DATA.data.output.bstp_nmix_prpr,
diff: STOCK_INDEX_VALUE_MOCK.VALID_DATA.data.output.bstp_nmix_prdy_vrss,
diffRate:
STOCK_INDEX_VALUE_MOCK.VALID_DATA.data.output.bstp_nmix_prdy_ctrt,
sign: STOCK_INDEX_VALUE_MOCK.VALID_DATA.data.output.prdy_vrss_sign,
});
});

it('주가 지수 값 조회 API에서 데이터를 조회하지 못한 경우, 에러를 발생시킨다.', async () => {
(axios.get as jest.Mock).mockResolvedValue(
STOCK_INDEX_VALUE_MOCK.INVALID_DATA,
);

await expect(
stockIndexService.getDomesticStockIndexValueByCode('code', 'accessToken'),
).rejects.toThrow('데이터를 정상적으로 조회하지 못했습니다.');
});
});
Binary file modified FE/src/assets/favicon.ico
Binary file not shown.
36 changes: 7 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>

<div align="center">
<h4>실시간 주식 데이터를 활용한 모의투자 경험을 통해 주식 투자에 대해 배울 수 있는 서비스</h4>
<h4>실시간 주식 데이터를 활용해 모의 투자를 경험하고, 친구들과 함께 성장할 수 있는 게임 서비스</h4>
</div>

---
Expand All @@ -15,10 +15,13 @@
- 처음이라 시작하기가 두려워요.
- 자금이 부족해 다양한 시도를 못 해봤어요.
- 주식의 전반적인 시스템을 공부하고 싶어요.
- 친구와 함께 투자를 시작하고 싶어요.

### 🎯 Juga를 통해 이런 걸 경험하세요!
- 실제 주식 투자 전에 게임으로 먼저 경험해보세요.
- 리스크 없이 투자 감각을 키워보세요.
- 친구들과 함께 성장하는 재미를 느껴보세요.
- 경쟁하고 정보도 나누며 더 즐겁게 배워보세요.

### [🚀 시작하기](https://juga.kro.kr/)

Expand All @@ -32,42 +35,17 @@

### 주의사항

- 카카오 로그인 기능은 현재 심사 중으로 사용이 불가능합니다.
- 실제 금전적 거래는 이루어지지 않는 모의투자 서비스입니다.

## ⭐️ 프로젝트 기능 소개



### 메인 페이지
![juga_main](https://github.com/user-attachments/assets/abb04197-ae88-4877-be53-2ca71ad3e57b)

- 메인 페이지에서 코스피, 코스닥 등 실시간 주가 지수를 확인할 수 있습니다.
- 상승률/하락률 TOP5 종목을 주가지수 별로 확인할 수 있습니다.
- 오늘 실시간 주요 뉴스를 확인할 수 있습니다.

### 주식 상세 페이지
![juga_detail](https://github.com/user-attachments/assets/14ed36ae-085e-4899-a314-8ece85236a55)

- 해당 주식에 대한 정보를 차트로 확인할 수 있습니다.
- 일별, 실시간 시세를 확인할 수 있습니다.
- 매수, 매도 요청을 할 수 있습니다.

### 주식 차트
![화면 기록 2024-11-28 오후 6 40 30](https://github.com/user-attachments/assets/6d36b0d9-2db2-4018-a7f3-2c12fb586fd0)

- 일, , 월, 년 단위로 주식 차트를 확인할 수 있습니다.
- 일, , 월, 년 단위로 주식 차트를 확인할 수 있습니다.
- 이동평균선 정보를 활용해 해당 주식의 추이를 더 자세히 확인할 수 있습니다.
- 라이브러리를 사용하지 않고 canvas를 활용해 직접 구현했습니다.

### 마이페이지
![juga_mypage](https://github.com/user-attachments/assets/8cdfa089-ac26-40a0-8d19-7a56a0f3c6e7)

- 현재 자산 현황, 투자 성과를 확인할 수 있습니다.
- 자신이 매수한 주식 정보들을 확인할 수 있습니다.
- 주문 요청 현황 탭에서 주문 요청한 주식들을 확인하고 요청을 취소할 수 있습니다.
- 즐겨찾기 탭에서 주식 상세 페이지에서 좋아요한 주식들을 확인할 수 있습니다.
- 내 정보 탭에서 자신의 닉네임을 변경할 수 있습니다.

- 라이브러리를 사용하지 않고 canvas를 활용해 직접 구현했습니다.

### 로그인
![image (14)](https://github.com/user-attachments/assets/9968ef08-cbf8-41fd-bfdc-8ca25dd8d80c)
Expand Down

0 comments on commit f8b41ef

Please sign in to comment.