-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.mjs
49 lines (43 loc) · 1.73 KB
/
index.test.mjs
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
42
43
44
45
46
47
48
49
import { expect } from 'chai';
import subject from './index.js';
import formatBytes from './formatBytes.js';
import formatCurrency from './formatCurrency.js';
import formatDuration from './formatDuration.js';
import formatNumber from './formatNumber.js';
import prefixWith from './prefixWith.js';
import suffixWith from './suffixWith.js';
describe('index', () => {
it('index exports modules', () => {
expect(subject.Maybe).to.be.a('function');
expect(subject.functionalUtil).to.be.a('object');
expect(subject.immutableOptics).to.be.a('object');
expect(subject.immutableUtil).to.be.a('object');
});
});
describe('Display', () => {
it('exports functions', () => {
expect(formatBytes).to.be.a("function");
expect(formatDuration()).to.be.a("function");
expect(formatNumber()).to.be.a("function");
expect(prefixWith()).to.be.a("function");
expect(suffixWith()).to.be.a("function");
})
it('formats positive numbers', () => {
expect(formatCurrency(123.45)).to.eq("$123.45");
expect(formatCurrency(123.456, "£")).to.eq("£123.46");
expect(formatCurrency(123.4567, "€")).to.eq("€123.46");
})
it('formats negative numbers', () => {
expect(formatCurrency(-123.45)).to.eq("$-123.45");
expect(formatCurrency(-123.456, "£")).to.eq("£-123.46");
expect(formatCurrency(-123.4567, "€")).to.eq("€-123.46");
})
it('creates a prefix function', () => {
const subject = prefixWith('Quantum');
expect(subject('Metric')).to.eq('QuantumMetric')
})
it("creates a suffix function", () => {
const subject = suffixWith("Quantum");
expect(subject("Metric")).to.eq("MetricQuantum");
});
})