Skip to content

Commit

Permalink
refactor: fixing linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drydenwilliams authored and mrchrisadams committed Mar 9, 2022
1 parent fd55085 commit 101232c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/sustainable-web-design.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

/**
* Sustainable Web Design
Expand All @@ -8,8 +8,8 @@
*
*
*/
const { fileSize } = require('./constants');
const { formatNumber } = require('./helpers');
const { fileSize } = require("./constants");
const { formatNumber } = require("./helpers");

// Taken from: https://sustainablewebdesign.org/calculating-digital-emissions/#:~:text=TWh/EB%20or-,0.81%20kWH/GB,-Carbon%20factor%20(global
const KWH_PER_GB = 0.81;
Expand Down
34 changes: 17 additions & 17 deletions src/sustainable-web-design.test.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
const fs = require('fs');
const path = require('path');
const SustainableWebDesign = require('./sustainable-web-design');
const fs = require("fs");
const path = require("path");
const SustainableWebDesign = require("./sustainable-web-design");

describe('sustainable web design model', () => {
describe("sustainable web design model", () => {
const swd = new SustainableWebDesign();
const averageWebsiteInBytes = 2257715.2;

describe('energyPerVisit', function () {
it('should return a number', () => {
expect(typeof swd.energyPerVisit(2257715.2)).toBe('number');
describe("energyPerVisit", function () {
it("should return a number", () => {
expect(typeof swd.energyPerVisit(2257715.2)).toBe("number");
});

it('should calculate the correct energy', () => {
it("should calculate the correct energy", () => {
expect(swd.energyPerVisit(2257715.2)).toBe(0.0004513362121582032);
});
});

describe('emissionsPerVisitInGrams', function () {
it('should calculate the correct co2 per visit', () => {
describe("emissionsPerVisitInGrams", function () {
it("should calculate the correct co2 per visit", () => {
const averageWebsiteInBytes = 2257715.2;
const energy = swd.energyPerVisit(averageWebsiteInBytes);
expect(swd.emissionsPerVisitInGrams(energy)).toEqual(0.2);
});

it('should accept a dynamic KwH value', () => {
it("should accept a dynamic KwH value", () => {
const averageWebsiteInBytes = 2257715.2;
const energy = swd.energyPerVisit(averageWebsiteInBytes);
expect(swd.emissionsPerVisitInGrams(energy, 245)).toEqual(0.11);
});
});

describe('annualEnergyInKwh', function () {
it('should calculate the correct energy in kWh', () => {
describe("annualEnergyInKwh", function () {
it("should calculate the correct energy in kWh", () => {
expect(swd.annualEnergyInKwh(averageWebsiteInBytes)).toBe(27092582400);
});
});

describe('annualEmissionsInGrams', function () {
it('should calculate the corrent energy in grams', () => {
describe("annualEmissionsInGrams", function () {
it("should calculate the corrent energy in grams", () => {
expect(swd.annualEmissionsInGrams(averageWebsiteInBytes)).toBe(
27092582400
);
});
});

describe('annualSegmentEnergy', function () {
it('should return the correct values', () => {
describe("annualSegmentEnergy", function () {
it("should return the correct values", () => {
expect(swd.annualSegmentEnergy(averageWebsiteInBytes)).toEqual({
consumerDeviceEnergy: 1174011.9,
dataCenterEnergy: 338657.28,
Expand Down

0 comments on commit 101232c

Please sign in to comment.