mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.3 KiB
Objective-C
63 lines
2.3 KiB
Objective-C
// Created by Michael Kirk on 9/25/16.
|
|
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
|
|
|
#import "OWSDisappearingMessagesConfiguration.h"
|
|
#import <XCTest/XCTest.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface OWSDisappearingMessagesConfigurationTest : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation OWSDisappearingMessagesConfigurationTest
|
|
|
|
- (void)testDictionaryValueDidChange
|
|
{
|
|
OWSDisappearingMessagesConfiguration *configuration =
|
|
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:@"fake-thread-id"
|
|
enabled:YES
|
|
durationSeconds:10];
|
|
XCTAssertTrue(configuration.dictionaryValueDidChange);
|
|
|
|
[configuration save];
|
|
XCTAssertFalse(configuration.dictionaryValueDidChange);
|
|
|
|
configuration.enabled = NO;
|
|
XCTAssertTrue(configuration.dictionaryValueDidChange);
|
|
|
|
configuration.enabled = YES;
|
|
XCTAssertFalse(configuration.dictionaryValueDidChange);
|
|
|
|
OWSDisappearingMessagesConfiguration *reloadedConfiguration =
|
|
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:@"fake-thread-id"];
|
|
XCTAssertNotNil(reloadedConfiguration); // Sanity Check.
|
|
XCTAssertFalse(reloadedConfiguration.dictionaryValueDidChange);
|
|
|
|
reloadedConfiguration.durationSeconds = 30;
|
|
XCTAssertTrue(reloadedConfiguration.dictionaryValueDidChange);
|
|
|
|
reloadedConfiguration.durationSeconds = 10;
|
|
XCTAssertFalse(reloadedConfiguration.dictionaryValueDidChange);
|
|
}
|
|
|
|
- (void)testDontStoreEphemeralProperties
|
|
{
|
|
OWSDisappearingMessagesConfiguration *configuration =
|
|
[[OWSDisappearingMessagesConfiguration alloc] initWithThreadId:@"fake-thread-id"
|
|
enabled:YES
|
|
durationSeconds:10];
|
|
|
|
|
|
// Unfortunately this test will break every time you add, remove, or rename a property, but on the
|
|
// plus side it has a chance of catching when you indadvertently remove our ephemeral properties
|
|
// from our Mantle storage blacklist.
|
|
NSArray<NSString *> *expected = @[ @"enabled", @"durationSeconds", @"uniqueId" ];
|
|
|
|
XCTAssertEqualObjects(expected, [configuration.dictionaryValue allKeys]);
|
|
}
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|