Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swistak35 committed Feb 20, 2020
1 parent e036b40 commit c4a1ee1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions test/CellValueExporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import {ErrorType} from '../src/Cell'
import {Exporter} from '../src/CellValue'
import {enGB, plPL} from '../src/i18n'
import {detailedError} from './testUtils'
import {NamedExpressions} from '../src/NamedExpressions'

const namedExpressionsMock = {} as NamedExpressions

describe( 'rounding', () => {
it( 'no rounding', () =>{
const config = new Config({ smartRounding : false})
const cellValueExporter = new Exporter(config)
const config = new Config({ smartRounding : false })
const cellValueExporter = new Exporter(config, namedExpressionsMock)
expect(cellValueExporter.exportValue(1.000000000000001)).toBe(1.000000000000001)
expect(cellValueExporter.exportValue(-1.000000000000001)).toBe(-1.000000000000001)
expect(cellValueExporter.exportValue(0.000000000000001)).toBe(0.000000000000001)
Expand All @@ -21,7 +24,7 @@ describe( 'rounding', () => {

it( 'with rounding', () =>{
const config = new Config()
const cellValueExporter = new Exporter(config)
const cellValueExporter = new Exporter(config, namedExpressionsMock)
expect(cellValueExporter.exportValue(1.0000000000001)).toBe(1.0000000000001)
expect(cellValueExporter.exportValue(-1.0000000000001)).toBe(-1.0000000000001)
expect(cellValueExporter.exportValue(1.000000000000001)).toBe(1)
Expand All @@ -39,7 +42,7 @@ describe( 'rounding', () => {
describe('detailed error', () => {
it('should return detailed errors', () => {
const config = new Config({ language: enGB })
const cellValueExporter = new Exporter(config)
const cellValueExporter = new Exporter(config, namedExpressionsMock)

const error = cellValueExporter.exportValue(new CellError(ErrorType.VALUE)) as DetailedCellError
expect(error).toEqual(detailedError(ErrorType.VALUE))
Expand All @@ -48,7 +51,7 @@ describe('detailed error', () => {

it('should return detailed errors with translation', () => {
const config = new Config({ language: plPL })
const cellValueExporter = new Exporter(config)
const cellValueExporter = new Exporter(config, namedExpressionsMock)

const error = cellValueExporter.exportValue(new CellError(ErrorType.VALUE)) as DetailedCellError
expect(error).toEqual(detailedError(ErrorType.VALUE, config))
Expand Down
6 changes: 3 additions & 3 deletions test/cruds/change-cell-content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ describe('changing cell content', () => {
const changes = engine.setCellContents(adr('A1'), '2')

expect(changes.length).toBe(5)
expect(changes.map((change) => change.value)).toEqual(expect.arrayContaining([2, 10, 12, 18, 22]))
expect(changes.map((change) => change.newValue)).toEqual(expect.arrayContaining([2, 10, 12, 18, 22]))
})

it('returns change of numeric matrix', () => {
Expand Down Expand Up @@ -546,7 +546,7 @@ describe('change multiple cells contents', () => {
const changes = engine.setCellContents(adr('A1'), [['7', '8'], ['9', '10']])

expect(changes.length).toEqual(4)
expect(changes.map((change) => change.value)).toEqual(expect.arrayContaining([7, 8, 9, 10]))
expect(changes.map((change) => change.newValue)).toEqual(expect.arrayContaining([7, 8, 9, 10]))
})

it('returns changes of mutliple values dependent formulas', () => {
Expand All @@ -561,7 +561,7 @@ describe('change multiple cells contents', () => {
const changes = engine.setCellContents(adr('A1'), [['7', '8'], ['9', '10']])

expect(changes.length).toEqual(6)
expect(changes.map((change) => change.value)).toEqual(expect.arrayContaining([7, 8, 9, 10, 15, 18]))
expect(changes.map((change) => change.newValue)).toEqual(expect.arrayContaining([7, 8, 9, 10, 15, 18]))
})
})

Expand Down

0 comments on commit c4a1ee1

Please sign in to comment.