-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0302197
commit 6d3516a
Showing
1 changed file
with
19 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,37 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { RedisService } from '../../src/common/redis/redis.service'; | ||
import { RssAcceptRepository } from '../../src/rss/rss.repository'; | ||
import { RssAcceptFixture } from '../fixture/rssAccept.fixture'; | ||
|
||
describe('Blog platform count statistic E2E Test : GET /api/statistic/platform', () => { | ||
describe('GET /api/statistic/platform E2E Test', () => { | ||
let app: INestApplication; | ||
let rssAcceptRepository: RssAcceptRepository; | ||
beforeAll(async () => { | ||
app = global.testApp; | ||
const redisService = app.get(RedisService); | ||
rssAcceptRepository = app.get(RssAcceptRepository); | ||
await redisService.redisClient.set('auth:test1234', 'test'); | ||
await Promise.all([ | ||
rssAcceptRepository.save(RssAcceptFixture.createRssAcceptFixture({})), | ||
rssAcceptRepository.save(RssAcceptFixture.createRssAcceptFixture({}, 2)), | ||
rssAcceptRepository.save( | ||
RssAcceptFixture.createRssAcceptFixture({ blogPlatform: 'velog' }, 3), | ||
), | ||
]); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await rssAcceptRepository | ||
.createQueryBuilder() | ||
.delete() | ||
.from('rss_accept') | ||
.execute(); | ||
}); | ||
|
||
it('데이터가 올바르게 출력된다.', async () => { | ||
await rssAcceptRepository.save(RssAcceptFixture.createRssAcceptFixture({})); | ||
await rssAcceptRepository.save( | ||
RssAcceptFixture.createRssAcceptFixture({}, 2), | ||
); | ||
await rssAcceptRepository.save( | ||
RssAcceptFixture.createRssAcceptFixture({ blogPlatform: 'velog' }, 3), | ||
); | ||
const response = await request(app.getHttpServer()).get( | ||
'/api/statistic/platform', | ||
); | ||
expect(response.status).toBe(200); | ||
expect(response.body).toStrictEqual({ | ||
message: '블로그 플랫폼 통계 조회 완료', | ||
data: [ | ||
{ | ||
platform: 'etc', | ||
count: 2, | ||
}, | ||
{ | ||
platform: 'velog', | ||
count: 1, | ||
}, | ||
], | ||
}); | ||
}); | ||
it('데이터가 없다.', async () => { | ||
it('요청을 받으면 블로그 플랫폼별 통계 결과를 응답한다.', async () => { | ||
const response = await request(app.getHttpServer()).get( | ||
'/api/statistic/platform', | ||
); | ||
expect(response.status).toBe(200); | ||
expect(response.body).toStrictEqual({ | ||
message: '블로그 플랫폼 통계 조회 완료', | ||
data: [], | ||
}); | ||
expect(response.body.data).toStrictEqual([ | ||
{ | ||
platform: 'etc', | ||
count: 2, | ||
}, | ||
{ | ||
platform: 'velog', | ||
count: 1, | ||
}, | ||
]); | ||
}); | ||
}); |