|
15 | 15 |
|
16 | 16 | suite('Test Encryption Helpers', function() {
|
17 | 17 | test('no args run', function() {
|
18 |
| - return new Promise(resolve => { |
| 18 | + return new Promise(function(resolve) { |
19 | 19 | const webpushCLISpawn = spawn('node', [
|
20 | 20 | cliPath
|
21 | 21 | ]);
|
22 | 22 | let errorData = '';
|
23 | 23 | let consoleOutput = '';
|
24 |
| - webpushCLISpawn.stdout.on('data', data => { |
| 24 | + webpushCLISpawn.stdout.on('data', function(data) { |
25 | 25 | consoleOutput += data;
|
26 | 26 | });
|
27 | 27 |
|
28 |
| - webpushCLISpawn.stderr.on('data', data => { |
| 28 | + webpushCLISpawn.stderr.on('data', function(data) { |
29 | 29 | errorData += data;
|
30 | 30 | });
|
31 | 31 |
|
32 |
| - webpushCLISpawn.on('close', code => { |
| 32 | + webpushCLISpawn.on('close', function(code) { |
33 | 33 | // No args should have code 1
|
34 | 34 | assert(code, 1);
|
35 | 35 |
|
|
42 | 42 | });
|
43 | 43 |
|
44 | 44 | test('test send-notification no args', function() {
|
45 |
| - return new Promise(resolve => { |
| 45 | + return new Promise(function(resolve) { |
46 | 46 | const webpushCLISpawn = spawn('node', [
|
47 | 47 | cliPath,
|
48 | 48 | 'send-notification'
|
49 | 49 | ]);
|
50 | 50 |
|
51 |
| - webpushCLISpawn.on('close', code => { |
| 51 | + webpushCLISpawn.on('close', function(code) { |
52 | 52 | // No args should have code 1
|
53 | 53 | assert.equal(code, 1);
|
54 | 54 | resolve();
|
|
57 | 57 | });
|
58 | 58 |
|
59 | 59 | test('test send-notification only endpoint', function() {
|
60 |
| - return new Promise(resolve => { |
| 60 | + return new Promise(function(resolve) { |
61 | 61 | const webpushCLISpawn = spawn('node', [
|
62 | 62 | cliPath,
|
63 | 63 | 'send-notification',
|
|
66 | 66 |
|
67 | 67 | let errorData = '';
|
68 | 68 | let consoleOutput = '';
|
69 |
| - webpushCLISpawn.stdout.on('data', data => { |
| 69 | + webpushCLISpawn.stdout.on('data', function(data) { |
70 | 70 | consoleOutput += data;
|
71 | 71 | });
|
72 | 72 |
|
73 |
| - webpushCLISpawn.stderr.on('data', data => { |
| 73 | + webpushCLISpawn.stderr.on('data', function(data) { |
74 | 74 | errorData += data;
|
75 | 75 | });
|
76 | 76 |
|
77 |
| - webpushCLISpawn.on('close', code => { |
| 77 | + webpushCLISpawn.on('close', function(code) { |
78 | 78 | assert.equal(code, 0);
|
79 | 79 | assert.equal(errorData, '');
|
80 | 80 | assert.equal(consoleOutput.indexOf('Error sending push message: '), 0);
|
|
84 | 84 | });
|
85 | 85 |
|
86 | 86 | test('test send-notification all options', function() {
|
87 |
| - return new Promise(resolve => { |
| 87 | + return new Promise(function(resolve) { |
88 | 88 | const webpushCLISpawn = spawn('node', [
|
89 | 89 | cliPath,
|
90 | 90 | 'send-notification',
|
|
101 | 101 |
|
102 | 102 | let errorData = '';
|
103 | 103 | let consoleOutput = '';
|
104 |
| - webpushCLISpawn.stdout.on('data', data => { |
| 104 | + webpushCLISpawn.stdout.on('data', function(data) { |
105 | 105 | consoleOutput += data;
|
106 | 106 | });
|
107 | 107 |
|
108 |
| - webpushCLISpawn.stderr.on('data', data => { |
| 108 | + webpushCLISpawn.stderr.on('data', function(data) { |
109 | 109 | errorData += data;
|
110 | 110 | });
|
111 | 111 |
|
112 |
| - webpushCLISpawn.on('close', code => { |
| 112 | + webpushCLISpawn.on('close', function(code) { |
113 | 113 | assert.equal(code, 0);
|
114 | 114 | assert.equal(errorData, '');
|
115 | 115 | assert.equal(consoleOutput.indexOf('Error sending push message: '), 0);
|
|
119 | 119 | });
|
120 | 120 |
|
121 | 121 | test('test generate vapid keys', function() {
|
122 |
| - return new Promise(resolve => { |
| 122 | + return new Promise(function(resolve) { |
123 | 123 | const webpushCLISpawn = spawn('node', [
|
124 | 124 | cliPath,
|
125 | 125 | 'generate-vapid-keys'
|
126 | 126 | ]);
|
127 | 127 |
|
128 | 128 | let errorData = '';
|
129 | 129 | let consoleOutput = '';
|
130 |
| - webpushCLISpawn.stdout.on('data', data => { |
| 130 | + webpushCLISpawn.stdout.on('data', function(data) { |
131 | 131 | consoleOutput += data;
|
132 | 132 | });
|
133 | 133 |
|
134 |
| - webpushCLISpawn.stderr.on('data', data => { |
| 134 | + webpushCLISpawn.stderr.on('data', function(data) { |
135 | 135 | errorData += data;
|
136 | 136 | });
|
137 | 137 |
|
138 |
| - webpushCLISpawn.on('close', code => { |
| 138 | + webpushCLISpawn.on('close', function(code) { |
139 | 139 | assert.equal(code, 0);
|
140 | 140 | assert.equal(errorData, '');
|
141 | 141 | assert.notEqual(consoleOutput.indexOf('Public Key:'), -1);
|
142 | 142 | assert.notEqual(consoleOutput.indexOf('Private Key:'), -1);
|
143 | 143 |
|
144 | 144 | const lines = consoleOutput.split('\n');
|
145 |
| - const publicKeyTitleIndex = lines.findIndex(line => { |
| 145 | + const publicKeyTitleIndex = lines.findIndex(function(line) { |
146 | 146 | return line.indexOf('Public Key:') !== -1;
|
147 | 147 | });
|
148 | 148 | const publicKey = lines[publicKeyTitleIndex + 1].trim();
|
149 | 149 | assert.equal(urlBase64.decode(publicKey).length, 65);
|
150 | 150 |
|
151 |
| - const privateKeyTitleIndex = lines.findIndex(line => { |
| 151 | + const privateKeyTitleIndex = lines.findIndex(function(line) { |
152 | 152 | return line.indexOf('Private Key:') !== -1;
|
153 | 153 | });
|
154 | 154 | const privateKey = lines[privateKeyTitleIndex + 1].trim();
|
|
159 | 159 | });
|
160 | 160 |
|
161 | 161 | test('test generate JSON vapid keys', function() {
|
162 |
| - return new Promise(resolve => { |
| 162 | + return new Promise(function(resolve) { |
163 | 163 | const webpushCLISpawn = spawn('node', [
|
164 | 164 | cliPath,
|
165 | 165 | 'generate-vapid-keys',
|
|
168 | 168 |
|
169 | 169 | let errorData = '';
|
170 | 170 | let consoleOutput = '';
|
171 |
| - webpushCLISpawn.stdout.on('data', data => { |
| 171 | + webpushCLISpawn.stdout.on('data', function(data) { |
172 | 172 | consoleOutput += data;
|
173 | 173 | });
|
174 | 174 |
|
175 |
| - webpushCLISpawn.stderr.on('data', data => { |
| 175 | + webpushCLISpawn.stderr.on('data', function(data) { |
176 | 176 | errorData += data;
|
177 | 177 | });
|
178 | 178 |
|
179 |
| - webpushCLISpawn.on('close', code => { |
| 179 | + webpushCLISpawn.on('close', function(code) { |
180 | 180 | assert.equal(code, 0);
|
181 | 181 | assert.equal(errorData, '');
|
182 | 182 |
|
|
0 commit comments