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.
session-ios/SignalServiceKit/tests/Messages/Interactions/TSMessageTest.m

64 lines
2.2 KiB
Objective-C

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSMessage.h"
#import "SSKBaseTestObjC.h"
#import "TSAttachmentStream.h"
#import "TSContactThread.h"
#import <SignalCoreKit/NSDate+OWS.h>
NS_ASSUME_NONNULL_BEGIN
@interface TSMessageTest : SSKBaseTestObjC
@property TSThread *thread;
@end
@implementation TSMessageTest
- (void)setUp {
[super setUp];
self.thread = [TSContactThread getOrCreateThreadWithContactId:@"fake-thread-id"];
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExpiresAtWithoutStartedTimer
{
TSMessage *message = [[TSMessage alloc] initMessageWithTimestamp:1
inThread:self.thread
messageBody:@"foo"
attachmentIds:@[]
expiresInSeconds:100
expireStartedAt:0
quotedMessage:nil
contactShare:nil];
XCTAssertEqual(0, message.expiresAt);
}
- (void)testExpiresAtWithStartedTimer
{
uint64_t now = [NSDate ows_millisecondTimeStamp];
const uint32_t expirationSeconds = 10;
const uint32_t expirationMs = expirationSeconds * 1000;
TSMessage *message = [[TSMessage alloc] initMessageWithTimestamp:1
inThread:self.thread
messageBody:@"foo"
attachmentIds:@[]
expiresInSeconds:expirationSeconds
expireStartedAt:now
quotedMessage:nil
contactShare:nil];
XCTAssertEqual(now + expirationMs, message.expiresAt);
}
@end
NS_ASSUME_NONNULL_END