Skip to content

Commit

Permalink
resolve #3
Browse files Browse the repository at this point in the history
  • Loading branch information
riversun committed May 2, 2019
1 parent 32ad141 commit f8d3df4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.riversun</groupId>
<artifactId>java-promise</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>java-promise</name>
<description>Simple Promise library for java</description>
Expand Down
74 changes: 74 additions & 0 deletions src/test/java/org/riversun/promise/TestPromiseAllTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,78 @@ public void test_promiseResolve_check_arg_string() {
assertEquals("str", holder.data);
}

/**
* Test Promise.resolve #3 check resolve(String[])
*/
@Test
public void test_promiseResolve_check_arg_array_of_string() {
sync();
final ObjectHolder holder = new ObjectHolder();
PromiseResolve(new String[] { "str1", "str2" }).then(
(action, data) -> {
holder.data = data;
action.resolve();
consume();
})
.start();
await();

assertEquals(Arrays.asList(new String[] { "str1", "str2" }), Arrays.asList((String[]) holder.data));
}

/**
* Test Promise.reject
*/
@Test
public void test_promiseReject() {
sync();
final ObjectHolder holder = new ObjectHolder();
PromiseReject().then(null,
(action, data) -> {
holder.data = data;
action.reject();
consume();
})
.start();
await();
assertEquals(null, holder.data);
}

/**
* Test Promise.reject #2 check reject(String)
*/
@Test
public void test_promiseReject_check_arg_string() {
sync();
final ObjectHolder holder = new ObjectHolder();
PromiseReject("str").then(null,
(action, data) -> {
holder.data = data;
action.reject();
consume();
})
.start();
await();
assertEquals("str", holder.data);
}

/**
* Test Promise.reject #3 check reject(String[])
*/
@Test
public void test_promiseReject_check_arg_array_of_string() {
sync();
final ObjectHolder holder = new ObjectHolder();
PromiseReject(new String[] { "str1", "str2" }).then(
null,
(action, data) -> {
holder.data = data;
action.reject();
consume();
})
.start();
await();

assertEquals(Arrays.asList(new String[] { "str1", "str2" }), Arrays.asList((String[]) holder.data));
}
}

0 comments on commit f8d3df4

Please sign in to comment.