UNPKG

6.74 kBJavaScriptView Raw
1// Copyright Jeff Wilcox
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16var assert = require('assert'),
17 mpns = require('../lib/mpns');
18
19suite('mpns', function () {
20
21 test('HttpProperties', function () {
22 assert.notEqual(mpns.Properties.http, null);
23 assert.deepEqual(mpns.Properties.http, ['proxy']);
24 });
25
26 test('SslProperties', function () {
27 assert.notEqual(mpns.Properties.ssl, null);
28 assert.deepEqual(mpns.Properties.ssl,
29 [
30 'pfx',
31 'key',
32 'passphrase',
33 'cert',
34 'ca',
35 'ciphers',
36 'rejectUnauthorized'
37 ]);
38 });
39
40 test('ToastProperties', function () {
41 assert.notEqual(mpns.Properties.toast, null);
42 assert.deepEqual(mpns.Properties.toast,
43 [
44 'text1',
45 'text2',
46 'param'
47 ]);
48 });
49
50 test('TileProperties', function () {
51 assert.notEqual(mpns.Properties.tile, null);
52 assert.deepEqual(mpns.Properties.tile,
53 [
54 'backgroundImage',
55 'count',
56 'title',
57 'backBackgroundImage',
58 'backTitle',
59 'backContent',
60 'id'
61 ]);
62 });
63
64 test('FlipTileProperties', function () {
65 assert.notEqual(mpns.Properties.flipTile, null);
66 assert.deepEqual(mpns.Properties.flipTile.sort(),
67 [
68 'backgroundImage',
69 'count',
70 'title',
71 'backBackgroundImage',
72 'backTitle',
73 'backContent',
74 'id',
75 'smallBackgroundImage',
76 'wideBackgroundImage',
77 'wideBackContent',
78 'wideBackBackgroundImage'
79 ].sort());
80 });
81
82 test('IconicTileProperties', function () {
83 assert.notEqual(mpns.Properties.iconicTile, null);
84 assert.deepEqual(mpns.Properties.iconicTile.sort(),
85 [
86 'count',
87 'title',
88 'id',
89 'backgroundColor',
90 'iconImage',
91 'smallIconImage',
92 'wideContent1',
93 'wideContent2',
94 'wideContent3'
95 ].sort());
96 });
97
98 test('OfInterestProperties', function () {
99 assert.notEqual(mpns.Properties.ofInterest, null);
100 assert.deepEqual(mpns.Properties.ofInterest.sort(),
101 [
102 'payload',
103 'pushType',
104 'tileTemplate',
105
106 'backgroundImage',
107 'count',
108 'title',
109 'backBackgroundImage',
110 'backTitle',
111 'backContent',
112 'id',
113 'smallBackgroundImage',
114 'wideBackgroundImage',
115 'wideBackContent',
116 'wideBackBackgroundImage',
117
118 'backgroundColor',
119 'iconImage',
120 'smallIconImage',
121 'wideContent1',
122 'wideContent2',
123 'wideContent3',
124
125 'text1',
126 'text2',
127 'param'
128 ].sort());
129 });
130
131 test('CreateToastWithObject', function () {
132 var toast = mpns.createToast({
133 text1: 'Bold text:',
134 text2: 'normal text',
135 param: 'NewPage.xaml?item=5'
136 });
137
138 assert.deepEqual(toast.pushType, 'toast');
139 assert.deepEqual(toast.notificationClass, '2');
140 assert.deepEqual(toast.targetName, 'toast');
141 assert.deepEqual(toast.param, 'NewPage.xaml?item=5');
142 assert.deepEqual(toast.text1, 'Bold text:');
143 assert.deepEqual(toast.text2, 'normal text');
144 });
145
146 test('CreateToastWithPrimitives', function () {
147 var toast = mpns.createToast('Bold text:', 'normal text', 'NewPage.xaml?item=5');
148
149 assert.deepEqual(toast.pushType, 'toast');
150 assert.deepEqual(toast.notificationClass, '2');
151 assert.deepEqual(toast.targetName, 'toast');
152 assert.deepEqual(toast.param, 'NewPage.xaml?item=5');
153 assert.deepEqual(toast.text1, 'Bold text:');
154 assert.deepEqual(toast.text2, 'normal text');
155 });
156
157 test('CreateTileWithObject', function () {
158 var tile = mpns.createTile({
159 count: 1,
160 title: 'hello',
161 backTitle: 'backtitle',
162 backContent: 'backcontent'
163 });
164
165 assert.deepEqual(tile.count, 1);
166 assert.deepEqual(tile.title, 'hello');
167 assert.deepEqual(tile.backTitle, 'backtitle');
168 assert.deepEqual(tile.backContent, 'backcontent');
169 });
170
171 test('CreateFlipTileWithObjectLegacySmallBackgroundImage', function () {
172 var tile = mpns.createFlipTile({
173 smallbackgroundImage : 'smallBackgroundImage'
174 });
175
176 assert.deepEqual(tile.smallBackgroundImage, 'smallBackgroundImage');
177 });
178
179 test('CreateTileWithPrimitives', function () {
180 var tile = mpns.createTile('', 1, 'hello', '', 'backtitle', 'backcontent');
181
182 assert.deepEqual(tile.count, 1);
183 assert.deepEqual(tile.title, 'hello');
184 assert.deepEqual(tile.backTitle, 'backtitle');
185 assert.deepEqual(tile.backContent, 'backcontent');
186 });
187
188 test('CreateIconicTileWithObject', function () {
189 var obj = {
190 count: 1,
191 title: 'hello',
192 backgroundColor: '#FFAABBCC',
193 iconImage: '/images/icon.png',
194 smallIconImage: '/images/small-icon.png',
195 wideContent1: 'wide content 1',
196 wideContent2: 'wide content 2',
197 wideContent3: 'wide content 3'
198 };
199
200 var tile = mpns.createIconicTile(obj);
201
202 assert.deepEqual(tile.count, obj.count);
203 assert.deepEqual(tile.title, obj.title);
204 assert.deepEqual(tile.backgroundColor, obj.backgroundColor);
205 assert.deepEqual(tile.wideContent1, obj.wideContent1);
206 assert.deepEqual(tile.wideContent2, obj.wideContent2);
207 assert.deepEqual(tile.wideContent3, obj.wideContent3);
208 });
209});