From 343a5f9b57d6efed4b71682b9a5e61a85d726abf Mon Sep 17 00:00:00 2001 From: yulingtianxia Date: Tue, 31 Jul 2018 22:19:16 +0800 Subject: [PATCH] add test case update readme --- MTDemo/MTDemoTests/MTDemoTests.m | 12 ++++++++++-- MessageThrottle.podspec | 2 +- README.md | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MTDemo/MTDemoTests/MTDemoTests.m b/MTDemo/MTDemoTests/MTDemoTests.m index 492f33f..d21703d 100644 --- a/MTDemo/MTDemoTests/MTDemoTests.m +++ b/MTDemo/MTDemoTests/MTDemoTests.m @@ -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]; @@ -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; } diff --git a/MessageThrottle.podspec b/MessageThrottle.podspec index 8f6ca89..8731679 100644 --- a/MessageThrottle.podspec +++ b/MessageThrottle.podspec @@ -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. diff --git a/README.md b/README.md index dc56e0f..5348e05 100644 --- a/README.md +++ b/README.md @@ -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