Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ module.exports = {
'@typescript-eslint',
'license-header',
'jsdoc',
'jasmine',
'jest',
],
env: {
jasmine: true,
'jest/globals': true,
},
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.test.json',
Expand All @@ -17,6 +23,9 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jasmine/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
],
rules: {
// Automatic fixers
Expand Down Expand Up @@ -113,6 +122,13 @@ module.exports = {
MethodDefinition: true,
}
}],
'jest/no-jasmine-globals': 'off',
'jest/no-alias-methods': 'off',
'jest/no-conditional-expect': 'warn',
'jest/no-standalone-expect': 'warn',
'jest/no-test-prefixes': 'off',
'jest/prefer-to-be': 'warn',
'jest/prefer-to-have-length': 'warn',
},
overrides: [
{
Expand Down
95 changes: 67 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
"env-cmd": "^10.1.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jasmine": "^4.2.2",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-license-header": "^0.6.1",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/AbsoluteCellRange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ describe('AbsoluteCellRange', () => {
it('true in simplest case', () => {
const range = AbsoluteCellRange.fromCoordinates(0, 0, 0, 0, 0)

expect(range.addressInRange(adr('A1')))
expect(range.addressInRange(adr('A1'))).toBe(true)
})

it('false if different sheets', () => {
const range = AbsoluteCellRange.fromCoordinates(1, 0, 0, 0, 0)

expect(range.addressInRange(adr('A1')))
expect(range.addressInRange(adr('A1'))).toBe(false)
})
})

Expand Down
1 change: 1 addition & 0 deletions test/unit/_setupFiles/jest/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {toEqualError} from './toEqualError'
beforeAll(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line no-global-assign
spyOn = jest.spyOn
expect.extend(toEqualError)
})
11 changes: 0 additions & 11 deletions test/unit/arrays.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ describe('build from array', () => {
[undefined, ArrayVertex, ArrayVertex],
])
expect(engine.arrayMapping.arrayMapping.size).toEqual(4)
expect(engine.getSheetValues(0))
})

it('should REF last array', () => {
Expand All @@ -399,7 +398,6 @@ describe('build from array', () => {
[noSpace(), 2, 2, 1, 2],
])
expect(engine.arrayMapping.arrayMapping.size).toEqual(3)
expect(engine.getSheetValues(0))
})

