@@ -2,83 +2,97 @@ var Notify = require('../notifiers/notifysend');
2
2
var utils = require ( '../lib/utils' ) ;
3
3
var os = require ( 'os' ) ;
4
4
5
- describe ( 'notify-send' , function ( ) {
5
+ describe ( 'notify-send' , function ( ) {
6
6
var original = utils . command ;
7
7
var originalType = os . type ;
8
8
9
- beforeEach ( function ( ) {
10
- os . type = function ( ) {
9
+ beforeEach ( function ( ) {
10
+ os . type = function ( ) {
11
11
return 'Linux' ;
12
12
} ;
13
13
} ) ;
14
14
15
- afterEach ( function ( ) {
15
+ afterEach ( function ( ) {
16
16
utils . command = original ;
17
17
os . type = originalType ;
18
18
} ) ;
19
19
20
20
function expectArgsListToBe ( expected , done ) {
21
- utils . command = function ( notifier , argsList , callback ) {
21
+ utils . command = function ( notifier , argsList , callback ) {
22
22
expect ( argsList ) . toEqual ( expected ) ;
23
23
done ( ) ;
24
24
} ;
25
25
}
26
26
27
- it ( 'should pass on title and body' , function ( done ) {
28
- var expected = [ '"title"' , '"body"' ] ;
27
+ it ( 'should pass on title and body' , function ( done ) {
28
+ var expected = [ '"title"' , '"body"' , '--expire-time' , '"10000"' ] ;
29
29
expectArgsListToBe ( expected , done ) ;
30
30
var notifier = new Notify ( { suppressOsdCheck : true } ) ;
31
31
notifier . notify ( { title : 'title' , message : 'body' } ) ;
32
32
} ) ;
33
33
34
- it ( 'should pass have default title' , function ( done ) {
35
- var expected = [ '"Node Notification:"' , '"body"' ] ;
34
+ it ( 'should pass have default title' , function ( done ) {
35
+ var expected = [
36
+ '"Node Notification:"' ,
37
+ '"body"' ,
38
+ '--expire-time' ,
39
+ '"10000"'
40
+ ] ;
36
41
37
42
expectArgsListToBe ( expected , done ) ;
38
43
var notifier = new Notify ( { suppressOsdCheck : true } ) ;
39
44
notifier . notify ( { message : 'body' } ) ;
40
45
} ) ;
41
46
42
- it ( 'should throw error if no message is passed' , function ( done ) {
43
- utils . command = function ( notifier , argsList , callback ) {
47
+ it ( 'should throw error if no message is passed' , function ( done ) {
48
+ utils . command = function ( notifier , argsList , callback ) {
44
49
expect ( argsList ) . toBeUndefined ( ) ;
45
50
} ;
46
51
47
52
var notifier = new Notify ( { suppressOsdCheck : true } ) ;
48
- notifier . notify ( { } , function ( err ) {
53
+ notifier . notify ( { } , function ( err ) {
49
54
expect ( err . message ) . toBe ( 'Message is required.' ) ;
50
55
done ( ) ;
51
56
} ) ;
52
57
} ) ;
53
58
54
- it ( 'should escape message input' , function ( done ) {
59
+ it ( 'should escape message input' , function ( done ) {
55
60
var excapedNewline = process . platform === 'win32' ? '\\r\\n' : '\\n' ;
56
61
var expected = [
57
62
'"Node Notification:"' ,
58
- '"some' + excapedNewline + ' \\"me\'ss\\`age\\`\\""'
63
+ '"some' + excapedNewline + ' \\"me\'ss\\`age\\`\\""' ,
64
+ '--expire-time' ,
65
+ '"10000"'
59
66
] ;
60
67
61
68
expectArgsListToBe ( expected , done ) ;
62
69
var notifier = new Notify ( { suppressOsdCheck : true } ) ;
63
70
notifier . notify ( { message : 'some\n "me\'ss`age`"' } ) ;
64
71
} ) ;
65
72
66
- it ( 'should send additional parameters as --"keyname"' , function ( done ) {
67
- var expected = [ '"title"' , '"body"' , '--icon' , '"icon-string"' ] ;
73
+ it ( 'should send additional parameters as --"keyname"' , function ( done ) {
74
+ var expected = [
75
+ '"title"' ,
76
+ '"body"' ,
77
+ '--icon' ,
78
+ '"icon-string"' ,
79
+ '--expire-time' ,
80
+ '"10000"'
81
+ ] ;
68
82
69
83
expectArgsListToBe ( expected , done ) ;
70
84
var notifier = new Notify ( { suppressOsdCheck : true } ) ;
71
85
notifier . notify ( { title : 'title' , message : 'body' , icon : 'icon-string' } ) ;
72
86
} ) ;
73
87
74
- it ( 'should remove extra options that are not supported by notify-send' , function ( done ) {
88
+ it ( 'should remove extra options that are not supported by notify-send' , function ( done ) {
75
89
var expected = [
76
90
'"title"' ,
77
91
'"body"' ,
78
92
'--icon' ,
79
93
'"icon-string"' ,
80
94
'--expire-time' ,
81
- '"100 "'
95
+ '"1000 "'
82
96
] ;
83
97
84
98
expectArgsListToBe ( expected , done ) ;
@@ -87,7 +101,7 @@ describe('notify-send', function() {
87
101
title : 'title' ,
88
102
message : 'body' ,
89
103
icon : 'icon-string' ,
90
- time : 100 ,
104
+ time : 1 ,
91
105
tullball : 'notValid'
92
106
} ) ;
93
107
} ) ;
0 commit comments