const assert = require('assert');
const { getAverageScore, getSquashedScore } = require('../lib/calculations');

describe('Calculations work', () => {
  describe('the average is calculated correctly', () => {
    it('should contain the expected average', async () => {
      const expectedResult = { 'lighthouse accessibility': 60, 'lighthouse performance': 51 };
      const input = [
        { 'lighthouse accessibility': 100, 'lighthouse performance': 52 },
        { 'lighthouse accessibility': 20, 'lighthouse performance': 50 },
      ];
      const actualResult = await getAverageScore(input);
      assert.deepEqual(expectedResult, actualResult);
    });

    it('should round the expected average correctly', async () => {
      const expectedResult = {
        'lighthouse accessibility': 99,
        'lighthouse performance': 99,
        'lighthouse progressive web app': 99,
        'lighthouse best practices': 99,
      };
      const input = [{
        'lighthouse accessibility': 100,
        'lighthouse performance': 100,
        'lighthouse progressive web app': 100,
        'lighthouse best practices': 100,
      }, {
        'lighthouse accessibility': 98.9,
        'lighthouse performance': 98.9,
        'lighthouse progressive web app': 98.9,
        'lighthouse best practices': 98.9,
      }];
      const actualResult = await getAverageScore(input);
      assert.deepEqual(expectedResult, actualResult);
    });
  });

  describe('the average is calculated correctly for squashed score', () => {
    it('should contain the expected squashed average', async () => {
      const expectedResult = { lighthouse: 60 };
      const input = [
        { 'lighthouse accessibility': 100, 'lighthouse performance': 65 },
        { 'lighthouse accessibility': 20, 'lighthouse performance': 55 },
      ];
      const actualResult = await getSquashedScore(input);
      assert.deepEqual(expectedResult, actualResult);
    });

    it('should round the expected squashed average correctly', async () => {
      const expectedResult = { lighthouse: 83 };
      const input = [{
        'lighthouse accessibility': 100,
        'lighthouse performance': 100,
        'lighthouse progressive web app': 55,
        'lighthouse best practices': 75,
      }];
      const actualResult = await getSquashedScore(input);
      assert.deepEqual(expectedResult, actualResult);
    });
  });
});

@@ -34,16 +34,35 @@
 %0Aconst %7B
+ percentageToColor,
  getAver
@@ -163,16 +163,883 @@
 () =%3E %7B%0A
+  describe('the colors are returned as expected', () =%3E %7B%0A    it('should return brightgreen for very high number', async () =%3E %7B%0A      assert.equal('brightgreen', await percentageToColor(97));%0A    %7D);%0A%0A    it('should return green for high number', async () =%3E %7B%0A      assert.equal('green', await percentageToColor(92));%0A    %7D);%0A%0A    it('should return yellowgreen for medium high number', async () =%3E %7B%0A      assert.equal('yellowgreen', await percentageToColor(85));%0A    %7D);%0A%0A    it('should return yellow for medium number', async () =%3E %7B%0A      assert.equal('yellow', await percentageToColor(62));%0A    %7D);%0A%0A    it('should return orange for low number', async () =%3E %7B%0A      assert.equal('orange', await percentageToColor(45));%0A    %7D);%0A%0A    it('should return red for very low number', async () =%3E %7B%0A      assert.equal('red', await percentageToColor(23));%0A    %7D);%0A  %7D);%0A%0A
   descri

Add tests for colors