Skip to content

Commit

Permalink
test: DiscountType 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiseull committed Jul 2, 2023
1 parent 8f9fd3a commit 3200547
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.programmers.vouchermanagement.voucher.domain;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class DiscountTypeTest {

@Nested
@DisplayName("할인 유형에 적합한 DiscountType 을 반환한다.")
class returnAppropriateDiscountType {

@Test
@DisplayName("fix 가 들어온 경우")
void WhenFixComeInto() {
// when
String name = "fix";

// given
DiscountType result = DiscountType.from(name);

// then
assertThat(result).isEqualTo(DiscountType.FIX);
}

@Test
@DisplayName("percent 가 들어온 경우")
void WhenPercentComeInto() {
// when
String name = "percent";

// given
DiscountType result = DiscountType.from(name);

// then
assertThat(result).isEqualTo(DiscountType.PERCENT);
}
}

@Test
@DisplayName("존재하지 않는 할인 유형이 들어오면 에외가 발생한다.")
void occurExceptionWhenDiscountTypeDoesNotExist() {
// when
String name = "fixx";

// given & then
assertThatThrownBy(() -> {
DiscountType.from(name);
})
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("This discount type does not exist.");
}
}

0 comments on commit 3200547

Please sign in to comment.