@@ -58,6 +58,34 @@ describe('constructActionButtons', () => {
58
58
} ) ;
59
59
60
60
describe ( 'constructTopicActionButtons' , ( ) => {
61
+ test ( 'show mark as read if topic is unread' , ( ) => {
62
+ const stream = eg . makeStream ( { name : 'test stream' , streamId : 123 } ) ;
63
+ const subscriptions = [ { ...eg . subscription , ...stream } ] ;
64
+ const unreadStreams = eg . makeUnreadStreamsState ( [
65
+ { streamId : 123 , topics : [ { topicName : 'test topic' , messageIds : [ 1 , 2 ] } ] } ,
66
+ ] ) ;
67
+ const buttons = constructTopicActionButtons ( {
68
+ backgroundData : { ...baseBackgroundData , subscriptions, unreadStreams } ,
69
+ stream : 'test stream' ,
70
+ topic : 'test topic' ,
71
+ } ) ;
72
+ expect ( buttonTitles ( buttons ) ) . toContain ( 'Mark topic as read' ) ;
73
+ } ) ;
74
+
75
+ test ( 'do not show mark as read if topic is read' , ( ) => {
76
+ const stream = eg . makeStream ( { name : 'test stream' , streamId : 123 } ) ;
77
+ const subscriptions = [ { ...eg . subscription , ...stream } ] ;
78
+ const unreadStreams = eg . makeUnreadStreamsState ( [
79
+ { streamId : 123 , topics : [ { topicName : 'unread topic' , messageIds : [ 1 , 2 ] } ] } ,
80
+ ] ) ;
81
+ const buttons = constructTopicActionButtons ( {
82
+ backgroundData : { ...baseBackgroundData , subscriptions, unreadStreams } ,
83
+ stream : 'test stream' ,
84
+ topic : 'read topic' ,
85
+ } ) ;
86
+ expect ( buttonTitles ( buttons ) ) . not . toContain ( 'Mark topic as read' ) ;
87
+ } ) ;
88
+
61
89
test ( 'show Unmute topic option if topic is muted' , ( ) => {
62
90
const mute = deepFreeze ( [ [ 'electron issues' , 'issue #556' ] ] ) ;
63
91
const buttons = constructTopicActionButtons ( {
0 commit comments