-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
배송 정보를 가진 Delivery 객체를 구현했습니다
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Member } from '../../members/domain/member.entity' | ||
|
||
export class Delivery { | ||
id: number | ||
|
||
deliveryName: string | ||
|
||
deliveryFee: number | ||
|
||
member: Member | ||
|
||
createTime: Date | ||
|
||
updateTime: Date | ||
|
||
createBy: string | ||
|
||
modifiedBy: string | ||
|
||
constructor({ | ||
id = 0, | ||
deliveryName = '', | ||
deliveryFee = 0, | ||
member = new Member({}), | ||
createTime = new Date(), | ||
updateTime = new Date(), | ||
createBy = '', | ||
modifiedBy = '', | ||
}: { | ||
id?: number | ||
deliveryName?: string | ||
deliveryFee?: number | ||
member?: Member | ||
createTime?: Date | ||
updateTime?: Date | ||
createBy?: string | ||
modifiedBy?: string | ||
}) { | ||
this.id = id | ||
this.deliveryName = deliveryName | ||
this.deliveryFee = deliveryFee | ||
this.member = member | ||
this.createTime = createTime | ||
this.updateTime = updateTime | ||
this.createBy = createBy | ||
this.modifiedBy = modifiedBy | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { userMock } from '../../fixture/memberFixture' | ||
import { Delivery } from './delivery.entity' | ||
import { deliveryMock } from '../../fixture/deliveryFixture' | ||
|
||
describe('Delivery', () => { | ||
let delivery: Delivery | ||
|
||
describe('객체가 주어지면', () => { | ||
beforeEach(() => { | ||
delivery = new Delivery(deliveryMock()) | ||
}) | ||
|
||
it('값을 리턴해야 리턴해야 한다', () => { | ||
expect(delivery.id).toEqual(1) | ||
expect(delivery.deliveryName).toEqual('마포구 물류센터') | ||
expect(delivery.deliveryFee).toEqual(3000) | ||
expect(delivery.member).toEqual(userMock()) | ||
expect(delivery.createTime).toEqual(new Date('2023-08-23T23:10:00.009Z')) | ||
expect(delivery.updateTime).toEqual(new Date('2023-10-01T23:10:00.009Z')) | ||
expect(delivery.createBy).toEqual('생성자') | ||
expect(delivery.modifiedBy).toEqual('수정자') | ||
}) | ||
}) | ||
|
||
describe('객체가 빈 값이 주어지면', () => { | ||
beforeEach(() => { | ||
delivery = new Delivery({}) | ||
}) | ||
|
||
it('default 값을 리턴해야 한다', () => { | ||
expect(delivery.id).toEqual(0) | ||
expect(delivery.deliveryName).toEqual('') | ||
expect(delivery.deliveryFee).toEqual(0) | ||
expect(delivery.createBy).toEqual('') | ||
expect(delivery.modifiedBy).toEqual('') | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { userMock } from './memberFixture' | ||
import { Delivery } from '../delivery/domain/delivery.entity' | ||
|
||
export const deliveryMock = (): Delivery => { | ||
return { | ||
id: 1, | ||
deliveryName: '마포구 물류센터', | ||
deliveryFee: 3000, | ||
member: userMock(), | ||
createTime: new Date('2023-08-23T23:10:00.009Z'), | ||
updateTime: new Date('2023-10-01T23:10:00.009Z'), | ||
createBy: '생성자', | ||
modifiedBy: '수정자', | ||
} | ||
} | ||
|
||
export const deliveriesMock = (): Delivery[] => { | ||
return [ | ||
{ | ||
id: 1, | ||
deliveryName: '마포구 물류센터', | ||
deliveryFee: 3000, | ||
member: userMock(), | ||
createTime: new Date('2023-08-23T23:10:00.009Z'), | ||
updateTime: new Date('2023-10-01T23:10:00.009Z'), | ||
createBy: '생성자', | ||
modifiedBy: '수정자', | ||
}, | ||
{ | ||
id: 2, | ||
deliveryName: '동탄 물류센터 무료배송', | ||
deliveryFee: 0, | ||
member: userMock(), | ||
createTime: new Date('2022-10-02T23:10:00.009Z'), | ||
updateTime: new Date('2023-09-01T23:10:00.009Z'), | ||
createBy: '생성자', | ||
modifiedBy: '수정자', | ||
}, | ||
] | ||
} | ||
|
||
export const dbDeliveriesMock = [ | ||
{ | ||
delivery_id: deliveriesMock()[0].id, | ||
delivery_name: deliveriesMock()[0].deliveryName, | ||
delivery_fee: deliveriesMock()[0].deliveryFee, | ||
member_id: userMock().memberId, | ||
create_time: deliveriesMock()[0].createTime, | ||
update_time: deliveriesMock()[0].updateTime, | ||
create_by: deliveriesMock()[0].createBy, | ||
modified_by: deliveriesMock()[0].modifiedBy, | ||
}, | ||
{ | ||
delivery_id: deliveriesMock()[1].id, | ||
delivery_name: deliveriesMock()[1].deliveryName, | ||
delivery_fee: deliveriesMock()[1].deliveryFee, | ||
member_id: userMock().memberId, | ||
create_time: deliveriesMock()[1].createTime, | ||
update_time: deliveriesMock()[1].updateTime, | ||
create_by: deliveriesMock()[1].createBy, | ||
modified_by: deliveriesMock()[1].modifiedBy, | ||
}, | ||
] |