@realfavicongenerator/check-favicon 0.4.7 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/desktop/desktop.d.ts +4 -4
- package/dist/desktop/desktop.js +40 -14
- package/dist/desktop/desktop.test.js +149 -64
- package/dist/desktop/ico.d.ts +2 -2
- package/dist/desktop/ico.js +30 -6
- package/dist/google.d.ts +8 -0
- package/dist/google.js +107 -0
- package/dist/google.test.js +71 -0
- package/dist/helper.d.ts +8 -1
- package/dist/helper.js +26 -7
- package/dist/helper.test.js +18 -3
- package/dist/touch-icon.js +1 -1
- package/dist/types.d.ts +29 -1
- package/dist/types.js +8 -0
- package/dist/web-app-manifest.js +1 -1
- package/package.json +6 -4
- package/src/desktop/desktop.test.ts +152 -64
- package/src/desktop/desktop.ts +46 -19
- package/src/desktop/ico.ts +35 -10
- package/src/google.test.ts +82 -0
- package/src/google.ts +103 -0
- package/src/helper.test.ts +19 -4
- package/src/helper.ts +35 -7
- package/src/touch-icon.ts +3 -3
- package/src/types.ts +33 -1
- package/src/web-app-manifest.ts +3 -3
- package/dist/web-manifest.d.ts +0 -4
- package/dist/web-manifest.js +0 -262
- package/dist/web-manifest.test.js +0 -172
- /package/dist/{web-manifest.test.d.ts → google.test.d.ts} +0 -0
package/dist/web-manifest.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.checkWebManifestFile = exports.checkWebAppManifest = void 0;
|
|
20
|
-
const types_1 = require("./types");
|
|
21
|
-
const helper_1 = require("./helper");
|
|
22
|
-
const checkWebAppManifest = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0, [baseUrl_1, head_1, ...args_1], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
|
|
23
|
-
const messages = [];
|
|
24
|
-
let name = undefined;
|
|
25
|
-
let shortName = undefined;
|
|
26
|
-
let backgroundColor = undefined;
|
|
27
|
-
let themeColor = undefined;
|
|
28
|
-
let icon = null;
|
|
29
|
-
if (!head) {
|
|
30
|
-
messages.push({
|
|
31
|
-
status: types_1.CheckerStatus.Error,
|
|
32
|
-
id: types_1.MessageId.noHead,
|
|
33
|
-
text: 'No <head> element'
|
|
34
|
-
});
|
|
35
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
36
|
-
}
|
|
37
|
-
const manifestMarkup = head.querySelectorAll("link[rel='manifest']");
|
|
38
|
-
if (manifestMarkup.length === 0) {
|
|
39
|
-
messages.push({
|
|
40
|
-
status: types_1.CheckerStatus.Error,
|
|
41
|
-
id: types_1.MessageId.noManifest,
|
|
42
|
-
text: 'No web app manifest'
|
|
43
|
-
});
|
|
44
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
45
|
-
}
|
|
46
|
-
const href = manifestMarkup[0].getAttribute('href');
|
|
47
|
-
if (!href) {
|
|
48
|
-
messages.push({
|
|
49
|
-
status: types_1.CheckerStatus.Error,
|
|
50
|
-
id: types_1.MessageId.noManifestHref,
|
|
51
|
-
text: 'The web app manifest markup has no `href` attribute'
|
|
52
|
-
});
|
|
53
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
54
|
-
}
|
|
55
|
-
const manifestUrl = (0, helper_1.mergeUrlAndPath)(baseUrl, href);
|
|
56
|
-
const manifest = yield fetcher(manifestUrl, 'application/json');
|
|
57
|
-
if (manifest.status === 404) {
|
|
58
|
-
messages.push({
|
|
59
|
-
status: types_1.CheckerStatus.Error,
|
|
60
|
-
id: types_1.MessageId.manifest404,
|
|
61
|
-
text: `The web app manifest at \`${href}\` is not found`
|
|
62
|
-
});
|
|
63
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
64
|
-
}
|
|
65
|
-
else if (manifest.status >= 300 || !manifest.readableStream) {
|
|
66
|
-
messages.push({
|
|
67
|
-
status: types_1.CheckerStatus.Error,
|
|
68
|
-
id: types_1.MessageId.manifestCannotGet,
|
|
69
|
-
text: `Cannot get the web app manifest at \`${href}\` (${manifest.status} error)`
|
|
70
|
-
});
|
|
71
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
72
|
-
}
|
|
73
|
-
let parsedManifest;
|
|
74
|
-
try {
|
|
75
|
-
parsedManifest = yield readableStreamToJson(manifest.readableStream);
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
messages.push({
|
|
79
|
-
status: types_1.CheckerStatus.Error,
|
|
80
|
-
id: types_1.MessageId.manifestInvalidJson,
|
|
81
|
-
text: `Cannot parse the web app manifest at \`${href}\``
|
|
82
|
-
});
|
|
83
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
84
|
-
}
|
|
85
|
-
const manifestReport = yield (0, exports.checkWebManifestFile)(parsedManifest, manifestUrl, fetcher);
|
|
86
|
-
return Object.assign(Object.assign({}, manifestReport), { messages: messages.concat(manifestReport.messages) });
|
|
87
|
-
});
|
|
88
|
-
exports.checkWebAppManifest = checkWebAppManifest;
|
|
89
|
-
const readableStreamToJson = (stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
const reader = stream.getReader();
|
|
91
|
-
const decoder = new TextDecoder();
|
|
92
|
-
let result = '';
|
|
93
|
-
while (true) {
|
|
94
|
-
const { done, value } = yield reader.read();
|
|
95
|
-
if (done) {
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
result += decoder.decode(value);
|
|
99
|
-
}
|
|
100
|
-
return JSON.parse(result);
|
|
101
|
-
});
|
|
102
|
-
const checkWebManifestFile = (manifest, baseUrl, fetcher) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
var _a, e_1, _b, _c;
|
|
104
|
-
const messages = [];
|
|
105
|
-
let icon = null;
|
|
106
|
-
const name = manifest.name || undefined;
|
|
107
|
-
if (!name) {
|
|
108
|
-
messages.push({
|
|
109
|
-
status: types_1.CheckerStatus.Error,
|
|
110
|
-
id: types_1.MessageId.noManifestName,
|
|
111
|
-
text: 'The web app manifest has no `name`'
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
messages.push({
|
|
116
|
-
status: types_1.CheckerStatus.Ok,
|
|
117
|
-
id: types_1.MessageId.manifestName,
|
|
118
|
-
text: `The web app manifest has the name "${name}"`
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const shortName = manifest.short_name || undefined;
|
|
122
|
-
if (!shortName) {
|
|
123
|
-
messages.push({
|
|
124
|
-
status: types_1.CheckerStatus.Error,
|
|
125
|
-
id: types_1.MessageId.noManifestShortName,
|
|
126
|
-
text: 'The web app manifest has no `short_name`'
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
messages.push({
|
|
131
|
-
status: types_1.CheckerStatus.Ok,
|
|
132
|
-
id: types_1.MessageId.manifestShortName,
|
|
133
|
-
text: `The web app manifest has the short name "${shortName}"`
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
const backgroundColor = manifest.background_color || undefined;
|
|
137
|
-
if (!backgroundColor) {
|
|
138
|
-
messages.push({
|
|
139
|
-
status: types_1.CheckerStatus.Error,
|
|
140
|
-
id: types_1.MessageId.noManifestBackgroundColor,
|
|
141
|
-
text: 'The web app manifest has no `background_color`'
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
messages.push({
|
|
146
|
-
status: types_1.CheckerStatus.Ok,
|
|
147
|
-
id: types_1.MessageId.manifestBackgroundColor,
|
|
148
|
-
text: `The web app manifest has the background color \`${backgroundColor}\``
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
const themeColor = manifest.theme_color || undefined;
|
|
152
|
-
if (!themeColor) {
|
|
153
|
-
messages.push({
|
|
154
|
-
status: types_1.CheckerStatus.Error,
|
|
155
|
-
id: types_1.MessageId.noManifestThemeColor,
|
|
156
|
-
text: 'The web app manifest has no `theme_color`'
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
messages.push({
|
|
161
|
-
status: types_1.CheckerStatus.Ok,
|
|
162
|
-
id: types_1.MessageId.manifestThemeColor,
|
|
163
|
-
text: `The web app manifest has the theme color \`${themeColor}\``
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
const icons = manifest.icons;
|
|
167
|
-
if (!icons || !Array.isArray(icons) || icons.length === 0) {
|
|
168
|
-
messages.push({
|
|
169
|
-
status: types_1.CheckerStatus.Error,
|
|
170
|
-
id: types_1.MessageId.noManifestIcons,
|
|
171
|
-
text: 'The web app manifest has no `icons`'
|
|
172
|
-
});
|
|
173
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
for (var _d = true, _e = __asyncValues([192, 512]), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
177
|
-
_c = _f.value;
|
|
178
|
-
_d = false;
|
|
179
|
-
const size = _c;
|
|
180
|
-
const iconEntry = icons.find((icon) => icon.sizes === `${size}x${size}`);
|
|
181
|
-
if (!iconEntry) {
|
|
182
|
-
messages.push({
|
|
183
|
-
status: types_1.CheckerStatus.Error,
|
|
184
|
-
id: types_1.MessageId.noManifestIcon,
|
|
185
|
-
text: `The web app manifest has no ${size}x${size} icon`
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
messages.push({
|
|
190
|
-
status: types_1.CheckerStatus.Ok,
|
|
191
|
-
id: types_1.MessageId.manifestIconDeclared,
|
|
192
|
-
text: `The web app manifest has a ${size}x${size} icon`
|
|
193
|
-
});
|
|
194
|
-
const iconUrl = (0, helper_1.mergeUrlAndPath)(baseUrl, iconEntry.src);
|
|
195
|
-
const processor = {
|
|
196
|
-
cannotGet: (status) => {
|
|
197
|
-
messages.push({
|
|
198
|
-
status: types_1.CheckerStatus.Error,
|
|
199
|
-
id: types_1.MessageId.manifestIconCannotGet,
|
|
200
|
-
text: `The ${size}x${size} icon cannot be fetched (${status})`
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
downloadable: () => {
|
|
204
|
-
messages.push({
|
|
205
|
-
status: types_1.CheckerStatus.Ok,
|
|
206
|
-
id: types_1.MessageId.manifestIconDownloadable,
|
|
207
|
-
text: `The ${size}x${size} icon is downloadable`
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
icon404: () => {
|
|
211
|
-
messages.push({
|
|
212
|
-
status: types_1.CheckerStatus.Error,
|
|
213
|
-
id: types_1.MessageId.manifestIcon404,
|
|
214
|
-
text: `The ${size}x${size} icon is not found`
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
noHref: () => {
|
|
218
|
-
messages.push({
|
|
219
|
-
status: types_1.CheckerStatus.Error,
|
|
220
|
-
id: types_1.MessageId.manifestIconNoHref,
|
|
221
|
-
text: `The ${size}x${size} icon has no \`href\` attribute`
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
notSquare: () => {
|
|
225
|
-
messages.push({
|
|
226
|
-
status: types_1.CheckerStatus.Error,
|
|
227
|
-
id: types_1.MessageId.manifestIconNotSquare,
|
|
228
|
-
text: `The ${size}x${size} icon is not square`
|
|
229
|
-
});
|
|
230
|
-
},
|
|
231
|
-
rightSize: () => {
|
|
232
|
-
messages.push({
|
|
233
|
-
status: types_1.CheckerStatus.Ok,
|
|
234
|
-
id: types_1.MessageId.manifestIconRightSize,
|
|
235
|
-
text: `The ${size}x${size} icon has the right size`
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
square: () => {
|
|
239
|
-
// Ignore this, just check the size
|
|
240
|
-
},
|
|
241
|
-
wrongSize: (actualSize) => {
|
|
242
|
-
messages.push({
|
|
243
|
-
status: types_1.CheckerStatus.Error,
|
|
244
|
-
id: types_1.MessageId.manifestIconWrongSize,
|
|
245
|
-
text: `The ${size}x${size} icon has the wrong size (${actualSize})`
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
icon = yield (0, helper_1.checkIcon)(iconUrl, processor, fetcher, iconEntry.type || (0, helper_1.pathToMimeType)(iconEntry.src), size);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
254
|
-
finally {
|
|
255
|
-
try {
|
|
256
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
257
|
-
}
|
|
258
|
-
finally { if (e_1) throw e_1.error; }
|
|
259
|
-
}
|
|
260
|
-
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
261
|
-
});
|
|
262
|
-
exports.checkWebManifestFile = checkWebManifestFile;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const node_html_parser_1 = __importDefault(require("node-html-parser"));
|
|
16
|
-
const types_1 = require("./types");
|
|
17
|
-
const web_manifest_1 = require("./web-manifest");
|
|
18
|
-
const test_helper_1 = require("./test-helper");
|
|
19
|
-
const helper_1 = require("./helper");
|
|
20
|
-
const filterOutput = (report) => (Object.assign(Object.assign({}, report), { messages: report.messages.map(m => ({ status: m.status, id: m.id })) }));
|
|
21
|
-
const runCheckTouchIconTitleTest = (headFragment_1, output_1, ...args_1) => __awaiter(void 0, [headFragment_1, output_1, ...args_1], void 0, function* (headFragment, output, fetchDatabase = {}) {
|
|
22
|
-
const root = headFragment ? (0, node_html_parser_1.default)(headFragment) : null;
|
|
23
|
-
const result = yield (0, web_manifest_1.checkWebAppManifest)('https://example.com/', root, (0, test_helper_1.testFetcher)(fetchDatabase));
|
|
24
|
-
expect(filterOutput(result)).toEqual(Object.assign({ name: undefined, shortName: undefined, backgroundColor: undefined, themeColor: undefined, icon: null }, output));
|
|
25
|
-
});
|
|
26
|
-
test('checkWebManifest - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
yield runCheckTouchIconTitleTest(null, { messages: [{
|
|
28
|
-
status: types_1.CheckerStatus.Error,
|
|
29
|
-
id: types_1.MessageId.noHead,
|
|
30
|
-
}] });
|
|
31
|
-
}));
|
|
32
|
-
test('checkWebManifest - noManifest', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
yield runCheckTouchIconTitleTest('<title>Hey</title>', { messages: [{
|
|
34
|
-
status: types_1.CheckerStatus.Error,
|
|
35
|
-
id: types_1.MessageId.noManifest,
|
|
36
|
-
}] });
|
|
37
|
-
}));
|
|
38
|
-
test('checkWebManifest - noManifestHref', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
yield runCheckTouchIconTitleTest('<link rel="manifest" />', { messages: [{
|
|
40
|
-
status: types_1.CheckerStatus.Error,
|
|
41
|
-
id: types_1.MessageId.noManifestHref,
|
|
42
|
-
}] });
|
|
43
|
-
}));
|
|
44
|
-
test('checkWebManifest - manifest404', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
yield runCheckTouchIconTitleTest('<link rel="manifest" href="not-found.json" />', { messages: [{
|
|
46
|
-
status: types_1.CheckerStatus.Error,
|
|
47
|
-
id: types_1.MessageId.manifest404,
|
|
48
|
-
}] });
|
|
49
|
-
}));
|
|
50
|
-
test('checkWebManifest - manifestCannotGet', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
yield runCheckTouchIconTitleTest('<link rel="manifest" href="/error.json" />', { messages: [{
|
|
52
|
-
status: types_1.CheckerStatus.Error,
|
|
53
|
-
id: types_1.MessageId.manifestCannotGet,
|
|
54
|
-
}] }, {
|
|
55
|
-
'https://example.com/error.json': {
|
|
56
|
-
status: 500,
|
|
57
|
-
contentType: 'application/json',
|
|
58
|
-
readableStream: null
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}));
|
|
62
|
-
test('checkWebManifest - manifestInvalidJson', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
yield runCheckTouchIconTitleTest('<link rel="manifest" href="/bad-manifest.json" />', { messages: [{
|
|
64
|
-
status: types_1.CheckerStatus.Error,
|
|
65
|
-
id: types_1.MessageId.manifestInvalidJson,
|
|
66
|
-
}] }, {
|
|
67
|
-
'https://example.com/bad-manifest.json': {
|
|
68
|
-
status: 200,
|
|
69
|
-
contentType: 'application/json',
|
|
70
|
-
readableStream: stringToReadableStream('{ bad JSON }')
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}));
|
|
74
|
-
const stringToReadableStream = (str) => {
|
|
75
|
-
const stream = new ReadableStream({
|
|
76
|
-
start(controller) {
|
|
77
|
-
controller.enqueue(new TextEncoder().encode(str));
|
|
78
|
-
controller.close();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return stream;
|
|
82
|
-
};
|
|
83
|
-
test('checkWebManifestFile - Missing fields', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
-
const report = yield (0, web_manifest_1.checkWebManifestFile)({
|
|
85
|
-
name: null,
|
|
86
|
-
short_name: null,
|
|
87
|
-
background_color: null,
|
|
88
|
-
theme_color: null,
|
|
89
|
-
icons: []
|
|
90
|
-
}, 'https://example.com/', (0, test_helper_1.testFetcher)({}));
|
|
91
|
-
expect(filterOutput(report)).toEqual({
|
|
92
|
-
messages: [{
|
|
93
|
-
status: types_1.CheckerStatus.Error,
|
|
94
|
-
id: types_1.MessageId.noManifestName,
|
|
95
|
-
}, {
|
|
96
|
-
status: types_1.CheckerStatus.Error,
|
|
97
|
-
id: types_1.MessageId.noManifestShortName,
|
|
98
|
-
}, {
|
|
99
|
-
status: types_1.CheckerStatus.Error,
|
|
100
|
-
id: types_1.MessageId.noManifestBackgroundColor,
|
|
101
|
-
}, {
|
|
102
|
-
status: types_1.CheckerStatus.Error,
|
|
103
|
-
id: types_1.MessageId.noManifestThemeColor,
|
|
104
|
-
}, {
|
|
105
|
-
status: types_1.CheckerStatus.Error,
|
|
106
|
-
id: types_1.MessageId.noManifestIcons,
|
|
107
|
-
}],
|
|
108
|
-
name: undefined,
|
|
109
|
-
shortName: undefined,
|
|
110
|
-
backgroundColor: undefined,
|
|
111
|
-
themeColor: undefined,
|
|
112
|
-
icon: null
|
|
113
|
-
});
|
|
114
|
-
}));
|
|
115
|
-
const testIcon192 = './fixtures/192x192.png';
|
|
116
|
-
const testIcon512 = './fixtures/512x512.png';
|
|
117
|
-
test('checkWebManifestFile - Everything is fine', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
const report = yield (0, web_manifest_1.checkWebManifestFile)({
|
|
119
|
-
name: 'My long name',
|
|
120
|
-
short_name: 'Short!',
|
|
121
|
-
background_color: '#123456',
|
|
122
|
-
theme_color: '#abcdef',
|
|
123
|
-
icons: [
|
|
124
|
-
{ src: '/icon-192.png', sizes: '192x192', type: 'image/png' },
|
|
125
|
-
{ src: '/icon-512.png', sizes: '512x512', type: 'image/png' }
|
|
126
|
-
]
|
|
127
|
-
}, 'https://example.com/', (0, test_helper_1.testFetcher)({
|
|
128
|
-
'https://example.com/icon-192.png': {
|
|
129
|
-
status: 200,
|
|
130
|
-
contentType: 'image/png',
|
|
131
|
-
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon192)
|
|
132
|
-
},
|
|
133
|
-
'https://example.com/icon-512.png': {
|
|
134
|
-
status: 200,
|
|
135
|
-
contentType: 'image/png',
|
|
136
|
-
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon512)
|
|
137
|
-
}
|
|
138
|
-
}));
|
|
139
|
-
const expectedIconReport = [
|
|
140
|
-
{
|
|
141
|
-
status: types_1.CheckerStatus.Ok,
|
|
142
|
-
id: types_1.MessageId.manifestIconDeclared,
|
|
143
|
-
}, {
|
|
144
|
-
status: types_1.CheckerStatus.Ok,
|
|
145
|
-
id: types_1.MessageId.manifestIconDownloadable,
|
|
146
|
-
}, {
|
|
147
|
-
status: types_1.CheckerStatus.Ok,
|
|
148
|
-
id: types_1.MessageId.manifestIconRightSize,
|
|
149
|
-
}
|
|
150
|
-
];
|
|
151
|
-
expect(filterOutput(report)).toEqual({
|
|
152
|
-
messages: [{
|
|
153
|
-
status: types_1.CheckerStatus.Ok,
|
|
154
|
-
id: types_1.MessageId.manifestName,
|
|
155
|
-
}, {
|
|
156
|
-
status: types_1.CheckerStatus.Ok,
|
|
157
|
-
id: types_1.MessageId.manifestShortName,
|
|
158
|
-
}, {
|
|
159
|
-
status: types_1.CheckerStatus.Ok,
|
|
160
|
-
id: types_1.MessageId.manifestBackgroundColor,
|
|
161
|
-
}, {
|
|
162
|
-
status: types_1.CheckerStatus.Ok,
|
|
163
|
-
id: types_1.MessageId.manifestThemeColor,
|
|
164
|
-
},
|
|
165
|
-
...expectedIconReport, ...expectedIconReport], // Two icons
|
|
166
|
-
name: 'My long name',
|
|
167
|
-
shortName: 'Short!',
|
|
168
|
-
backgroundColor: '#123456',
|
|
169
|
-
themeColor: '#abcdef',
|
|
170
|
-
icon: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon512)), 'image/png')
|
|
171
|
-
});
|
|
172
|
-
}));
|
|
File without changes
|