Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
yulingtianxia committed Jul 31, 2018
1 parent 0fe24d2 commit 343a5f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions MTDemo/MTDemoTests/MTDemoTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ - (void)testApplyStubThenDiscardThenApplySuperStub {
[rule2 discard];
}

- (void)testApplySuperStubThenDiscardThenApplyStub {
MTRule *rule1 = [SuperStub mt_limitSelector:@selector(foo:) oncePerDuration:0.01];
[rule1 discard];
MTRule *rule2 = [Stub mt_limitSelector:@selector(foo:) oncePerDuration:0.01];
[self.stub foo:[NSDate date]];
[rule2 discard];
}

- (void)testApplyMetaStubThenDiscardThenApplyMetaSuperStub {
MTRule *rule1 = [mt_metaClass(Stub.class) mt_limitSelector:@selector(foo:) oncePerDuration:0.01];
[rule1 discard];
Expand Down Expand Up @@ -338,9 +346,9 @@ - (void)testKVOThenApplyRule
MTRule *rule = [self.stub mt_limitSelector:@selector(bar) oncePerDuration:0.01 usingMode:MTPerformModeDebounce];
NSCAssert((rule.durationThreshold == 0.01 && rule.mode == MTPerformModeDebounce), @"rule not correct!");
NSObject *bar = self.stub.bar;
[self.stub removeObserver:self forKeyPath:@"bar"];
[rule discard];
// [self.stub removeObserver:self forKeyPath:@"bar"];
[rule discard];
[self.stub removeObserver:self forKeyPath:@"bar"];
bar = self.stub.bar;
}

Expand Down
2 changes: 1 addition & 1 deletion MessageThrottle.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MessageThrottle"
s.version = "1.2.3"
s.version = "1.3.0"
s.summary = "A lightweight Objective-C message throttle and debounce library."
s.description = <<-DESC
MessageThrottle is a lightweight, simple library for controlling frequency of forwarding Objective-C messages. You can choose to control existing methods per instance or per class. It's an implementation of function throttle/debounce developed with Objective-C runtime.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ MessageThrottle is a lightweight, simple library for controlling frequency of fo
- [x] Centralized management of rules.
- [x] Self-managed rules.
- [x] Let method **MUST** invoke at the specified conditions.
- [x] Persistent rules.

## 🔮 Example

Expand Down

0 comments on commit 343a5f9

Please sign in to comment.