@tgwf/co2 0.11.4 → 0.12.1
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/.esbuild.esm.js +1 -1
- package/.esbuild.node.js +1 -1
- package/README.md +3 -3
- package/dist/cjs/1byte.js +0 -0
- package/dist/cjs/1byte.js.map +2 -2
- package/dist/cjs/co2.js +67 -4
- package/dist/cjs/co2.js.map +2 -2
- package/dist/cjs/constants/file-size.js +0 -0
- package/dist/cjs/constants/file-size.js.map +0 -0
- package/dist/cjs/constants/index.js +20 -0
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/data/average-intensities-2021.min.js +0 -0
- package/dist/cjs/data/average-intensities-2021.min.js.map +0 -0
- package/dist/cjs/data/marginal-intensities-2021.min.js +0 -0
- package/dist/cjs/data/marginal-intensities-2021.min.js.map +0 -0
- package/dist/cjs/helpers/index.js +139 -1
- package/dist/cjs/helpers/index.js.map +2 -2
- package/dist/cjs/hosting-api.js +0 -0
- package/dist/cjs/hosting-api.js.map +0 -0
- package/dist/cjs/hosting-json.node.js +0 -0
- package/dist/cjs/hosting-json.node.js.map +0 -0
- package/dist/cjs/hosting-node.js +0 -0
- package/dist/cjs/hosting-node.js.map +0 -0
- package/dist/cjs/hosting.js +0 -0
- package/dist/cjs/hosting.js.map +0 -0
- package/dist/cjs/index-node.js +0 -0
- package/dist/cjs/index-node.js.map +0 -0
- package/dist/cjs/index.js +0 -0
- package/dist/cjs/index.js.map +0 -0
- package/dist/cjs/package.json +0 -0
- package/dist/cjs/sustainable-web-design.js +67 -49
- package/dist/cjs/sustainable-web-design.js.map +2 -2
- package/dist/esm/1byte.js +0 -0
- package/dist/esm/co2.js +70 -4
- package/dist/esm/constants/file-size.js +0 -0
- package/dist/esm/constants/index.js +20 -0
- package/dist/esm/data/average-intensities-2021.min.js +0 -0
- package/dist/esm/data/marginal-intensities-2021.min.js +0 -0
- package/dist/esm/helpers/index.js +144 -1
- package/dist/esm/hosting-api.js +0 -0
- package/dist/esm/hosting.js +0 -0
- package/dist/esm/index.js +0 -0
- package/dist/esm/package.json +0 -0
- package/dist/esm/sustainable-web-design.js +90 -41
- package/dist/iife/index.js +19 -3
- package/dist/iife/index.js.map +3 -3
- package/package.json +1 -1
- package/src/1byte.js +7 -0
- package/src/co2.js +157 -4
- package/src/constants/index.js +36 -1
- package/src/helpers/index.js +173 -1
- package/src/sustainable-web-design.js +113 -72
- package/dist/cjs/1byte.test.js +0 -27
- package/dist/cjs/1byte.test.js.map +0 -7
- package/dist/cjs/co2.test.js +0 -281
- package/dist/cjs/co2.test.js.map +0 -7
- package/dist/cjs/hosting-api.test.js +0 -47
- package/dist/cjs/hosting-api.test.js.map +0 -7
- package/dist/cjs/hosting-database.node.test.js +0 -36
- package/dist/cjs/hosting-database.node.test.js.map +0 -7
- package/dist/cjs/hosting-json.node.test.js +0 -43
- package/dist/cjs/hosting-json.node.test.js.map +0 -7
- package/dist/cjs/hosting.test.js +0 -67
- package/dist/cjs/hosting.test.js.map +0 -7
- package/dist/cjs/sustainable-web-design.test.js +0 -84
- package/dist/cjs/sustainable-web-design.test.js.map +0 -7
- package/dist/esm/1byte.test.js +0 -11
- package/dist/esm/co2.test.js +0 -265
- package/dist/esm/hosting-api.test.js +0 -31
- package/dist/esm/hosting-database.node.test.js +0 -20
- package/dist/esm/hosting-json.node.test.js +0 -27
- package/dist/esm/hosting.test.js +0 -51
- package/dist/esm/sustainable-web-design.test.js +0 -68
package/dist/cjs/co2.test.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
|
-
var import_fs = __toESM(require("fs"));
|
|
18
|
-
var import_path = __toESM(require("path"));
|
|
19
|
-
var import_pagexray = __toESM(require("pagexray"));
|
|
20
|
-
var import_co2 = __toESM(require("./co2.js"));
|
|
21
|
-
var import_index = require("./index.js");
|
|
22
|
-
describe("co2", () => {
|
|
23
|
-
let har, co2;
|
|
24
|
-
describe("1 byte model", () => {
|
|
25
|
-
const TGWF_GREY_VALUE = 0.20497;
|
|
26
|
-
const TGWF_GREEN_VALUE = 0.54704;
|
|
27
|
-
const TGWF_MIXED_VALUE = 0.16718;
|
|
28
|
-
const MILLION = 1e6;
|
|
29
|
-
const MILLION_GREY = 0.29081;
|
|
30
|
-
const MILLION_GREEN = 0.23196;
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
co2 = new import_co2.default({ model: "1byte" });
|
|
33
|
-
har = JSON.parse(import_fs.default.readFileSync(import_path.default.resolve(__dirname, "../data/fixtures/tgwf.har"), "utf8"));
|
|
34
|
-
});
|
|
35
|
-
describe("perByte", () => {
|
|
36
|
-
it("returns a CO2 number for data transfer using 'grey' power", () => {
|
|
37
|
-
expect(co2.perByte(MILLION).toPrecision(5)).toBe(MILLION_GREY.toPrecision(5));
|
|
38
|
-
});
|
|
39
|
-
it("returns a lower CO2 number for data transfer from domains using entirely 'green' power", () => {
|
|
40
|
-
expect(co2.perByte(MILLION).toPrecision(5)).toBe(MILLION_GREY.toPrecision(5));
|
|
41
|
-
expect(co2.perByte(MILLION, true).toPrecision(5)).toBe(MILLION_GREEN.toPrecision(5));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe("perPage", () => {
|
|
45
|
-
it("returns CO2 for total transfer for page", () => {
|
|
46
|
-
const pages = import_pagexray.default.convert(har);
|
|
47
|
-
const pageXrayRun = pages[0];
|
|
48
|
-
expect(co2.perPage(pageXrayRun).toPrecision(5)).toBe(TGWF_GREY_VALUE.toPrecision(5));
|
|
49
|
-
});
|
|
50
|
-
it("returns lower CO2 for page served from green site", () => {
|
|
51
|
-
const pages = import_pagexray.default.convert(har);
|
|
52
|
-
const pageXrayRun = pages[0];
|
|
53
|
-
let green = [
|
|
54
|
-
"www.thegreenwebfoundation.org",
|
|
55
|
-
"fonts.googleapis.com",
|
|
56
|
-
"ajax.googleapis.com",
|
|
57
|
-
"assets.digitalclimatestrike.net",
|
|
58
|
-
"cdnjs.cloudflare.com",
|
|
59
|
-
"graphite.thegreenwebfoundation.org",
|
|
60
|
-
"analytics.thegreenwebfoundation.org",
|
|
61
|
-
"fonts.gstatic.com",
|
|
62
|
-
"api.thegreenwebfoundation.org"
|
|
63
|
-
];
|
|
64
|
-
expect(co2.perPage(pageXrayRun, green)).toBeLessThan(TGWF_GREY_VALUE);
|
|
65
|
-
});
|
|
66
|
-
it("returns a lower CO2 number where *some* domains use green power", () => {
|
|
67
|
-
const pages = import_pagexray.default.convert(har);
|
|
68
|
-
const pageXrayRun = pages[0];
|
|
69
|
-
let green = [
|
|
70
|
-
"www.thegreenwebfoundation.org",
|
|
71
|
-
"fonts.googleapis.com",
|
|
72
|
-
"ajax.googleapis.com",
|
|
73
|
-
"assets.digitalclimatestrike.net",
|
|
74
|
-
"cdnjs.cloudflare.com",
|
|
75
|
-
"graphite.thegreenwebfoundation.org",
|
|
76
|
-
"analytics.thegreenwebfoundation.org",
|
|
77
|
-
"fonts.gstatic.com",
|
|
78
|
-
"api.thegreenwebfoundation.org"
|
|
79
|
-
];
|
|
80
|
-
expect(co2.perPage(pageXrayRun, green).toPrecision(5)).toBe(TGWF_MIXED_VALUE.toPrecision(5));
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe("perDomain", () => {
|
|
84
|
-
it("shows object listing Co2 for each domain", () => {
|
|
85
|
-
const pages = import_pagexray.default.convert(har);
|
|
86
|
-
const pageXrayRun = pages[0];
|
|
87
|
-
const res = co2.perDomain(pageXrayRun);
|
|
88
|
-
const domains = [
|
|
89
|
-
"thegreenwebfoundation.org",
|
|
90
|
-
"www.thegreenwebfoundation.org",
|
|
91
|
-
"maxcdn.bootstrapcdn.com",
|
|
92
|
-
"fonts.googleapis.com",
|
|
93
|
-
"ajax.googleapis.com",
|
|
94
|
-
"assets.digitalclimatestrike.net",
|
|
95
|
-
"cdnjs.cloudflare.com",
|
|
96
|
-
"graphite.thegreenwebfoundation.org",
|
|
97
|
-
"analytics.thegreenwebfoundation.org",
|
|
98
|
-
"fonts.gstatic.com",
|
|
99
|
-
"api.thegreenwebfoundation.org"
|
|
100
|
-
];
|
|
101
|
-
for (let obj of res) {
|
|
102
|
-
expect(domains.indexOf(obj.domain)).toBeGreaterThan(-1);
|
|
103
|
-
expect(typeof obj.co2).toBe("number");
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
it("shows lower Co2 for green domains", () => {
|
|
107
|
-
const pages = import_pagexray.default.convert(har);
|
|
108
|
-
const pageXrayRun = pages[0];
|
|
109
|
-
const greenDomains = [
|
|
110
|
-
"www.thegreenwebfoundation.org",
|
|
111
|
-
"fonts.googleapis.com",
|
|
112
|
-
"ajax.googleapis.com",
|
|
113
|
-
"assets.digitalclimatestrike.net",
|
|
114
|
-
"cdnjs.cloudflare.com",
|
|
115
|
-
"graphite.thegreenwebfoundation.org",
|
|
116
|
-
"analytics.thegreenwebfoundation.org",
|
|
117
|
-
"fonts.gstatic.com",
|
|
118
|
-
"api.thegreenwebfoundation.org"
|
|
119
|
-
];
|
|
120
|
-
const res = co2.perDomain(pageXrayRun);
|
|
121
|
-
const resWithGreen = co2.perDomain(pageXrayRun, greenDomains);
|
|
122
|
-
for (let obj of res) {
|
|
123
|
-
expect(typeof obj.co2).toBe("number");
|
|
124
|
-
}
|
|
125
|
-
for (let obj of greenDomains) {
|
|
126
|
-
let index = 0;
|
|
127
|
-
expect(resWithGreen[index].co2).toBeLessThan(res[index].co2);
|
|
128
|
-
index++;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
describe("Sustainable Web Design model as simple option", () => {
|
|
134
|
-
const MILLION = 1e6;
|
|
135
|
-
const MILLION_GREY = 0.35802;
|
|
136
|
-
const MILLION_GREEN = 0.31039;
|
|
137
|
-
const MILLION_PERVISIT_GREY = 0.27031;
|
|
138
|
-
const MILLION_PERVISIT_GREEN = 0.23435;
|
|
139
|
-
const TGWF_GREY_VALUE = 0.25234;
|
|
140
|
-
const TGWF_GREEN_VALUE = 0.54704;
|
|
141
|
-
const TGWF_MIXED_VALUE = 0.22175;
|
|
142
|
-
beforeEach(() => {
|
|
143
|
-
co2 = new import_co2.default();
|
|
144
|
-
har = JSON.parse(import_fs.default.readFileSync(import_path.default.resolve(__dirname, "../data/fixtures/tgwf.har"), "utf8"));
|
|
145
|
-
});
|
|
146
|
-
describe("perByte", () => {
|
|
147
|
-
it("returns a CO2 number for data transfer", () => {
|
|
148
|
-
co2.perByte(MILLION);
|
|
149
|
-
expect(co2.perByte(MILLION).toPrecision(5)).toBe(MILLION_GREY.toPrecision(5));
|
|
150
|
-
});
|
|
151
|
-
it("returns a lower CO2 number for data transfer from domains using entirely 'green' power", () => {
|
|
152
|
-
expect(co2.perByte(MILLION, false).toPrecision(5)).toBe(MILLION_GREY.toPrecision(5));
|
|
153
|
-
expect(co2.perByte(MILLION, true).toPrecision(5)).toBe(MILLION_GREEN.toPrecision(5));
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
describe("perVisit", () => {
|
|
157
|
-
it("returns a CO2 number for data transfer per visit with caching assumptions from the Sustainable Web Design model", () => {
|
|
158
|
-
co2.perVisit(MILLION);
|
|
159
|
-
expect(co2.perVisit(MILLION).toPrecision(5)).toBe(MILLION_PERVISIT_GREY.toPrecision(5));
|
|
160
|
-
});
|
|
161
|
-
it("returns a lower CO2 number for data transfer from domains using entirely 'green' power", () => {
|
|
162
|
-
expect(co2.perVisit(MILLION, false).toPrecision(5)).toBe(MILLION_PERVISIT_GREY.toPrecision(5));
|
|
163
|
-
expect(co2.perVisit(MILLION, true).toPrecision(5)).toBe(MILLION_PERVISIT_GREEN.toPrecision(5));
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
describe("perPage", () => {
|
|
167
|
-
it("returns CO2 for total transfer for page", () => {
|
|
168
|
-
const pages = import_pagexray.default.convert(har);
|
|
169
|
-
const pageXrayRun = pages[0];
|
|
170
|
-
expect(co2.perPage(pageXrayRun).toPrecision(5)).toBe(TGWF_GREY_VALUE.toPrecision(5));
|
|
171
|
-
});
|
|
172
|
-
it("returns lower CO2 for page served from green site", () => {
|
|
173
|
-
const pages = import_pagexray.default.convert(har);
|
|
174
|
-
const pageXrayRun = pages[0];
|
|
175
|
-
let green = [
|
|
176
|
-
"www.thegreenwebfoundation.org",
|
|
177
|
-
"fonts.googleapis.com",
|
|
178
|
-
"ajax.googleapis.com",
|
|
179
|
-
"assets.digitalclimatestrike.net",
|
|
180
|
-
"cdnjs.cloudflare.com",
|
|
181
|
-
"graphite.thegreenwebfoundation.org",
|
|
182
|
-
"analytics.thegreenwebfoundation.org",
|
|
183
|
-
"fonts.gstatic.com",
|
|
184
|
-
"api.thegreenwebfoundation.org"
|
|
185
|
-
];
|
|
186
|
-
expect(co2.perPage(pageXrayRun, green)).toBeLessThan(TGWF_GREY_VALUE);
|
|
187
|
-
});
|
|
188
|
-
it("returns a lower CO2 number where *some* domains use green power", () => {
|
|
189
|
-
const pages = import_pagexray.default.convert(har);
|
|
190
|
-
const pageXrayRun = pages[0];
|
|
191
|
-
let green = [
|
|
192
|
-
"www.thegreenwebfoundation.org",
|
|
193
|
-
"fonts.googleapis.com",
|
|
194
|
-
"ajax.googleapis.com",
|
|
195
|
-
"assets.digitalclimatestrike.net",
|
|
196
|
-
"cdnjs.cloudflare.com",
|
|
197
|
-
"graphite.thegreenwebfoundation.org",
|
|
198
|
-
"analytics.thegreenwebfoundation.org",
|
|
199
|
-
"fonts.gstatic.com",
|
|
200
|
-
"api.thegreenwebfoundation.org"
|
|
201
|
-
];
|
|
202
|
-
expect(co2.perPage(pageXrayRun, green).toPrecision(5)).toBe(TGWF_MIXED_VALUE.toPrecision(5));
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
describe("perDomain", () => {
|
|
206
|
-
it("shows object listing Co2 for each domain", () => {
|
|
207
|
-
const pages = import_pagexray.default.convert(har);
|
|
208
|
-
const pageXrayRun = pages[0];
|
|
209
|
-
const res = co2.perDomain(pageXrayRun);
|
|
210
|
-
const domains = [
|
|
211
|
-
"thegreenwebfoundation.org",
|
|
212
|
-
"www.thegreenwebfoundation.org",
|
|
213
|
-
"maxcdn.bootstrapcdn.com",
|
|
214
|
-
"fonts.googleapis.com",
|
|
215
|
-
"ajax.googleapis.com",
|
|
216
|
-
"assets.digitalclimatestrike.net",
|
|
217
|
-
"cdnjs.cloudflare.com",
|
|
218
|
-
"graphite.thegreenwebfoundation.org",
|
|
219
|
-
"analytics.thegreenwebfoundation.org",
|
|
220
|
-
"fonts.gstatic.com",
|
|
221
|
-
"api.thegreenwebfoundation.org"
|
|
222
|
-
];
|
|
223
|
-
for (let obj of res) {
|
|
224
|
-
expect(domains.indexOf(obj.domain)).toBeGreaterThan(-1);
|
|
225
|
-
expect(typeof obj.co2).toBe("number");
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
it("shows lower Co2 for green domains", () => {
|
|
229
|
-
const pages = import_pagexray.default.convert(har);
|
|
230
|
-
const pageXrayRun = pages[0];
|
|
231
|
-
const greenDomains = [
|
|
232
|
-
"www.thegreenwebfoundation.org",
|
|
233
|
-
"fonts.googleapis.com",
|
|
234
|
-
"ajax.googleapis.com",
|
|
235
|
-
"assets.digitalclimatestrike.net",
|
|
236
|
-
"cdnjs.cloudflare.com",
|
|
237
|
-
"graphite.thegreenwebfoundation.org",
|
|
238
|
-
"analytics.thegreenwebfoundation.org",
|
|
239
|
-
"fonts.gstatic.com",
|
|
240
|
-
"api.thegreenwebfoundation.org"
|
|
241
|
-
];
|
|
242
|
-
const res = co2.perDomain(pageXrayRun);
|
|
243
|
-
const resWithGreen = co2.perDomain(pageXrayRun, greenDomains);
|
|
244
|
-
for (let obj of res) {
|
|
245
|
-
expect(typeof obj.co2).toBe("number");
|
|
246
|
-
}
|
|
247
|
-
for (let obj of greenDomains) {
|
|
248
|
-
let index = 0;
|
|
249
|
-
expect(resWithGreen[index].co2).toBeLessThan(res[index].co2);
|
|
250
|
-
index++;
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
describe("Error checking", () => {
|
|
256
|
-
it("throws an error if model is not valid", () => {
|
|
257
|
-
expect(() => co2 = new import_co2.default({ model: "1direction" })).toThrowError(`"1direction" is not a valid model. Please use "1byte" for the OneByte model, and "swd" for the Sustainable Web Design model.
|
|
258
|
-
See https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.`);
|
|
259
|
-
});
|
|
260
|
-
it("throws an error if perVisit method is not supported by model", () => {
|
|
261
|
-
expect(() => {
|
|
262
|
-
co2 = new import_co2.default({ model: "1byte" });
|
|
263
|
-
co2.perVisit(10);
|
|
264
|
-
}).toThrowError(`The perVisit() method is not supported in the model you are using. Try using perByte() instead.
|
|
265
|
-
See https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
describe("Importing grid intensity", () => {
|
|
269
|
-
describe("average intensity", () => {
|
|
270
|
-
it("imports average intensity data", () => {
|
|
271
|
-
expect(import_index.averageIntensity).toHaveProperty("type", "average");
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
describe("marginal intensity", () => {
|
|
275
|
-
it("imports average intensity data", () => {
|
|
276
|
-
expect(import_index.marginalIntensity).toHaveProperty("type", "marginal");
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
//# sourceMappingURL=co2.test.js.map
|
package/dist/cjs/co2.test.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/co2.test.js"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nimport pagexray from \"pagexray\";\n\nimport CO2 from \"./co2.js\";\nimport { averageIntensity, marginalIntensity } from \"./index.js\";\n\ndescribe(\"co2\", () => {\n let har, co2;\n\n describe(\"1 byte model\", () => {\n const TGWF_GREY_VALUE = 0.20497;\n const TGWF_GREEN_VALUE = 0.54704;\n const TGWF_MIXED_VALUE = 0.16718;\n\n const MILLION = 1000000;\n const MILLION_GREY = 0.29081;\n const MILLION_GREEN = 0.23196;\n\n beforeEach(() => {\n co2 = new CO2({ model: \"1byte\" });\n har = JSON.parse(\n fs.readFileSync(\n path.resolve(__dirname, \"../data/fixtures/tgwf.har\"),\n \"utf8\"\n )\n );\n });\n\n describe(\"perByte\", () => {\n it(\"returns a CO2 number for data transfer using 'grey' power\", () => {\n expect(co2.perByte(MILLION).toPrecision(5)).toBe(\n MILLION_GREY.toPrecision(5)\n );\n });\n\n it(\"returns a lower CO2 number for data transfer from domains using entirely 'green' power\", () => {\n expect(co2.perByte(MILLION).toPrecision(5)).toBe(\n MILLION_GREY.toPrecision(5)\n );\n expect(co2.perByte(MILLION, true).toPrecision(5)).toBe(\n MILLION_GREEN.toPrecision(5)\n );\n });\n });\n\n describe(\"perPage\", () => {\n it(\"returns CO2 for total transfer for page\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n\n expect(co2.perPage(pageXrayRun).toPrecision(5)).toBe(\n TGWF_GREY_VALUE.toPrecision(5)\n );\n });\n it(\"returns lower CO2 for page served from green site\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n let green = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n expect(co2.perPage(pageXrayRun, green)).toBeLessThan(TGWF_GREY_VALUE);\n });\n it(\"returns a lower CO2 number where *some* domains use green power\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n // green can be true, or a array containing entries\n let green = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n expect(co2.perPage(pageXrayRun, green).toPrecision(5)).toBe(\n TGWF_MIXED_VALUE.toPrecision(5)\n );\n });\n });\n describe(\"perDomain\", () => {\n it(\"shows object listing Co2 for each domain\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n const res = co2.perDomain(pageXrayRun);\n\n const domains = [\n \"thegreenwebfoundation.org\",\n \"www.thegreenwebfoundation.org\",\n \"maxcdn.bootstrapcdn.com\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n\n for (let obj of res) {\n expect(domains.indexOf(obj.domain)).toBeGreaterThan(-1);\n expect(typeof obj.co2).toBe(\"number\");\n }\n });\n it(\"shows lower Co2 for green domains\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n\n const greenDomains = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n const res = co2.perDomain(pageXrayRun);\n const resWithGreen = co2.perDomain(pageXrayRun, greenDomains);\n\n for (let obj of res) {\n expect(typeof obj.co2).toBe(\"number\");\n }\n for (let obj of greenDomains) {\n let index = 0;\n expect(resWithGreen[index].co2).toBeLessThan(res[index].co2);\n index++;\n }\n });\n });\n });\n\n describe(\"Sustainable Web Design model as simple option\", () => {\n // the SWD model should have slightly higher values as\n // we include more of the system in calculations for the\n // same levels of data transfer\n const MILLION = 1000000;\n const MILLION_GREY = 0.35802;\n const MILLION_GREEN = 0.31039;\n const MILLION_PERVISIT_GREY = 0.27031;\n const MILLION_PERVISIT_GREEN = 0.23435;\n\n const TGWF_GREY_VALUE = 0.25234;\n const TGWF_GREEN_VALUE = 0.54704;\n const TGWF_MIXED_VALUE = 0.22175;\n\n // We're not passing in a model parameter here to check that SWD is used by default\n beforeEach(() => {\n co2 = new CO2();\n har = JSON.parse(\n fs.readFileSync(\n path.resolve(__dirname, \"../data/fixtures/tgwf.har\"),\n \"utf8\"\n )\n );\n });\n\n describe(\"perByte\", () => {\n it(\"returns a CO2 number for data transfer\", () => {\n co2.perByte(MILLION);\n expect(co2.perByte(MILLION).toPrecision(5)).toBe(\n MILLION_GREY.toPrecision(5)\n );\n });\n\n it(\"returns a lower CO2 number for data transfer from domains using entirely 'green' power\", () => {\n expect(co2.perByte(MILLION, false).toPrecision(5)).toBe(\n MILLION_GREY.toPrecision(5)\n );\n\n expect(co2.perByte(MILLION, true).toPrecision(5)).toBe(\n MILLION_GREEN.toPrecision(5)\n );\n });\n });\n\n describe(\"perVisit\", () => {\n it(\"returns a CO2 number for data transfer per visit with caching assumptions from the Sustainable Web Design model\", () => {\n co2.perVisit(MILLION);\n expect(co2.perVisit(MILLION).toPrecision(5)).toBe(\n MILLION_PERVISIT_GREY.toPrecision(5)\n );\n });\n\n it(\"returns a lower CO2 number for data transfer from domains using entirely 'green' power\", () => {\n expect(co2.perVisit(MILLION, false).toPrecision(5)).toBe(\n MILLION_PERVISIT_GREY.toPrecision(5)\n );\n\n expect(co2.perVisit(MILLION, true).toPrecision(5)).toBe(\n MILLION_PERVISIT_GREEN.toPrecision(5)\n );\n });\n });\n\n describe(\"perPage\", () => {\n it(\"returns CO2 for total transfer for page\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n\n expect(co2.perPage(pageXrayRun).toPrecision(5)).toBe(\n TGWF_GREY_VALUE.toPrecision(5)\n );\n });\n it(\"returns lower CO2 for page served from green site\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n let green = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n expect(co2.perPage(pageXrayRun, green)).toBeLessThan(TGWF_GREY_VALUE);\n });\n it(\"returns a lower CO2 number where *some* domains use green power\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n // green can be true, or a array containing entries\n let green = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n expect(co2.perPage(pageXrayRun, green).toPrecision(5)).toBe(\n TGWF_MIXED_VALUE.toPrecision(5)\n );\n });\n });\n describe(\"perDomain\", () => {\n it(\"shows object listing Co2 for each domain\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n const res = co2.perDomain(pageXrayRun);\n\n const domains = [\n \"thegreenwebfoundation.org\",\n \"www.thegreenwebfoundation.org\",\n \"maxcdn.bootstrapcdn.com\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n\n for (let obj of res) {\n expect(domains.indexOf(obj.domain)).toBeGreaterThan(-1);\n expect(typeof obj.co2).toBe(\"number\");\n }\n });\n it(\"shows lower Co2 for green domains\", () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n\n const greenDomains = [\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n const res = co2.perDomain(pageXrayRun);\n const resWithGreen = co2.perDomain(pageXrayRun, greenDomains);\n\n for (let obj of res) {\n expect(typeof obj.co2).toBe(\"number\");\n }\n for (let obj of greenDomains) {\n let index = 0;\n expect(resWithGreen[index].co2).toBeLessThan(res[index].co2);\n index++;\n }\n });\n });\n });\n\n describe(\"Error checking\", () => {\n // Test for error if incorrect model is passed\n it(\"throws an error if model is not valid\", () => {\n expect(() => (co2 = new CO2({ model: \"1direction\" }))).toThrowError(\n `\"1direction\" is not a valid model. Please use \"1byte\" for the OneByte model, and \"swd\" for the Sustainable Web Design model.\\nSee https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.`\n );\n });\n\n // Test that an error is thrown when using the OneByte model with the perVisit method.\n it(\"throws an error if perVisit method is not supported by model\", () => {\n expect(() => {\n co2 = new CO2({ model: \"1byte\" });\n co2.perVisit(10);\n }).toThrowError(\n `The perVisit() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`\n );\n });\n });\n\n // Test that grid intensity data can be imported and used\n describe(\"Importing grid intensity\", () => {\n describe(\"average intensity\", () => {\n it(\"imports average intensity data\", () => {\n expect(averageIntensity).toHaveProperty(\"type\", \"average\");\n });\n });\n\n describe(\"marginal intensity\", () => {\n it(\"imports average intensity data\", () => {\n expect(marginalIntensity).toHaveProperty(\"type\", \"marginal\");\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAEA,gBAAe;AACf,kBAAiB;AAEjB,sBAAqB;AAErB,iBAAgB;AAChB,mBAAoD;AAEpD,SAAS,OAAO,MAAM;AACpB,MAAI,KAAK;AAET,WAAS,gBAAgB,MAAM;AAC7B,UAAM,kBAAkB;AACxB,UAAM,mBAAmB;AACzB,UAAM,mBAAmB;AAEzB,UAAM,UAAU;AAChB,UAAM,eAAe;AACrB,UAAM,gBAAgB;AAEtB,eAAW,MAAM;AACf,YAAM,IAAI,mBAAI,EAAE,OAAO,QAAQ,CAAC;AAChC,YAAM,KAAK,MACT,kBAAG,aACD,oBAAK,QAAQ,WAAW,2BAA2B,GACnD,MACF,CACF;AAAA,IACF,CAAC;AAED,aAAS,WAAW,MAAM;AACxB,SAAG,6DAA6D,MAAM;AACpE,eAAO,IAAI,QAAQ,OAAO,EAAE,YAAY,CAAC,CAAC,EAA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= Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
|
-
var import_hosting_node = __toESM(require("./hosting-node.js"));
|
|
18
|
-
var import_nock = __toESM(require("nock"));
|
|
19
|
-
describe("hostingAPI", () => {
|
|
20
|
-
describe("checking a single domain with #check", () => {
|
|
21
|
-
it.skip("using the API", async () => {
|
|
22
|
-
const scope = (0, import_nock.default)("https://api.thegreenwebfoundation.org/").get("/greencheck/google.com").reply(200, {
|
|
23
|
-
url: "google.com",
|
|
24
|
-
green: true
|
|
25
|
-
});
|
|
26
|
-
const res = await import_hosting_node.default.check("google.com");
|
|
27
|
-
expect(res).toEqual(true);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe("implicitly checking multiple domains with #check", () => {
|
|
31
|
-
it.skip("using the API", async () => {
|
|
32
|
-
const scope = (0, import_nock.default)("https://api.thegreenwebfoundation.org/").get("/v2/greencheckmulti/[%22google.com%22,%22kochindustries.com%22]").reply(200, {
|
|
33
|
-
"google.com": {
|
|
34
|
-
url: "google.com",
|
|
35
|
-
green: true
|
|
36
|
-
},
|
|
37
|
-
"kochindustries.com": {
|
|
38
|
-
url: "kochindustries.com",
|
|
39
|
-
green: null
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
const res = await import_hosting_node.default.check(["google.com", "kochindustries.com"]);
|
|
43
|
-
expect(res).toContain("google.com");
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=hosting-api.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hosting-api.test.js"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nimport hosting from \"./hosting-node.js\";\nimport nock from \"nock\";\n/* eslint-disable jest/no-disabled-tests */\ndescribe(\"hostingAPI\", () => {\n describe(\"checking a single domain with #check\", () => {\n it.skip(\"using the API\", async () => {\n const scope = nock(\"https://api.thegreenwebfoundation.org/\")\n .get(\"/greencheck/google.com\")\n .reply(200, {\n url: \"google.com\",\n green: true,\n });\n const res = await hosting.check(\"google.com\");\n expect(res).toEqual(true);\n });\n });\n describe(\"implicitly checking multiple domains with #check\", () => {\n it.skip(\"using the API\", async () => {\n const scope = nock(\"https://api.thegreenwebfoundation.org/\")\n .get(\"/v2/greencheckmulti/[%22google.com%22,%22kochindustries.com%22]\")\n .reply(200, {\n \"google.com\": {\n url: \"google.com\",\n green: true,\n },\n \"kochindustries.com\": {\n url: \"kochindustries.com\",\n green: null,\n },\n });\n const res = await hosting.check([\"google.com\", \"kochindustries.com\"]);\n expect(res).toContain(\"google.com\");\n });\n });\n});\n/* eslint-enable jest/no-disabled-tests */\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAEA,0BAAoB;AACpB,kBAAiB;AAEjB,SAAS,cAAc,MAAM;AAC3B,WAAS,wCAAwC,MAAM;AACrD,OAAG,KAAK,iBAAiB,YAAY;AACnC,YAAM,QAAQ,yBAAK,wCAAwC,EACxD,IAAI,wBAAwB,EAC5B,MAAM,KAAK;AAAA,QACV,KAAK;AAAA,QACL,OAAO;AAAA,MACT,CAAC;AACH,YAAM,MAAM,MAAM,4BAAQ,MAAM,YAAY;AAC5C,aAAO,GAAG,EAAE,QAAQ,IAAI;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AACD,WAAS,oDAAoD,MAAM;AACjE,OAAG,KAAK,iBAAiB,YAAY;AACnC,YAAM,QAAQ,yBAAK,wCAAwC,EACxD,IAAI,iEAAiE,EACrE,MAAM,KAAK;AAAA,QACV,cAAc;AAAA,UACZ,KAAK;AAAA,UACL,OAAO;AAAA,QACT;AAAA,QACA,sBAAsB;AAAA,UACpB,KAAK;AAAA,UACL,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AACH,YAAM,MAAM,MAAM,4BAAQ,MAAM,CAAC,cAAc,oBAAoB,CAAC;AACpE,aAAO,GAAG,EAAE,UAAU,YAAY;AAAA,IACpC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
|
-
var import_path = __toESM(require("path"));
|
|
18
|
-
var import_debug = __toESM(require("debug"));
|
|
19
|
-
var import_url2green = require("@tgwf/url2green");
|
|
20
|
-
const log = (0, import_debug.default)("tgwf:url2green:test");
|
|
21
|
-
const dbPath = import_path.default.resolve(__dirname, "..", "data", "fixtures", "url2green.test.db");
|
|
22
|
-
describe("hostingDatabase", () => {
|
|
23
|
-
describe("checking a single domain with #check", () => {
|
|
24
|
-
test("tries to use a local database if available", async () => {
|
|
25
|
-
const res = await import_url2green.hosting.check("google.com", dbPath);
|
|
26
|
-
expect(res).toEqual(true);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe("implicitly checking multiple domains with #check", () => {
|
|
30
|
-
test("tries to use a local database if available", async () => {
|
|
31
|
-
const res = await import_url2green.hosting.check(["google.com", "kochindustries.com"], dbPath);
|
|
32
|
-
expect(res).toContain("google.com");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=hosting-database.node.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hosting-database.node.test.js"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nimport path from \"path\";\n\nimport debugFactory from \"debug\";\nconst log = debugFactory(\"tgwf:url2green:test\");\n\nimport { hosting } from \"@tgwf/url2green\";\n\nconst dbPath = path.resolve(\n __dirname,\n \"..\",\n \"data\",\n \"fixtures\",\n \"url2green.test.db\"\n);\n\ndescribe(\"hostingDatabase\", () => {\n describe(\"checking a single domain with #check\", () => {\n test(\"tries to use a local database if available\", async () => {\n const res = await hosting.check(\"google.com\", dbPath);\n expect(res).toEqual(true);\n });\n });\n describe(\"implicitly checking multiple domains with #check\", () => {\n test(\"tries to use a local database if available\", async () => {\n const res = await hosting.check(\n [\"google.com\", \"kochindustries.com\"],\n dbPath\n );\n expect(res).toContain(\"google.com\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAEA,kBAAiB;AAEjB,mBAAyB;AAGzB,uBAAwB;AAFxB,MAAM,MAAM,0BAAa,qBAAqB;AAI9C,MAAM,SAAS,oBAAK,QAClB,WACA,MACA,QACA,YACA,mBACF;AAEA,SAAS,mBAAmB,MAAM;AAChC,WAAS,wCAAwC,MAAM;AACrD,SAAK,8CAA8C,YAAY;AAC7D,YAAM,MAAM,MAAM,yBAAQ,MAAM,cAAc,MAAM;AACpD,aAAO,GAAG,EAAE,QAAQ,IAAI;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AACD,WAAS,oDAAoD,MAAM;AACjE,SAAK,8CAA8C,YAAY;AAC7D,YAAM,MAAM,MAAM,yBAAQ,MACxB,CAAC,cAAc,oBAAoB,GACnC,MACF;AACA,aAAO,GAAG,EAAE,UAAU,YAAY;AAAA,IACpC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
|
-
var import_hosting_json_node = __toESM(require("./hosting-json.node.js"));
|
|
18
|
-
var import_path = __toESM(require("path"));
|
|
19
|
-
describe("hostingJSON", () => {
|
|
20
|
-
const jsonPath = import_path.default.resolve(__dirname, "..", "data", "fixtures", "url2green.test.json");
|
|
21
|
-
const jsonPathGz = import_path.default.resolve(__dirname, "..", "data", "fixtures", "url2green.test.json.gz");
|
|
22
|
-
describe("checking a single domain with #check", () => {
|
|
23
|
-
test("against the list of domains as JSON", async () => {
|
|
24
|
-
const db = await import_hosting_json_node.default.loadJSON(jsonPath);
|
|
25
|
-
const res = await import_hosting_json_node.default.check("google.com", db);
|
|
26
|
-
expect(res).toEqual(true);
|
|
27
|
-
});
|
|
28
|
-
test("against the list of domains as JSON loaded from a gzipped JSON", async () => {
|
|
29
|
-
const db = await import_hosting_json_node.default.loadJSON(jsonPathGz);
|
|
30
|
-
const res = await import_hosting_json_node.default.check("google.com", db);
|
|
31
|
-
expect(res).toEqual(true);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe("implicitly checking multiple domains with #check", () => {
|
|
35
|
-
test("against the list of domains as JSON", async () => {
|
|
36
|
-
const db = await import_hosting_json_node.default.loadJSON(jsonPath);
|
|
37
|
-
const domains = ["google.com", "kochindustries.com"];
|
|
38
|
-
const res = await import_hosting_json_node.default.check(domains, db);
|
|
39
|
-
expect(res).toContain("google.com");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=hosting-json.node.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hosting-json.node.test.js"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nimport hosting from \"./hosting-json.node.js\";\nimport path from \"path\";\n\ndescribe(\"hostingJSON\", () => {\n const jsonPath = path.resolve(\n __dirname,\n \"..\",\n \"data\",\n \"fixtures\",\n \"url2green.test.json\"\n );\n const jsonPathGz = path.resolve(\n __dirname,\n \"..\",\n \"data\",\n \"fixtures\",\n \"url2green.test.json.gz\"\n );\n describe(\"checking a single domain with #check\", () => {\n test(\"against the list of domains as JSON\", async () => {\n const db = await hosting.loadJSON(jsonPath);\n const res = await hosting.check(\"google.com\", db);\n expect(res).toEqual(true);\n });\n test(\"against the list of domains as JSON loaded from a gzipped JSON\", async () => {\n const db = await hosting.loadJSON(jsonPathGz);\n const res = await hosting.check(\"google.com\", db);\n expect(res).toEqual(true);\n });\n });\n describe(\"implicitly checking multiple domains with #check\", () => {\n test(\"against the list of domains as JSON\", async () => {\n const db = await hosting.loadJSON(jsonPath);\n const domains = [\"google.com\", \"kochindustries.com\"];\n\n const res = await hosting.check(domains, db);\n expect(res).toContain(\"google.com\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAEA,+BAAoB;AACpB,kBAAiB;AAEjB,SAAS,eAAe,MAAM;AAC5B,QAAM,WAAW,oBAAK,QACpB,WACA,MACA,QACA,YACA,qBACF;AACA,QAAM,aAAa,oBAAK,QACtB,WACA,MACA,QACA,YACA,wBACF;AACA,WAAS,wCAAwC,MAAM;AACrD,SAAK,uCAAuC,YAAY;AACtD,YAAM,KAAK,MAAM,iCAAQ,SAAS,QAAQ;AAC1C,YAAM,MAAM,MAAM,iCAAQ,MAAM,cAAc,EAAE;AAChD,aAAO,GAAG,EAAE,QAAQ,IAAI;AAAA,IAC1B,CAAC;AACD,SAAK,kEAAkE,YAAY;AACjF,YAAM,KAAK,MAAM,iCAAQ,SAAS,UAAU;AAC5C,YAAM,MAAM,MAAM,iCAAQ,MAAM,cAAc,EAAE;AAChD,aAAO,GAAG,EAAE,QAAQ,IAAI;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AACD,WAAS,oDAAoD,MAAM;AACjE,SAAK,uCAAuC,YAAY;AACtD,YAAM,KAAK,MAAM,iCAAQ,SAAS,QAAQ;AAC1C,YAAM,UAAU,CAAC,cAAc,oBAAoB;AAEnD,YAAM,MAAM,MAAM,iCAAQ,MAAM,SAAS,EAAE;AAC3C,aAAO,GAAG,EAAE,UAAU,YAAY;AAAA,IACpC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/cjs/hosting.test.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
|
-
var import_fs = __toESM(require("fs"));
|
|
18
|
-
var import_path = __toESM(require("path"));
|
|
19
|
-
var import_pagexray = __toESM(require("pagexray"));
|
|
20
|
-
var import_hosting_node = __toESM(require("./hosting-node.js"));
|
|
21
|
-
const jsonPath = import_path.default.resolve(__dirname, "..", "data", "fixtures", "url2green.test.json");
|
|
22
|
-
describe("hosting", () => {
|
|
23
|
-
let har;
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
har = JSON.parse(import_fs.default.readFileSync(import_path.default.resolve(__dirname, "../data/fixtures/tgwf.har"), "utf8"));
|
|
26
|
-
});
|
|
27
|
-
describe("checking all domains on a page object with #checkPage", () => {
|
|
28
|
-
it("returns a list of green domains, when passed a page object", async () => {
|
|
29
|
-
const pages = import_pagexray.default.convert(har);
|
|
30
|
-
const pageXrayRun = pages[0];
|
|
31
|
-
const db = await import_hosting_node.default.loadJSON(jsonPath);
|
|
32
|
-
const greenDomains = await import_hosting_node.default.checkPage(pageXrayRun, db);
|
|
33
|
-
expect(greenDomains).toHaveLength(11);
|
|
34
|
-
const expectedGreendomains = [
|
|
35
|
-
"maxcdn.bootstrapcdn.com",
|
|
36
|
-
"thegreenwebfoundation.org",
|
|
37
|
-
"www.thegreenwebfoundation.org",
|
|
38
|
-
"fonts.googleapis.com",
|
|
39
|
-
"ajax.googleapis.com",
|
|
40
|
-
"assets.digitalclimatestrike.net",
|
|
41
|
-
"cdnjs.cloudflare.com",
|
|
42
|
-
"graphite.thegreenwebfoundation.org",
|
|
43
|
-
"analytics.thegreenwebfoundation.org",
|
|
44
|
-
"fonts.gstatic.com",
|
|
45
|
-
"api.thegreenwebfoundation.org"
|
|
46
|
-
];
|
|
47
|
-
greenDomains.forEach((dom) => {
|
|
48
|
-
expect(expectedGreendomains).toContain(dom);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe("checking a single domain with #check", () => {
|
|
53
|
-
it("use the API instead", async () => {
|
|
54
|
-
const db = await import_hosting_node.default.loadJSON(jsonPath);
|
|
55
|
-
const res = await import_hosting_node.default.check("google.com");
|
|
56
|
-
expect(res).toEqual(true);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe("checking multiple domains with #check", () => {
|
|
60
|
-
it("Use the API", async () => {
|
|
61
|
-
const db = await import_hosting_node.default.loadJSON(jsonPath);
|
|
62
|
-
const res = await import_hosting_node.default.check(["google.com", "kochindustries.com"]);
|
|
63
|
-
expect(res).toContain("google.com");
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=hosting.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hosting.test.js"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nimport pagexray from \"pagexray\";\n\nimport hosting from \"./hosting-node.js\";\n\nconst jsonPath = path.resolve(\n __dirname,\n \"..\",\n \"data\",\n \"fixtures\",\n \"url2green.test.json\"\n);\n\ndescribe(\"hosting\", () => {\n let har;\n beforeEach(() => {\n har = JSON.parse(\n fs.readFileSync(\n path.resolve(__dirname, \"../data/fixtures/tgwf.har\"),\n \"utf8\"\n )\n );\n });\n describe(\"checking all domains on a page object with #checkPage\", () => {\n it(\"returns a list of green domains, when passed a page object\", async () => {\n const pages = pagexray.convert(har);\n const pageXrayRun = pages[0];\n const db = await hosting.loadJSON(jsonPath);\n const greenDomains = await hosting.checkPage(pageXrayRun, db);\n\n expect(greenDomains).toHaveLength(11);\n const expectedGreendomains = [\n \"maxcdn.bootstrapcdn.com\",\n \"thegreenwebfoundation.org\",\n \"www.thegreenwebfoundation.org\",\n \"fonts.googleapis.com\",\n \"ajax.googleapis.com\",\n \"assets.digitalclimatestrike.net\",\n \"cdnjs.cloudflare.com\",\n \"graphite.thegreenwebfoundation.org\",\n \"analytics.thegreenwebfoundation.org\",\n \"fonts.gstatic.com\",\n \"api.thegreenwebfoundation.org\",\n ];\n greenDomains.forEach((dom) => {\n expect(expectedGreendomains).toContain(dom);\n });\n });\n });\n describe(\"checking a single domain with #check\", () => {\n it(\"use the API instead\", async () => {\n const db = await hosting.loadJSON(jsonPath);\n const res = await hosting.check(\"google.com\");\n expect(res).toEqual(true);\n });\n });\n describe(\"checking multiple domains with #check\", () => {\n it(\"Use the API\", async () => {\n const db = await hosting.loadJSON(jsonPath);\n\n const res = await hosting.check([\"google.com\", \"kochindustries.com\"]);\n expect(res).toContain(\"google.com\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAEA,gBAAe;AACf,kBAAiB;AAEjB,sBAAqB;AAErB,0BAAoB;AAEpB,MAAM,WAAW,oBAAK,QACpB,WACA,MACA,QACA,YACA,qBACF;AAEA,SAAS,WAAW,MAAM;AACxB,MAAI;AACJ,aAAW,MAAM;AACf,UAAM,KAAK,MACT,kBAAG,aACD,oBAAK,QAAQ,WAAW,2BAA2B,GACnD,MACF,CACF;AAAA,EACF,CAAC;AACD,WAAS,yDAAyD,MAAM;AACtE,OAAG,8DAA8D,YAAY;AAC3E,YAAM,QAAQ,wBAAS,QAAQ,GAAG;AAClC,YAAM,cAAc,MAAM;AAC1B,YAAM,KAAK,MAAM,4BAAQ,SAAS,QAAQ;AAC1C,YAAM,eAAe,MAAM,4BAAQ,UAAU,aAAa,EAAE;AAE5D,aAAO,YAAY,EAAE,aAAa,EAAE;AACpC,YAAM,uBAAuB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,mBAAa,QAAQ,CAAC,QAAQ;AAC5B,eAAO,oBAAoB,EAAE,UAAU,GAAG;AAAA,MAC5C,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACD,WAAS,wCAAwC,MAAM;AACrD,OAAG,uBAAuB,YAAY;AACpC,YAAM,KAAK,MAAM,4BAAQ,SAAS,QAAQ;AAC1C,YAAM,MAAM,MAAM,4BAAQ,MAAM,YAAY;AAC5C,aAAO,GAAG,EAAE,QAAQ,IAAI;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AACD,WAAS,yCAAyC,MAA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