1 | var should = require('should'),
|
2 | path = require('path'),
|
3 | os = require('os'),
|
4 | fs = require('fs');
|
5 |
|
6 | var _ = require('../lib/utils');
|
7 |
|
8 | describe('utils', function(){
|
9 |
|
10 | describe('mapping', function () {
|
11 |
|
12 | it('should map icon for notify-send', function () {
|
13 | var expected = {
|
14 | title: 'Foo',
|
15 | message: 'Bar',
|
16 | icon: 'foobar'
|
17 | };
|
18 |
|
19 | _.mapToNotifySend({
|
20 | title: 'Foo',
|
21 | message: 'Bar',
|
22 | appIcon: 'foobar'
|
23 | }).should.eql(expected);
|
24 |
|
25 | _.mapToNotifySend({
|
26 | title: 'Foo',
|
27 | message: 'Bar',
|
28 | i: 'foobar'
|
29 | }).should.eql(expected);
|
30 | });
|
31 |
|
32 | it('should map short hand for notify-sned', function () {
|
33 | var expected = {
|
34 | urgency: 'a',
|
35 | 'expire-time': 'b',
|
36 | category: 'c',
|
37 | icon: 'd',
|
38 | hint: 'e'
|
39 | };
|
40 |
|
41 | _.mapToNotifySend({
|
42 | u: 'a',
|
43 | e: 'b',
|
44 | c: 'c',
|
45 | i: 'd',
|
46 | h: 'e'
|
47 | }).should.eql(expected);
|
48 | });
|
49 |
|
50 | it('should map icon for notification center', function () {
|
51 | var expected = {
|
52 | title: 'Foo',
|
53 | message: 'Bar',
|
54 | appIcon: 'foobar'
|
55 | };
|
56 |
|
57 | _.mapToMac({
|
58 | title: 'Foo',
|
59 | message: 'Bar',
|
60 | icon: 'foobar'
|
61 | }).should.eql(expected);
|
62 |
|
63 | _.mapToMac({
|
64 | title: 'Foo',
|
65 | message: 'Bar',
|
66 | i: 'foobar'
|
67 | }).should.eql(expected);
|
68 | });
|
69 |
|
70 | it('should map icon for growl', function () {
|
71 | var icon = path.join(__dirname, 'fixture', 'coulson.jpg');
|
72 | var iconRead = fs.readFileSync(icon);
|
73 |
|
74 | var expected = {
|
75 | title: 'Foo',
|
76 | message: 'Bar',
|
77 | icon: fs.readFileSync(icon)
|
78 | };
|
79 |
|
80 | var obj = _.mapToGrowl({
|
81 | title: 'Foo',
|
82 | message: 'Bar',
|
83 | icon: icon
|
84 | });
|
85 |
|
86 | obj.should.have.property('icon');
|
87 | (Buffer.isBuffer(obj.icon)).should.be.true;
|
88 |
|
89 | var obj = _.mapToGrowl({
|
90 | title: 'Foo',
|
91 | message: 'Bar',
|
92 | appIcon: icon
|
93 | });
|
94 |
|
95 | obj.should.have.property('icon');
|
96 | (Buffer.isBuffer(obj.icon)).should.be.true;
|
97 | });
|
98 |
|
99 | });
|
100 |
|
101 | });
|