Skip to content

Commit

Permalink
Merge pull request #227 from ncooke3/nc/add-ci
Browse files Browse the repository at this point in the history
[Infra] Add GHA workflow
  • Loading branch information
ykjchen authored Jan 29, 2024
2 parents 5b6daa4 + 1ae8e6d commit 5031732
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
spm:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build
- name: Test
run: swift test

cocoapods:
strategy:
matrix:
podspec: [PromisesObjC.podspec, PromisesSwift.podspec]
platform: [ios, tvos, macos, watchos]
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
- name: Lint
run: |
pod lib lint ${{ matrix.podspec }} --platforms=${{ matrix.platform }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

#import "FBLPromise+Testing.h"
#import "FBLPromisesTestHelpers.h"
#import "PromisesTestHelpers-Swift.h"

@import PromisesTestHelpers;

@interface FBLPromiseCatchInteroperabilityTests : XCTestCase
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

#import "FBLPromise+Testing.h"
#import "FBLPromisesTestHelpers.h"
#import "PromisesTestHelpers-Swift.h"

@import PromisesTestHelpers;

@interface FBLPromiseThenInteroperabilityTests : XCTestCase
@end
Expand Down
17 changes: 17 additions & 0 deletions Tests/PromisesTests/Promise+ThenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ class PromiseThenTests: XCTestCase {
XCTAssertNil(postFinalPromise.error)
}

func testPromiseWhenNilBridgesToNSNullInThenChain() {
// Act.
let promise = Promise<Any?> { fulfill, _ in
fulfill(nil)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssert(value is NSNull)
}

// Assert.
XCTAssert(waitForPromises(timeout: 10))
XCTAssertTrue(promise.isFulfilled)
XCTAssert(promise.value is NSNull)
XCTAssertNil(promise.error)
}

func testPromiseAsyncFulfill() {
// Act.
let promise = Promise { fulfill, _ in
Expand Down
14 changes: 1 addition & 13 deletions Tests/PromisesTests/Promise+WrapTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class PromiseResolveTests: XCTestCase {
Harness.async(completion: handler)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssertNil(value)
}

// Assert.
Expand Down Expand Up @@ -57,8 +55,6 @@ class PromiseResolveTests: XCTestCase {
Harness.async(value: nil, completion: handler)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssertNil(value)
}

// Assert.
Expand Down Expand Up @@ -107,8 +103,6 @@ class PromiseResolveTests: XCTestCase {
Harness.async(value: nil, error: nil, completion: handler)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssertNil(value)
}
// Assert.
XCTAssert(waitForPromises(timeout: 10))
Expand All @@ -118,21 +112,15 @@ class PromiseResolveTests: XCTestCase {
}

func testPromiseWrapErrorOrObjectCompletionFulfillsWithNilValue() {
// Arrange.
let expectation = self.expectation(description: "")

// Act.
let promise = wrap { (handler: @escaping (Error?, Any?) -> Void) in
Harness.async(error: nil, value: nil, completion: handler)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssertNil(value)
expectation.fulfill()
}

// Assert.
waitForExpectations(timeout: 10)
XCTAssert(waitForPromises(timeout: 10))
XCTAssertTrue(promise.isFulfilled)
XCTAssert(promise.value == nil)
XCTAssertNil(promise.error)
Expand Down

0 comments on commit 5031732

Please sign in to comment.