This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-candidate' into stable
- Loading branch information
Showing
14 changed files
with
177 additions
and
59 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,10 +1,10 @@ | ||
module: MaterialMotion | ||
module_version: 1.1.0 | ||
module_version: 1.2.0 | ||
sdk: iphonesimulator | ||
xcodebuild_arguments: | ||
- -workspace | ||
- MaterialMotion.xcworkspace | ||
- -scheme | ||
- MaterialMotion | ||
github_url: https://github.com/material-motion/material-motion-swift | ||
github_file_prefix: https://github.com/material-motion/material-motion-swift/tree/v1.1.0 | ||
github_file_prefix: https://github.com/material-motion/material-motion-swift/tree/v1.2.0 |
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,96 @@ | ||
/* | ||
Copyright 2017-present The Material Motion Authors. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import XCTest | ||
import IndefiniteObservable | ||
import MaterialMotion | ||
|
||
class startWithTests: XCTestCase { | ||
|
||
func testOverwrittenByReactivePropertyDefaultValue() { | ||
let property = createProperty(withInitialValue: 0) | ||
|
||
var values: [CGFloat] = [] | ||
let subscription = property.startWith(10).subscribeToValue { value in | ||
values.append(value) | ||
} | ||
|
||
property.value = -10 | ||
|
||
XCTAssertEqual(values, [0, -10]) | ||
|
||
subscription.unsubscribe() | ||
} | ||
|
||
func testInitializedWithInitialValue() { | ||
var valueObserver: MotionObserver<CGFloat>? | ||
let observable = MotionObservable<CGFloat> { observer in | ||
valueObserver = observer | ||
return noopDisconnect | ||
} | ||
|
||
var values: [CGFloat] = [] | ||
let subscription = observable.startWith(10).subscribeToValue { value in | ||
values.append(value) | ||
} | ||
|
||
valueObserver?.next(50) | ||
|
||
XCTAssertEqual(values, [10, 50]) | ||
|
||
subscription.unsubscribe() | ||
} | ||
|
||
func testAdditionalSubscriptionsReceiveLatestValue() { | ||
var valueObserver: MotionObserver<CGFloat>? | ||
let observable = MotionObservable<CGFloat> { observer in | ||
valueObserver = observer | ||
return noopDisconnect | ||
} | ||
|
||
let stream = observable.startWith(10) | ||
|
||
let subscription = stream.subscribeToValue { value in } | ||
|
||
valueObserver?.next(50) | ||
|
||
var secondValues: [CGFloat] = [] | ||
let secondSubscription = stream.subscribeToValue { value in | ||
secondValues.append(value) | ||
} | ||
|
||
XCTAssertEqual(secondValues, [50]) | ||
|
||
subscription.unsubscribe() | ||
secondSubscription.unsubscribe() | ||
} | ||
|
||
@available(*, deprecated) | ||
func testDeprecatedInitialValueIsReceivedFirst() { | ||
let property = createProperty() | ||
|
||
var values: [CGFloat] = [] | ||
let subscription = property.initialValue(10).subscribeToValue { value in | ||
values.append(value) | ||
} | ||
|
||
property.value = -10 | ||
|
||
XCTAssertEqual(values, [10, 0, -10]) | ||
|
||
subscription.unsubscribe() | ||
} | ||
} |