it('array should work with different types of data', () => {
Expand Down Expand Up @@ -490,15 +488,6 @@ describe('column ranges', () => {
expect(engine.getCellValue(adr('A2'))).toEqualError(detailedError(ErrorType.SPILL, ErrorMessage.NoSpaceForArrayResult))
})

it('arithmetic should work for row range', () => {
const engine = HyperFormula.buildFromArray([
['=2*(2:2)', null],
[1, 2],
], {useArrayArithmetic: true})

expect(engine.getSheetValues(0)).toEqual([[2, 4], [1, 2]])
})

it('arithmetic for shifted row range -- error', () => {
const engine = HyperFormula.buildFromArray([
[null, '=2*(2:2)'],
Expand Down
6 changes: 3 additions & 3 deletions test/unit/column-index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('ColumnIndex#removeColumns', () => {
expect(index.getValueIndex(0, 0, 1).index).toEqual([])
})

it('should remove multiple columns in the middle ', () => {
it('should remove multiple columns in the middle', () => {
const index = buildEmptyIndex(transformingService, new Config(), statistics)
index.add(1, adr('A1'))
index.add(2, adr('B1'))
Expand All @@ -311,7 +311,7 @@ describe('ColumnIndex#removeColumns', () => {
expect(index.getValueIndex(0, 3, 4).index).toEqual([])
})

it('should remove columns only in one sheet ', () => {
it('should remove columns only in one sheet', () => {
const index = buildEmptyIndex(transformingService, new Config(), statistics)
index.add(1, adr('A1', 0))
index.add(1, adr('A1', 1))
Expand Down Expand Up @@ -455,7 +455,7 @@ describe('ColumnIndex#removeRows', () => {
expect(index.getValueIndex(0, 0, 1).index).toEqual([])
})

it('should remove rows in the middle ', () => {
it('should remove rows in the middle', () => {
const statistics = new Statistics()
const transformingService = new LazilyTransformingAstService(statistics)
const index = buildEmptyIndex(transformingService, new Config(), statistics)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cruds/adding-columns-dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('Adding column, fixing ranges', () => {
]))
})

it('it should insert new cell with edge to only one range at right', () => {
it('should insert new cell with edge to only one range at right', () => {
const engine = HyperFormula.buildFromArray([
['1', '2', /* */ '3', '4'],
['=SUM(A1:A1)', '=SUM(A1:B1)', /* */ '=SUM(A1:C1)', '=SUM(A1:D1)'],
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cruds/adding-row-dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe('Adding row, ranges', () => {
]))
})

it('it should insert new cell with edge to all ranges below', () => {
it('should insert new cell with edge to all ranges below', () => {
const engine = HyperFormula.buildFromArray([
['1', '=SUM(A1:A1)'],
['2', '=SUM(A1:A2)'],
Expand All @@ -358,7 +358,7 @@ describe('Adding row, ranges', () => {
expect(engine.graph.adjacentNodesCount(a2)).toBe(1)
})

it('it should insert new cell with edge to only one range below, shifted by 1', () => {
it('should insert new cell with edge to only one range below, shifted by 1', () => {
const engine = HyperFormula.buildFromArray([
['1', null],
['2', '=SUM(A1:A1)'],
Expand Down
10 changes: 4 additions & 6 deletions test/unit/cruds/change-cell-content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('changing cell content', () => {
expect(engine.getCellValue(adr('B1'))).toBe(42)
})

it('set nothing again', () => {
it('set nothing again (2)', () => {
const sheet = [
[null],
]
Expand Down Expand Up @@ -486,15 +486,15 @@ describe('changing cell content', () => {
expectArrayWithSameContent(changes.map((change) => change.newValue), [2, 10, 12, 18, 22])
})

it('update empty cell to parsing error ', () => {
it('update empty cell to parsing error', () => {
const engine = HyperFormula.buildFromArray([])

engine.setCellContents(adr('A1'), '=SUM(')

expect(engine.getCellValue(adr('A1'))).toEqualError(detailedError(ErrorType.ERROR, ErrorMessage.ParseError))
})

it('update dependency value cell to parsing error ', () => {
it('update dependency value cell to parsing error', () => {
const sheet = [
['1', '=SUM(A1)'],
]
Expand All @@ -509,7 +509,7 @@ describe('changing cell content', () => {
expect(engine.getCellValue(adr('B1'))).toEqualError(detailedError(ErrorType.ERROR, ErrorMessage.ParseError))
})

it('update formula cell to parsing error ', () => {
it('update formula cell to parsing error', () => {
const sheet = [
['1', '=SUM(A1)'],
]
Expand Down Expand Up @@ -907,7 +907,6 @@ describe('arrays', () => {
[undefined, ArrayVertex, ArrayVertex],
])
expect(engine.arrayMapping.arrayMapping.size).toEqual(4)
expect(engine.getSheetValues(0))
})

it('should REF last array', () => {
Expand All @@ -931,7 +930,6 @@ describe('arrays', () => {
[noSpace(), 2, 2, 1, 2],
])
expect(engine.arrayMapping.arrayMapping.size).toEqual(3)
expect(engine.getSheetValues(0))
})

it('should make existing array REF and change cell content to simple value', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cruds/copy-paste.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ describe('Copy - paste integration', () => {
const range = engine.rangeMapping.fetchRange(rowStart(2), rowEnd(3))
const a2 = engine.addressMapping.fetchCell(adr('A2'))
const a3 = engine.addressMapping.fetchCell(adr('A3'))
expect(engine.graph.existsEdge(a2, range))
expect(engine.graph.existsEdge(a3, range))
expect(engine.graph.existsEdge(a2, range)).toBe(true)
expect(engine.graph.existsEdge(a3, range)).toBe(true)
expect(engine.getCellValue(adr('A1'))).toEqual(4)
})

Expand Down
Loading
Loading