-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
Copy pathProblem022.test.js
33 lines (28 loc) · 1.05 KB
/
Problem022.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { describe, it, expect } from 'vitest'
import { calculateTotalNameScore, getAlphabeticalValue } from './Problem022'
const path = require('path')
describe('getAlphabeticalValue', () => {
it('should return correct alphabetical value for COLIN', () => {
const name = 'COLIN'
const expectedValue = 3 + 15 + 12 + 9 + 14
expect(getAlphabeticalValue(name)).toBe(expectedValue)
})
it('should return correct alphabetical value for A', () => {
const name = 'A'
const expectedValue = 1
expect(getAlphabeticalValue(name)).toBe(expectedValue)
})
it('should return correct alphabetical value for Z', () => {
const name = 'Z'
const expectedValue = 26
expect(getAlphabeticalValue(name)).toBe(expectedValue)
})
})
describe('calculateTotalNameScore', () => {
it('should correctly calculate the total name score', async () => {
const namesFilePath = path.join(__dirname, 'Names.txt')
const result = await calculateTotalNameScore(namesFilePath)
const expectedScore = 4654143
expect(result).toBe(expectedScore)
})
})