-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.test.js
41 lines (36 loc) · 1.09 KB
/
solution.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
34
35
36
37
38
39
40
41
import { describe, it } from 'mocha'
import assert from 'assert'
import wrapping from './solution.mjs'
describe('Challenge #1: Automating Christmas gift wrapping!', () => {
it('should return an array', () => {
assert.equal(Array.isArray(wrapping([])), true)
})
it('should wrap gifts', () => {
const gifts = ['cat', 'game', 'socks']
const wrapped = wrapping(gifts)
const expected = [
'*****\n*cat*\n*****',
'******\n*game*\n******',
'*******\n*socks*\n*******'
]
assert.deepEqual(wrapped, expected)
})
it('should wrap a single gift', () => {
const gifts = ['midu']
const wrapped = wrapping(gifts)
const expected = ['******\n*midu*\n******']
assert.deepEqual(wrapped, expected)
})
it('should wrap a single letter gift', () => {
const gifts = ['a']
const wrapped = wrapping(gifts)
const expected = ['***\n*a*\n***']
assert.deepEqual(wrapped, expected)
})
it('should wrap an empty array', () => {
const gifts = []
const wrapped = wrapping(gifts)
const expected = []
assert.deepEqual(wrapped, expected)
})
})