| 1 |
import { expect } from 'chai'; |
| 2 |
import { deepCopy, convert_dates } from '../utils'; |
| 3 |
|
| 4 |
describe('utils >', () => { |
| 5 |
it('convert dates', async () => { |
| 6 |
const dates = ['2005-02-25', '2005-02-26', '2005-02-27'].map( |
| 7 |
(x) => new Date(x) |
| 8 |
); |
| 9 |
const numbers = [1109289600000, 1109376000000, 1109462400000]; |
| 10 |
expect(Array.from(convert_dates(dates))).to.deep.equal(numbers); |
| 11 |
expect([Array.from(convert_dates([dates])[0])]).to.deep.equal([numbers]); |
| 12 |
expect(Array.from(convert_dates(numbers))).to.deep.equal(numbers); |
| 13 |
expect(Array.from(convert_dates([numbers, numbers]))).to.deep.equal([ |
| 14 |
numbers, |
| 15 |
numbers, |
| 16 |
]); |
| 17 |
}); |
| 18 |
|
| 19 |
it('deepCopy', () => { |
| 20 |
const ar = new Float64Array([0, 0.5]); |
| 21 |
expect(Array.from(deepCopy(ar))).to.deep.equal(Array.from(ar)); |
| 22 |
expect(Array.from(deepCopy([ar])[0])).to.deep.equal(Array.from(ar)); |
| 23 |
expect(Array.from(deepCopy({ ar: ar }).ar)).to.deep.equal(Array.from(ar)); |
| 24 |
}); |
| 25 |
}); |