From 8372c0cd7111fd8f1ea094ff5fe1426b167786a1 Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:13:21 +0200 Subject: [PATCH 1/6] Add license key requirements Adds license key validity to the HF. Replace environment variables to literal values declared in the hf.config.js file. Now, for all modules the global values are available. Moves testConfig.ts file to global config which Jest provides. --- jest.config.js | 7 +- package.json | 1 + src/BuildEngineFactory.ts | 3 + src/Config.ts | 53 ++-- src/HyperFormula.ts | 245 +++++++++--------- src/helpers/licenseKey.ts | 65 +++++ test/AbsoluteCellRange.spec.ts | 1 - test/_setupFiles/bootstrap.ts | 26 ++ test/_setupFiles/globalSetup.ts | 14 + test/build-engine.spec.ts | 1 - test/computation-suspension.spec.ts | 1 - .../cruds/adding-columns-dependencies.spec.ts | 2 +- test/cruds/adding-columns.spec.ts | 1 - test/cruds/adding-row-dependencies.spec.ts | 3 +- test/cruds/adding-row.spec.ts | 1 - test/cruds/adding-sheet.spec.ts | 1 - test/cruds/batch-operations.spec.ts | 1 - test/cruds/change-cell-content.spec.ts | 1 - test/cruds/copy-paste.spec.ts | 1 - test/cruds/cut-paste.spec.ts | 1 - test/cruds/move-cells.spec.ts | 1 - test/cruds/removing-columns.spec.ts | 1 - test/cruds/removing-rows.spec.ts | 1 - test/cruds/removing-sheet.spec.ts | 1 - test/date.spec.ts | 1 - test/disable-matrix-optimizations.spec.ts | 1 - test/emitting-events.spec.ts | 2 +- test/engine.spec.ts | 1 - test/extending-plugins.spec.ts | 1 - test/format/format-interpreter.spec.ts | 1 - test/graph-builder.spec.ts | 1 - test/helpers/licenseKey/agpl-v3.spec.ts | 18 ++ .../licenseKey/invalid-agpl-version.spec.ts | 18 ++ test/helpers/licenseKey/invalid-key.spec.ts | 18 ++ test/helpers/licenseKey/missing-key.spec.ts | 18 ++ .../licenseKey/non-commercial-key.spec.ts | 18 ++ test/i18n.spec.ts | 1 - test/interpreter.spec.ts | 1 - test/interpreter/boolean-operators.spec.ts | 2 - test/interpreter/coercions.spec.ts | 1 - .../criterion-computations.spec.ts | 1 - test/interpreter/date-arithmetic.spec.ts | 1 - test/interpreter/error-literals.spec.ts | 3 +- test/interpreter/function-abs.spec.ts | 1 - test/interpreter/function-acos.spec.ts | 1 - test/interpreter/function-and.spec.ts | 1 - test/interpreter/function-asin.spec.ts | 1 - test/interpreter/function-atan.spec.ts | 1 - test/interpreter/function-atan2.spec.ts | 1 - test/interpreter/function-average.spec.ts | 1 - test/interpreter/function-averagea.spec.ts | 1 - test/interpreter/function-averageif.spec.ts | 1 - test/interpreter/function-columns.spec.ts | 1 - test/interpreter/function-concatenate.spec.ts | 1 - test/interpreter/function-correl.spec.ts | 1 - test/interpreter/function-cos.spec.ts | 1 - test/interpreter/function-cot.spec.ts | 1 - test/interpreter/function-count.spec.ts | 1 - test/interpreter/function-counta.spec.ts | 1 - test/interpreter/function-countblank.spec.ts | 1 - test/interpreter/function-countif.spec.ts | 1 - test/interpreter/function-countifs.spec.ts | 1 - test/interpreter/function-countunique.spec.ts | 1 - test/interpreter/function-date.spec.ts | 1 - test/interpreter/function-day.spec.ts | 1 - test/interpreter/function-degrees.spec.ts | 1 - test/interpreter/function-eomonth.spec.ts | 1 - test/interpreter/function-even.spec.ts | 1 - test/interpreter/function-exp.spec.ts | 1 - test/interpreter/function-false.spec.ts | 1 - test/interpreter/function-if.spec.ts | 1 - test/interpreter/function-index.spec.ts | 1 - test/interpreter/function-int.spec.ts | 1 - test/interpreter/function-isblank.spec.ts | 1 - test/interpreter/function-iserror.spec.ts | 1 - test/interpreter/function-iseven.spec.ts | 1 - test/interpreter/function-islogical.spec.ts | 1 - test/interpreter/function-isnontext.spec.ts | 1 - test/interpreter/function-isnumber.spec.ts | 1 - test/interpreter/function-isodd.spec.ts | 1 - test/interpreter/function-istext.spec.ts | 1 - test/interpreter/function-ln.spec.ts | 1 - test/interpreter/function-log.spec.ts | 1 - test/interpreter/function-log10.spec.ts | 1 - test/interpreter/function-match.spec.ts | 1 - test/interpreter/function-max.spec.ts | 1 - test/interpreter/function-maxa.spec.ts | 1 - test/interpreter/function-median.spec.ts | 1 - test/interpreter/function-min.spec.ts | 1 - test/interpreter/function-mina.spec.ts | 1 - test/interpreter/function-month.spec.ts | 1 - test/interpreter/function-not.spec.ts | 1 - test/interpreter/function-odd.spec.ts | 1 - test/interpreter/function-or.spec.ts | 1 - test/interpreter/function-radians.spec.ts | 1 - test/interpreter/function-rand.spec.ts | 1 - test/interpreter/function-round.spec.ts | 1 - test/interpreter/function-rounddown.spec.ts | 1 - test/interpreter/function-roundup.spec.ts | 1 - test/interpreter/function-rows.spec.ts | 1 - test/interpreter/function-sin.spec.ts | 1 - test/interpreter/function-split.spec.ts | 1 - test/interpreter/function-sum.spec.ts | 1 - test/interpreter/function-sumif.spec.ts | 1 - test/interpreter/function-sumproduct.spec.ts | 1 - test/interpreter/function-sumsq.spec.ts | 1 - test/interpreter/function-tan.spec.ts | 1 - test/interpreter/function-text.spec.ts | 1 - test/interpreter/function-true.spec.ts | 1 - test/interpreter/function-trunc.spec.ts | 1 - test/interpreter/function-vlookup.spec.ts | 2 - test/interpreter/function-xor.spec.ts | 1 - test/interpreter/function-year.spec.ts | 1 - test/interpreter/matrix-plugin.spec.ts | 2 - test/interpreter/number-literals.spec.ts | 5 +- test/interpreter/operator-concatenate.spec.ts | 1 - test/interpreter/operator-division.spec.ts | 1 - test/interpreter/operator-minus.spec.ts | 1 - test/interpreter/operator-percent.spec.ts | 1 - test/interpreter/operator-plus.spec.ts | 1 - test/interpreter/operator-power.spec.ts | 1 - test/interpreter/operator-times.spec.ts | 1 - test/interpreter/operator-unary-minus.spec.ts | 1 - test/interpreter/operator-unary-plus.spec.ts | 1 - test/interpreter/precision.spec.ts | 1 - test/matrix-size-check.spec.ts | 1 - test/named-expressions.spec.ts | 1 - test/parser/boolean-operators.spec.ts | 1 - test/parser/concatenate-operator.spec.ts | 1 - test/parser/parser-caching.spec.ts | 1 - test/parser/parser.spec.ts | 1 - test/parser/percent-operator.spec.ts | 1 - test/parser/range-offset.spec.ts | 1 - .../volatile-functions-detection.spec.ts | 1 - test/square-plugin-example.spec.ts | 1 - test/temporary-formulas.spec.ts | 1 - test/testConfig.ts | 19 -- test/undo-redo.spec.ts | 1 - test/volatile-functions.spec.ts | 1 - 139 files changed, 365 insertions(+), 296 deletions(-) create mode 100644 src/helpers/licenseKey.ts create mode 100644 test/_setupFiles/bootstrap.ts create mode 100644 test/_setupFiles/globalSetup.ts create mode 100644 test/helpers/licenseKey/agpl-v3.spec.ts create mode 100644 test/helpers/licenseKey/invalid-agpl-version.spec.ts create mode 100644 test/helpers/licenseKey/invalid-key.spec.ts create mode 100644 test/helpers/licenseKey/missing-key.spec.ts create mode 100644 test/helpers/licenseKey/non-commercial-key.spec.ts delete mode 100644 test/testConfig.ts diff --git a/jest.config.js b/jest.config.js index edbc6e1b9f..3139632ca9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -49,7 +49,7 @@ module.exports = { // forceCoverageMatch: [], // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: null, + globalSetup: '/test/_setupFiles/globalSetup.ts', // A path to a module which exports an async function that is triggered once after all test suites // globalTeardown: null, @@ -120,6 +120,11 @@ module.exports = { // The paths to modules that run some code to configure or set up the testing environment before each test // setupFiles: [], + // The paths to modules that run some code to configure or set up the testing environment after each test + setupFilesAfterEnv: [ + '/test/_setupFiles/bootstrap.ts' + ], + // The path to a module that runs some code to configure or set up the testing framework before each test // setupTestFrameworkScriptFile: null, diff --git a/package.json b/package.json index 74c356021b..0ee3fc4986 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "compile": "tsc", "coverage": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --coverage", "test": "cross-env NODE_ICU_DATA=node_modules/full-icu jest", + "test.watch": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch", "test:ci": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --maxWorkers=2", "docs:build": "typedoc --options .typedoc.js", "docs:serve": "serve doc -p 5005", diff --git a/src/BuildEngineFactory.ts b/src/BuildEngineFactory.ts index d07876c558..6390b2c7ed 100644 --- a/src/BuildEngineFactory.ts +++ b/src/BuildEngineFactory.ts @@ -20,6 +20,7 @@ import {buildLexerConfig, ParserWithCaching, Unparser} from './parser' import {Serialization} from './Serialization' import {EmptyStatistics, Statistics, StatType} from './statistics' import {UndoRedo} from './UndoRedo' +import {checkLicenseKeyValidity} from './helpers/licenseKey' export type EngineState = { config: Config, @@ -40,6 +41,8 @@ export type EngineState = { export class BuildEngineFactory { private static buildEngine(config: Config, sheets: Sheets = {}, stats: Statistics = config.useStats ? new Statistics() : new EmptyStatistics()): EngineState { + checkLicenseKeyValidity(config.licenseKey) + stats.start(StatType.BUILD_ENGINE_TOTAL) const undoRedo: UndoRedo = new UndoRedo() diff --git a/src/Config.ts b/src/Config.ts index 8de05a9219..0c571bf462 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -57,7 +57,7 @@ export interface ConfigParams { * Applies to comparison operators only. * * @default false - * + * * @category String */ accentSensitive: boolean, @@ -66,7 +66,7 @@ export interface ConfigParams { * Applies to comparison operators only. * * @default false - * + * * @category String */ caseSensitive: boolean, @@ -75,7 +75,7 @@ export interface ConfigParams { * When set to `false` uses the locale's default. * * @default 'lower' - * + * * @category String */ caseFirst: 'upper' | 'lower' | 'false', @@ -96,7 +96,7 @@ export interface ConfigParams { * Any order of YY, MM, DD is accepted as a date, and YY can be replaced with YYYY. * * @default ['MM/DD/YYYY', 'MM/DD/YY'] - * + * * @category DateTime */ dateFormats: string[], @@ -114,7 +114,7 @@ export interface ConfigParams { * A separator character used to separate arguments of procedures in formulas. Must be different from [[decimalSeparator]] and [[thousandSeparator]]. * * @default ',' - * + * * @category Syntax */ functionArgSeparator: string, @@ -123,7 +123,7 @@ export interface ConfigParams { * Can be either '.' or ',' and must be different from [[thousandSeparator]] and [[functionArgSeparator]]. * * @default '.' - * + * * @category Number */ decimalSeparator: '.' | ',', @@ -133,12 +133,18 @@ export interface ConfigParams { * @default 'enGB' */ language: string, + /** + * License key for commercial version of HyperFormula. + * + * @default '' + */ + licenseKey: string, /** * A thousand separator used for parsing numeric literals. * Can be either empty, ',' or ' ' and must be different from [[decimalSeparator]] and [[functionArgSeparator]]. * * @default '' - * + * * @category Number */ thousandSeparator: '' | ',' | ' ' | '.', @@ -146,7 +152,7 @@ export interface ConfigParams { * A list of additional function plugins to use by formula interpreter. * * @default [] - * + * * @category Syntax */ // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -157,7 +163,7 @@ export interface ConfigParams { * Other values should be used for debugging purposes only. More info can be found in GPU.js documentation. * * @default 'gpu' - * + * * @category Engine */ gpuMode: GPUMode, @@ -175,7 +181,7 @@ export interface ConfigParams { * Set to `true` for compatibility with Lotus 1-2-3 and Excel. See [[nullDate]] for complete solution. * * @default false - * + * * @category DateTime */ leapYear1900: boolean, @@ -193,7 +199,7 @@ export interface ConfigParams { * Some CRUD operations may break numeric matrices into individual vertices if needed. * * @default true - * + * * @category Engine */ matrixDetection: boolean, @@ -201,8 +207,8 @@ export interface ConfigParams { * Specifies how many cells an area must have in order to be treated as a matrix. Relevant only if [[matrixDetection]] is set to `true`. * * @default 100 - * - * @category Engine + * + * @category Engine */ matrixDetectionThreshold: number, /** @@ -210,7 +216,7 @@ export interface ConfigParams { * If `xx <= nullYear` its latter, otherwise its former. * * @default 30 - * + * * @category DateTime */ nullYear: number, @@ -232,8 +238,8 @@ export interface ConfigParams { * for `c=a+b` or `c=a-b`, if `abs(c) <= precisionEpsilon * abs(a)`, then `c` is set to `0` * * @default 1e-13 - * - * @category Number + * + * @category Number */ precisionEpsilon: number, /** @@ -241,7 +247,7 @@ export interface ConfigParams { * Numerical outputs are rounded to `precisionRounding` many digits after the decimal. * * @default 14 - * + * * @category Number */ precisionRounding: number, @@ -258,7 +264,7 @@ export interface ConfigParams { * If `false`, no rounding happens, and numbers are equal if and only if they are truly identical value (see: [[precisionEpsilon]]). * * @default true - * + * * @category Number */ smartRounding: boolean, @@ -269,7 +275,7 @@ export interface ConfigParams { * In some scenarios column index may fall back to binary search despite this flag. * * @default false - * + * * @category Engine */ useColumnIndex: boolean, @@ -287,7 +293,7 @@ export interface ConfigParams { * Used by VLOOKUP and MATCH functions. * * @default 20 - * + * * @category Engine */ vlookupThreshold: number, @@ -318,6 +324,7 @@ export class Config implements ConfigParams, ParserConfig { decimalSeparator: '.', thousandSeparator: '', language: 'enGB', + licenseKey: '', functionPlugins: [], gpuMode: 'gpu', leapYear1900: false, @@ -393,6 +400,8 @@ export class Config implements ConfigParams, ParserConfig { /** @inheritDoc */ public readonly language: string /** @inheritDoc */ + public readonly licenseKey: string + /** @inheritDoc */ // eslint-disable-next-line @typescript-eslint/no-explicit-any public readonly functionPlugins: any[] /** @inheritDoc */ @@ -429,7 +438,7 @@ export class Config implements ConfigParams, ParserConfig { public readonly nullDate: SimpleDate /** * Built automatically based on translation package. - * + * * @internal */ public readonly errorMapping: Record @@ -452,6 +461,7 @@ export class Config implements ConfigParams, ParserConfig { decimalSeparator, thousandSeparator, language, + licenseKey, functionPlugins, gpuMode, ignorePunctuation, @@ -481,6 +491,7 @@ export class Config implements ConfigParams, ParserConfig { this.functionArgSeparator = this.valueFromParam(functionArgSeparator, 'string', 'functionArgSeparator') this.decimalSeparator = this.valueFromParam(decimalSeparator, ['.', ','], 'decimalSeparator') this.language = this.valueFromParam(language, 'string', 'language') + this.licenseKey = this.valueFromParam(licenseKey, 'string', 'licenseKey') this.thousandSeparator = this.valueFromParam(thousandSeparator, ['', ',', ' ', '.'], 'thousandSeparator') this.localeLang = this.valueFromParam(localeLang, 'string', 'localeLang') this.functionPlugins = functionPlugins ?? Config.defaultConfig.functionPlugins diff --git a/src/HyperFormula.ts b/src/HyperFormula.ts index 1f140b1cba..ffcb38ecbb 100644 --- a/src/HyperFormula.ts +++ b/src/HyperFormula.ts @@ -47,16 +47,16 @@ export type Index = [number, number] /** * This is a class for creating HyperFormula instance, all the following public methods * ale related to this class. - * + * * The instance can be created only by calling one of the static methods * `buildFromArray`, `buildFromSheets` or `buildEmpty` and should be disposed of with * `destroy` method when it's no longer needed to free the resources. - * + * * The instance can be seen as a workbook where worksheets can be created and * manipulated. They are organized within a widely know structure of columns and rows * which can be manipulated as well. The smallest possible data unit are the cells, which * may contain simple values or formulas to be calculated. - * + * * All CRUD methods are called directly on HyperFormula instance and will trigger * corresponding lifecycle events. The events are marked accordingly, as well as thrown * errors so they can be correctly handled. @@ -66,17 +66,17 @@ export class HyperFormula implements TypedEmitter { /** * Version of the HyperFormula. */ - public static version = (process.env.HT_VERSION ?? '') + public static version = process.env.HT_VERSION /** * Latest build date. */ - public static buildDate = (process.env.HT_BUILD_DATE ?? '') + public static buildDate = process.env.HT_BUILD_DATE /** * Calls the `graph` method on the dependency graph. * Allows to execute `graph` directly without a need to refer to `dependencyGraph`. - * + * * @internal */ public get graph(): Graph { @@ -86,7 +86,7 @@ export class HyperFormula implements TypedEmitter { /** * Calls the `rangeMapping` method on the dependency graph. * Allows to execute `rangeMapping` directly without a need to refer to `dependencyGraph`. - * + * * @internal */ public get rangeMapping(): RangeMapping { @@ -96,7 +96,7 @@ export class HyperFormula implements TypedEmitter { /** * Calls the `matrixMapping` method on the dependency graph. * Allows to execute `matrixMapping` directly without a need to refer to `dependencyGraph`. - * + * * @internal */ public get matrixMapping(): MatrixMapping { @@ -106,7 +106,7 @@ export class HyperFormula implements TypedEmitter { /** * Calls the `sheetMapping` method on the dependency graph. * Allows to execute `sheetMapping` directly without a need to refer to `dependencyGraph`. - * + * * @internal */ public get sheetMapping(): SheetMapping { @@ -116,7 +116,7 @@ export class HyperFormula implements TypedEmitter { /** * Calls the `addressMapping` method on the dependency graph. * Allows to execute `addressMapping` directly without a need to refer to `dependencyGraph`. - * + * * @internal */ public get addressMapping(): AddressMapping { @@ -276,12 +276,12 @@ export class HyperFormula implements TypedEmitter { /** * Returns the cell value of a given address. * Applies rounding and post-processing. - * + * * @param {SimpleCellAddress} address - cell coordinates - * + * * @throws Throws an error if the sheet ID is unknown * @throws [[EvaluationSuspendedError]] when the evaluation is suspended - * + * * @category Cell */ public getCellValue(address: SimpleCellAddress): CellValue { @@ -298,7 +298,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns a normalized formula string from the cell of a given address or `undefined` for an address that does not exist and empty values. * Unparses AST. - * + * * @param {SimpleCellAddress} address - cell coordinates * * @category Cell @@ -325,10 +325,10 @@ export class HyperFormula implements TypedEmitter { /** * Returns an array of arrays of [[CellValue]] with values of all cells from [[Sheet]]. * Applies rounding and post-processing. - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws [[EvaluationSuspendedError]] when the evaluation is suspended - * + * * @param {number} sheet - sheet ID number * * @category Sheet @@ -343,7 +343,7 @@ export class HyperFormula implements TypedEmitter { * Unparses AST. * * @param {SimpleCellAddress} sheet - sheet ID number - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * * @category Sheet @@ -357,7 +357,7 @@ export class HyperFormula implements TypedEmitter { * Unparses AST. Applies post-processing. * * @param {SimpleCellAddress} sheet - sheet ID number - * + * * @throws [[EvaluationSuspendedError]] when the evaluation is suspended * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @@ -372,7 +372,7 @@ export class HyperFormula implements TypedEmitter { * Returns a map containing dimensions of all sheets for the engine instance represented as a key-value pairs where keys are sheet IDs and dimensions are returned as numbers, width and height respectively. * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist - * + * * @category Sheet */ public getAllSheetsDimensions(): Record { @@ -382,7 +382,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns dimensions of a specified sheet. * The sheet dimensions is represented with numbers: width and height. - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * * @param {number} sheet - sheet ID number @@ -398,7 +398,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns values of all sheets in a form of an object which property keys are strings and values are arrays of arrays of [[CellValue]] - * + * * @throws [[EvaluationSuspendedError]] when the evaluation is suspended * * @category Sheet @@ -419,9 +419,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns formulas or values of all sheets in a form of an object which property keys are strings and values are arrays of arrays of [[CellValue]] - * + * * @throws [[EvaluationSuspendedError]] when the evaluation is suspended - * + * * @category Sheet */ public getAllSheetsSerialized(): Record { @@ -490,13 +490,13 @@ export class HyperFormula implements TypedEmitter { /** * Undo the previous operation. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NoOperationToUndo]] when there is no operation running that can be undone - * + * * @category UndoRedo */ public undo() { @@ -509,7 +509,7 @@ export class HyperFormula implements TypedEmitter { /** * Checks if there is at least one operation that can be undone. - * + * * @category UndoRedo */ public isThereSomethingToUndo() { @@ -520,11 +520,11 @@ export class HyperFormula implements TypedEmitter { * Returns information whether it is possible to change the content in a rectangular area bounded by the box. * If returns `true`, doing [[setCellContents]] operation won't throw any errors. * Returns `false` if the operation might be disrupted and causes side-effects by the fact that there is a matrix inside selected cells, the address is invalid or the sheet does not exist - * + * * @param {SimpleCellAddress} address - cell coordinates (top left corner) * @param {number} width - width of the box * @param {number} height - height of the box - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws [[InvalidAddressError]] when the given address is invalid * @throws an error when there is a matrix inside selected cells @@ -546,14 +546,14 @@ export class HyperFormula implements TypedEmitter { /** * Sets the content for a block of cells of a given coordinates. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @param {SimpleCellAddress} topLeftCornerAddress - top left corner of block of cells * @param {(RawCellContent[][]|RawCellContent)} cellContents - array with content - * + * * @fires [[valuesUpdated]] - * + * * @throws [[InvalidArgumentsError]] when the value is not an array of arrays or a raw cell value * @throws an error when it is an attempt to set cells content inside matrices during batch operation * @@ -569,10 +569,10 @@ export class HyperFormula implements TypedEmitter { * Checks against particular rules to ascertain that addRows can be called. * If returns `true`, doing [[addRows]] operation won't throw any errors. * Returns `false` if the operation might be disrupted and causes side-effects by the fact that there is a matrix inside the selected rows. - * + * * @param {number} sheet - sheet ID in which rows will be added * @param {Index[]} indexes - non-contiguous indexes with format [row, amount], where row is a row number above which the rows will be added - * + * * @category Row */ public isItPossibleToAddRows(sheet: number, ...indexes: Index[]): boolean { @@ -588,14 +588,14 @@ export class HyperFormula implements TypedEmitter { /** * Adds multiple rows into a specified position in a given sheet. * Does nothing if rows are outside of effective sheet size. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - sheet ID in which rows will be added * @param {Index[]} indexes - non-contiguous indexes with format [row, amount], where row is a row number above which the rows will be added - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws an error if the selected position has matrix inside * @@ -630,18 +630,18 @@ export class HyperFormula implements TypedEmitter { /** * Removes multiple rows from a specified position in a given sheet. * Does nothing if rows are outside of the effective sheet size. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - sheet ID from which rows will be removed * @param {Index[]} indexes - non-contiguous indexes with format: [row, amount] - * + * * @fires [[valuesUpdated]] - * + * * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws an error when the selected position has matrix inside - * + * * @category Row */ public removeRows(sheet: number, ...indexes: Index[]): ExportedChange[] { @@ -673,18 +673,18 @@ export class HyperFormula implements TypedEmitter { /** * Adds multiple columns into a specified position in a given sheet. * Does nothing if the columns are outside of the effective sheet size. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - sheet ID in which columns will be added * @param {Index[]} indexes - non-contiguous indexes with format: [column, amount], where column is a column number from which new columns will be added - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws an error when the selected position has matrix inside - * + * * @category Column */ public addColumns(sheet: number, ...indexes: Index[]): ExportedChange[] { @@ -716,14 +716,14 @@ export class HyperFormula implements TypedEmitter { /** * Removes multiple columns from a specified position in a given sheet. * Does nothing if columns are outside of the effective sheet size. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - sheet ID from which columns will be removed * @param {Index[]} indexes - non-contiguous indexes with format: [column, amount] - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws an error when the selected position has matrix inside @@ -759,16 +759,16 @@ export class HyperFormula implements TypedEmitter { /** * Moves the content of a cell block from source to the target location. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {SimpleCellAddress} sourceLeftCorner - address of the upper left corner of a moved block * @param {number} width - width of the cell block that is being moved * @param {number} height - height of the cell block that is being moved * @param {SimpleCellAddress} destinationLeftCorner - upper left address of the target cell block - * + * * @fires [[valuesUpdated]] - * + * * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws an error when the source location has matrix inside - matrix cannot be moved * @throws an error when the target location has matrix inside - cells cannot be replaced by the matrix @@ -804,19 +804,19 @@ export class HyperFormula implements TypedEmitter { /** * Moves a particular number of rows to a specified position in a given sheet. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - a sheet number in which the operation will be performed * @param {number} startRow - number of the first row to move * @param {number} numberOfRows - number of rows to move * @param {number} targetRow - row number before which rows will be moved - * + * * @fires [[valuesUpdated]] - * + * * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws an error when the source location has matrix inside - matrix cannot be moved - * + * * @category Row */ public moveRows(sheet: number, startRow: number, numberOfRows: number, targetRow: number): ExportedChange[] { @@ -848,16 +848,16 @@ export class HyperFormula implements TypedEmitter { /** * Moves a particular number of columns to a specified position in a given sheet. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {number} sheet - a sheet number in which the operation will be performed * @param {number} startColumn - number of the first column to move * @param {number} numberOfColumns - number of columns to move * @param {number} targetColumn - column number before which columns will be moved - * + * * @fires [[valuesUpdated]] - * + * * @throws [[InvalidArgumentsError]] when the given arguments are invalid * @throws an error when the source location has matrix inside - matrix cannot be moved * @@ -875,7 +875,7 @@ export class HyperFormula implements TypedEmitter { * @param {SimpleCellAddress} sourceLeftCorner - address of the upper left corner of a copied block * @param {number} width - width of the cell block being copied * @param {number} height - height of the cell block being copied - * + * * @throws an error while attempting to copy unsupported content type * * @category Clipboard @@ -906,13 +906,13 @@ export class HyperFormula implements TypedEmitter { * When called after [[copy]] it will paste copied values and formulas into a cell block. * When called after [[paste]] it will perform [[moveCells]] operation into the cell block. * Does nothing if the clipboard is empty. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @param {SimpleCellAddress} targetLeftCorner - upper left address of the target cell block - * + * * @fires [[valuesUpdated]] - * + * * @throws an error while attempting to paste onto a matrix * @throws [[EvaluationSuspendedError]] when the evaluation is suspended * @@ -983,9 +983,9 @@ export class HyperFormula implements TypedEmitter { * Checks against particular rules to ascertain that addSheet can be called. * If returns `true`, doing [[addSheet]] operation won't throw any errors and it possible to add sheet with provided name. * Returns `false` if the chosen name is already used. - * + * * @param {string} name - sheet name, case insensitive - * + * * @category Sheet */ public isItPossibleToAddSheet(name: string): boolean { @@ -999,11 +999,11 @@ export class HyperFormula implements TypedEmitter { /** * Adds a new sheet to the HyperFormula instance. Returns given or autogenerated name of a new sheet. - * + * * @param {string} [name] - if not specified, name will be autogenerated - * + * * @fires [[sheetAdded]] - * + * * @throws an error when sheet with a given name already exists * * @category Sheet @@ -1018,7 +1018,7 @@ export class HyperFormula implements TypedEmitter { * Returns information whether it is possible to remove sheet for the engine. * Returns `true` if the provided name of a sheet exists and therefore it can be removed, doing [[removeSheet]] operation won't throw any errors. * Returns `false` if there is no sheet with a given name - * + * * @param {string} name - sheet name, case insensitive * * @category Sheet @@ -1034,14 +1034,14 @@ export class HyperFormula implements TypedEmitter { /** * Removes sheet with a specified name. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @param {string} name - sheet name, case insensitive - * + * * @fires [[sheetRemoved]] * @fires [[valuesUpdated]] - * + * * @throws [[NoSheetWithNameError]] when the given sheet name does not exists * * @category Sheet @@ -1058,7 +1058,7 @@ export class HyperFormula implements TypedEmitter { * Returns information whether it is possible to clear a specified sheet. * If returns `true`, doing [[clearSheet]] operation won't throw any errors, provided name of a sheet exists and then its content can be cleared. * Returns `false` if there is no sheet with a given name - * + * * @param {string} name - sheet name, case insensitive. * * @category Sheet @@ -1075,13 +1075,13 @@ export class HyperFormula implements TypedEmitter { /** * Clears the sheet content. Based on that the method finds the ID of a sheet to be cleared. * Double-checks if the sheet exists. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @param {string} name - sheet name, case insensitive. - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NoSheetWithNameError]] when the given sheet name does not exists * * @category Sheet @@ -1117,9 +1117,9 @@ export class HyperFormula implements TypedEmitter { * * @param {string} sheetName - sheet name, case insensitive. * @param {RawCellContent[][]} values - array of new values - * + * * @throws [[NoSheetWithNameError]] when the given sheet name does not exists - * + * * @category Sheet */ public setSheetContent(sheetName: string, values: RawCellContent[][]): ExportedChange[] { @@ -1135,7 +1135,7 @@ export class HyperFormula implements TypedEmitter { * * @param {string} stringAddress - string representation of cell address in A1 notation, e.g. 'C64' * @param {number} sheet - override sheet index regardless of sheet mapping - * + * * @category Helper */ public simpleCellAddressFromString(stringAddress: string, sheet: number) { @@ -1144,7 +1144,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns string representation of an absolute address in A1 notation or `undefined` if the sheet index is not present in the engine. - * + * * @param {SimpleCellAddress} address - object representation of an absolute address * @param {number} sheet - if is not equal with address sheet index, string representation will contain sheet name * @@ -1156,9 +1156,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns a unique sheet name assigned to the sheet of a given ID or `undefined` if the there is no sheet with a given ID. - * + * * @param {number} sheetId - ID of the sheet, for which we want to retrieve name - * + * * @category Sheet */ public getSheetName(sheetId: number): Maybe { @@ -1167,7 +1167,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns a unique sheet ID assigned to the sheet with a given name or `undefined` if the sheet does not exist. - * + * * @param {string} sheetName - name of the sheet, for which we want to retrieve ID, case insensitive. * * @category Sheet @@ -1178,9 +1178,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns `true` whether sheet with a given name exists. The methods accepts sheet name to be checked. - * + * * @param {string} sheetName - name of the sheet, case insensitive. - * + * * @category Sheet */ public doesSheetExist(sheetName: string): boolean { @@ -1192,7 +1192,7 @@ export class HyperFormula implements TypedEmitter { * The methods accepts cell coordinates as object with column, row and sheet numbers. * * @param {SimpleCellAddress} address - cell coordinates - * + * * @throws [[NoSheetWithIdError]] when the given sheet ID does not exist * * @category Cell @@ -1205,9 +1205,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns `true` if the specified cell contains a simple value. * The methods accepts cell coordinates as object with column, row and sheet numbers. - * + * * @param {SimpleCellAddress} address - cell coordinates - * + * * @category Cell */ public doesCellHaveSimpleValue(address: SimpleCellAddress): boolean { @@ -1217,9 +1217,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns `true` if the specified cell contains a formula. * The methods accepts cell coordinates as object with column, row and sheet numbers. - * + * * @param {SimpleCellAddress} address - cell coordinates - * + * * @category Cell */ public doesCellHaveFormula(address: SimpleCellAddress): boolean { @@ -1231,7 +1231,7 @@ export class HyperFormula implements TypedEmitter { * The methods accepts cell coordinates as object with column, row and sheet numbers. * * @param {SimpleCellAddress} address - cell coordinates - * + * * @category Cell */ public isCellEmpty(address: SimpleCellAddress): boolean { @@ -1253,9 +1253,9 @@ export class HyperFormula implements TypedEmitter { /** * Returns type of the cell value of a given address. * The methods accepts cell coordinates as object with column, row and sheet numbers. - * + * * @param {SimpleCellAddress} address - cell coordinates - * + * * @throws [[EvaluationSuspendedError]] when the evaluation is suspended * * @category Cell @@ -1268,7 +1268,7 @@ export class HyperFormula implements TypedEmitter { /** * Returns the number of existing sheets. - * + * * @category Sheet */ public countSheets(): number { @@ -1277,12 +1277,12 @@ export class HyperFormula implements TypedEmitter { /** * Renames a specified sheet. - * + * * @param {number} sheetId - a sheet number * @param {string} newName - a name of the sheet to be given, if is the same as the old one the method does nothing - * + * * @fires [[sheetRenamed]] - * + * * @throws Throws an error if the provided sheet ID does not exists. * * @category Sheet @@ -1296,9 +1296,9 @@ export class HyperFormula implements TypedEmitter { /** * Runs multiple operations and recomputes formulas at the end. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @param {(e: IBatchExecutor) => void} batchOperations * @fires [[valuesUpdated]] * @@ -1321,7 +1321,7 @@ export class HyperFormula implements TypedEmitter { * With this method, multiple CRUD operations can be done without triggering recalculation after every operation. * Suspending evaluation should result in an overall faster calculation compared to recalculating after each operation separately. * To resume the evaluation use [[resumeEvaluation]]. - * + * * @category Batch */ public suspendEvaluation(): void { @@ -1331,7 +1331,7 @@ export class HyperFormula implements TypedEmitter { /** * Resumes the dependency graph recalculation that was suspended with [[suspendEvaluation]]. * It also triggers the recalculation and returns changes that are a result of all batched operations. - * + * * @fires [[valuesUpdated]] * * @category Batch @@ -1352,12 +1352,12 @@ export class HyperFormula implements TypedEmitter { /** * Adds a specified named expression. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {string} expressionName - a name of the expression to be added * @param {RawCellContent} expression - the expression - * + * * @fires [[namedExpressionAdded]] always, unless [[batch]] mode is used * @fires [[valuesUpdated]] if recalculation was triggered by this change * @@ -1398,14 +1398,14 @@ export class HyperFormula implements TypedEmitter { /** * Changes a given named expression to a specified formula. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {string} expressionName - an expression name, case insensitive. * @param {RawCellContent} newExpression - a new expression - * + * * @fires [[valuesUpdated]] - * + * * @throws [[NamedExpressionDoesNotExist]] when the given expression does not exist. * * @category Named Expression @@ -1420,11 +1420,11 @@ export class HyperFormula implements TypedEmitter { /** * Removes a named expression. - * + * * Note that this method may trigger dependency graph recalculation. * * @param {string} expressionName - expression name, case insensitive. - * + * * @fires [[namedExpressionRemoved]] * @fires [[valuesUpdated]] * @@ -1445,7 +1445,7 @@ export class HyperFormula implements TypedEmitter { /** * Lists all named expressions. * Returns an array of expression names as strings - * + * * @category Named Expression */ public listNamedExpressions(): string[] { @@ -1474,7 +1474,7 @@ export class HyperFormula implements TypedEmitter { * * @param {string} formulaString - a formula, ex. "=SUM(Sheet1!A1:A100)" * @param {string} sheetName - a name of the sheet in context of which we evaluate formula, case insensitive. - * + * * @throws [[NotAFormulaError]] when the provided string is not a valid formula, i.e does not start with "=" * @throws [[NoSheetWithNameError]] when the given sheet name does not exists * @@ -1528,10 +1528,10 @@ export class HyperFormula implements TypedEmitter { /** * A method that subscribes to an event. - * + * * @param {Event} event the name of the event to subscribe to * @param {Listener} listener to be called when event is emitted - * + * * @category Events */ public on(event: Event, listener: Listeners[Event]): void { @@ -1540,10 +1540,10 @@ export class HyperFormula implements TypedEmitter { /** * A method that subscribes to an event once. - * + * * @param {Event} event the name of the event to subscribe to * @param {Listener} listener to be called when event is emitted - * + * * @category Events */ public once(event: Event, listener: Listeners[Event]): void { @@ -1552,10 +1552,10 @@ export class HyperFormula implements TypedEmitter { /** * A method that unsubscribe from an event or all events. - * + * * @param {Event} event the name of the event to subscribe to * @param {Listener} listener to be called when event is emitted - * + * * @category Events */ public off(event: Event, listener: Listeners[Event]): void { @@ -1580,9 +1580,9 @@ export class HyperFormula implements TypedEmitter { /** * Runs a recomputation starting from recently changed vertices. - * + * * Note that this method may trigger dependency graph recalculation. - * + * * @fires [[valuesUpdated]] */ private recomputeIfDependencyGraphNeedsIt(): ExportedChange[] { @@ -1607,4 +1607,3 @@ export class HyperFormula implements TypedEmitter { } } } - diff --git a/src/helpers/licenseKey.ts b/src/helpers/licenseKey.ts new file mode 100644 index 0000000000..9c1f89c3ac --- /dev/null +++ b/src/helpers/licenseKey.ts @@ -0,0 +1,65 @@ +// @ts-nocheck +const consoleMessages = { + invalid: () => `The license key for HyperFormula is invalid.`, + expired: ({ keyValidityDate }) => `The license key for HyperFormula expired` + + ` on ${keyValidityDate}, and is not valid for the installed version.`, + missing: () => `The license key for HyperFormula is missing.`, +} + +let _notified = false + +export function checkLicenseKeyValidity(licenseKey) { + const messageDescriptor = { + template: 'missing', + args: {}, + } + + if (licenseKey === 'non-commercial-and-evaluation' || licenseKey === 'agpl-v3') { + messageDescriptor.template = 'valid' + + } else if (typeof licenseKey === 'string' && _checkKeySchema(licenseKey)) { + const [day, month, year] = process.env.HT_RELEASE_DATE.split('/') + const releaseDays = Math.floor(new Date(`${month}/${day}/${year}`).getTime() / 8.64e7) + const keyValidityDays = _extractTime(licenseKey) + + messageDescriptor.args.keyValidityDate = new Date((keyValidityDays + 1) * 8.64e7).toISOString() + + if (releaseDays > keyValidityDays) { + messageDescriptor.template = 'expired' + } else { + messageDescriptor.template = 'valid' + } + + } else if (licenseKey !== '') { + messageDescriptor.template = 'invalid' + } + + if (!_notified && messageDescriptor.template !== 'valid') { + console.warn(consoleMessages[messageDescriptor.template](messageDescriptor.args)) + _notified = true; + } +} + +const _rl = '\x6C\x65\x6E\x67\x74\x68' +const _hd = (v) => parseInt(v, 16) +const _pi = (v) => parseInt(v, 10) +const _nm = (v) => (v+'').replace(/\-/g, '') +const _ss = (v, s, l) => v['\x73\x75\x62\x73\x74\x72'](s, l) +const _cp = (v) => v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0) - 65 + +function _extractTime(v) { + return _nm(v)[_rl] === (50>>1) ? _hd(_ss(_nm(v), _hd('12'), _cp('\x46'))) / (_hd(_ss(_nm(v), _cp('C'), _cp('\x59')>>4)) || ((~~![][_rl])<<3) + 1) : 0; +}; +function _checkKeySchema(v: string): string { + v = (v+'').replace(/\-/g, ''); + + if (v[_rl] !== _cp('\x5A')) { + return false; + } + + let sp = 0; + + return [[0, _cp('\x47') + 1],[_cp('\x48'), _cp('\x48') - 1],[_cp('G') + _cp('H'), _cp('\x47')]].reduce((e, [a, b], c) => { + e|=(_pi(`${_pi(_hd(_ss(v, ...[sp + a - (c === (3>>2) ? 0 : 2), b + (!c ? 0 : 2)]))+(_hd(_ss(v, ...[sp + a + b, 2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp += 2;return e; + },_cp('A'))===([] + 1>>1); +} diff --git a/test/AbsoluteCellRange.spec.ts b/test/AbsoluteCellRange.spec.ts index 6494071f19..13b06a15fa 100644 --- a/test/AbsoluteCellRange.spec.ts +++ b/test/AbsoluteCellRange.spec.ts @@ -1,5 +1,4 @@ import {AbsoluteCellRange} from '../src/AbsoluteCellRange' -import './testConfig' import {adr} from './testUtils' describe('AbsoluteCellRange', () => { diff --git a/test/_setupFiles/bootstrap.ts b/test/_setupFiles/bootstrap.ts new file mode 100644 index 0000000000..5b19f80c7a --- /dev/null +++ b/test/_setupFiles/bootstrap.ts @@ -0,0 +1,26 @@ +/** + * This script file presents you the opportunity of running some code immediately + * after the test framework has been installed in the environment. + */ +import {HyperFormula} from '../../src' +import {Config} from '../../src/Config' +import {AlwaysSparse} from '../../src/DependencyGraph/AddressMapping/ChooseAddressMappingPolicy' +import {languages} from '../../src/i18n' +import {unregisterAllLanguages} from './../testUtils' + +Config.defaultConfig = Object.assign({}, Config.defaultConfig, { + chooseAddressMappingPolicy: new AlwaysSparse(), + functionPlugins: [], + gpuMode: 'cpu', + matrixDetection: false, + useStats: true, + licenseKey: 'agpl-v3', +}) + +beforeEach(() => { + unregisterAllLanguages() + + const defaultLanguage = Config.defaultConfig.language + + HyperFormula.registerLanguage(defaultLanguage, languages[defaultLanguage]) +}) diff --git a/test/_setupFiles/globalSetup.ts b/test/_setupFiles/globalSetup.ts new file mode 100644 index 0000000000..2742921fb1 --- /dev/null +++ b/test/_setupFiles/globalSetup.ts @@ -0,0 +1,14 @@ +/** + * This script file presents you the opportunity of running some code immediately + * before the test framework has been installed in the environment. + */ +export default async function() { + const htConfig = require('./../../ht.config'); + + // Extract all HF constants to the process environment namespance. + // So the HT_RELEASE_DATE consts and other will be accessible while + // testing the lib. + Object.keys(htConfig).forEach((key) => { + process.env[key] = htConfig[key]; + }); +} diff --git a/test/build-engine.spec.ts b/test/build-engine.spec.ts index e418f40117..49aaefc9a2 100644 --- a/test/build-engine.spec.ts +++ b/test/build-engine.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula} from '../src' -import './testConfig.ts' import {plPL} from '../src/i18n' import {adr} from './testUtils' diff --git a/test/computation-suspension.spec.ts b/test/computation-suspension.spec.ts index c65b6aa0b4..3beac7b1f1 100644 --- a/test/computation-suspension.spec.ts +++ b/test/computation-suspension.spec.ts @@ -1,7 +1,6 @@ import {HyperFormula, EvaluationSuspendedError, ExportedCellChange} from '../src' import { AbsoluteCellRange } from '../src/AbsoluteCellRange' import { CellType } from '../src/Cell' -import './testConfig' import {adr} from './testUtils' describe('Evaluation suspension', () => { diff --git a/test/cruds/adding-columns-dependencies.spec.ts b/test/cruds/adding-columns-dependencies.spec.ts index a0cc9a387f..d26d0284b1 100644 --- a/test/cruds/adding-columns-dependencies.spec.ts +++ b/test/cruds/adding-columns-dependencies.spec.ts @@ -1,7 +1,7 @@ import { HyperFormula} from '../../src' import {EmptyCellVertex} from '../../src/DependencyGraph' import {CellAddress} from '../../src/parser' -import '../testConfig' + import { adr, colEnd, diff --git a/test/cruds/adding-columns.spec.ts b/test/cruds/adding-columns.spec.ts index 755f3ff1c6..86230b29da 100644 --- a/test/cruds/adding-columns.spec.ts +++ b/test/cruds/adding-columns.spec.ts @@ -3,7 +3,6 @@ import {AbsoluteCellRange} from '../../src/AbsoluteCellRange' import { simpleCellAddress} from '../../src/Cell' import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import { FormulaCellVertex, MatrixVertex} from '../../src/DependencyGraph' -import '../testConfig' import {adr, expectArrayWithSameContent, extractMatrixRange, extractRange} from '../testUtils' describe('Adding column - checking if its possible', () => { diff --git a/test/cruds/adding-row-dependencies.spec.ts b/test/cruds/adding-row-dependencies.spec.ts index 77095af584..7aefb5406a 100644 --- a/test/cruds/adding-row-dependencies.spec.ts +++ b/test/cruds/adding-row-dependencies.spec.ts @@ -1,7 +1,6 @@ import { HyperFormula} from '../../src' import {EmptyCellVertex} from '../../src/DependencyGraph' import {CellAddress} from '../../src/parser' -import '../testConfig' import {adr, colEnd, colStart, expectEngineToBeTheSameAs, extractReference, rowEnd, rowStart} from '../testUtils' describe('Adding row - fixing dependencies', () => { @@ -636,4 +635,4 @@ describe('Adding row, fixing row ranges', () => { ['=SUM(1:3)'], ])) }) -}) \ No newline at end of file +}) diff --git a/test/cruds/adding-row.spec.ts b/test/cruds/adding-row.spec.ts index 4bf4f50e8f..23a3750319 100644 --- a/test/cruds/adding-row.spec.ts +++ b/test/cruds/adding-row.spec.ts @@ -3,7 +3,6 @@ import {AbsoluteCellRange} from '../../src/AbsoluteCellRange' import {simpleCellAddress} from '../../src/Cell' import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import { FormulaCellVertex, MatrixVertex} from '../../src/DependencyGraph' -import '../testConfig' import {adr, expectArrayWithSameContent, extractMatrixRange} from '../testUtils' describe('Adding row - checking if its possible', () => { diff --git a/test/cruds/adding-sheet.spec.ts b/test/cruds/adding-sheet.spec.ts index ec39226aa7..307386d5bd 100644 --- a/test/cruds/adding-sheet.spec.ts +++ b/test/cruds/adding-sheet.spec.ts @@ -1,5 +1,4 @@ import {EmptyValue, HyperFormula} from '../../src' -import '../testConfig' import {plPL} from '../../src/i18n' import {adr} from '../testUtils' diff --git a/test/cruds/batch-operations.spec.ts b/test/cruds/batch-operations.spec.ts index 604cc2ec11..7d5fdc1807 100644 --- a/test/cruds/batch-operations.spec.ts +++ b/test/cruds/batch-operations.spec.ts @@ -1,6 +1,5 @@ import {EmptyValue, HyperFormula} from '../../src' import {normalizeAddedIndexes, normalizeRemovedIndexes} from '../../src/Operations' -import '../testConfig' import {adr, expectArrayWithSameContent} from '../testUtils' describe('batch cruds', () => { diff --git a/test/cruds/change-cell-content.spec.ts b/test/cruds/change-cell-content.spec.ts index 2700829d0c..927f105876 100644 --- a/test/cruds/change-cell-content.spec.ts +++ b/test/cruds/change-cell-content.spec.ts @@ -2,7 +2,6 @@ import {EmptyValue, ExportedCellChange, HyperFormula, InvalidAddressError, NoShe import {ErrorType, simpleCellAddress} from '../../src/Cell' import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {EmptyCellVertex, MatrixVertex} from '../../src/DependencyGraph' -import '../testConfig' import {adr, colEnd, colStart, detailedError, rowEnd, rowStart} from '../testUtils' describe('Changing cell content - checking if its possible', () => { diff --git a/test/cruds/copy-paste.spec.ts b/test/cruds/copy-paste.spec.ts index 6e6898b3f1..05cfc99215 100644 --- a/test/cruds/copy-paste.spec.ts +++ b/test/cruds/copy-paste.spec.ts @@ -1,7 +1,6 @@ import {EmptyValue, HyperFormula, ExportedCellChange} from '../../src' import {ErrorType, simpleCellAddress} from '../../src/Cell' import {CellAddress} from '../../src/parser' -import '../testConfig' import { adr, colEnd, diff --git a/test/cruds/cut-paste.spec.ts b/test/cruds/cut-paste.spec.ts index db457a8f4e..a2e61c8cf7 100644 --- a/test/cruds/cut-paste.spec.ts +++ b/test/cruds/cut-paste.spec.ts @@ -4,7 +4,6 @@ import {simpleCellAddress} from '../../src/Cell' import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {EmptyCellVertex, ValueCellVertex} from '../../src/DependencyGraph' import {CellAddress} from '../../src/parser' -import '../testConfig' import { adr, expectArrayWithSameContent, diff --git a/test/cruds/move-cells.spec.ts b/test/cruds/move-cells.spec.ts index 0492db2ac6..62ef8b6ea5 100644 --- a/test/cruds/move-cells.spec.ts +++ b/test/cruds/move-cells.spec.ts @@ -4,7 +4,6 @@ import {simpleCellAddress} from '../../src/Cell' import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {EmptyCellVertex, ValueCellVertex} from '../../src/DependencyGraph' import {CellAddress} from '../../src/parser' -import '../testConfig' import { adr, expectArrayWithSameContent, diff --git a/test/cruds/removing-columns.spec.ts b/test/cruds/removing-columns.spec.ts index 68040e92ac..195e1ed6e0 100644 --- a/test/cruds/removing-columns.spec.ts +++ b/test/cruds/removing-columns.spec.ts @@ -4,7 +4,6 @@ import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {MatrixVertex, RangeVertex} from '../../src/DependencyGraph' import {CellAddress} from '../../src/parser' import {simpleCellAddress} from '../../src/Cell' -import '../testConfig' import { adr, expectArrayWithSameContent, diff --git a/test/cruds/removing-rows.spec.ts b/test/cruds/removing-rows.spec.ts index fd2ce9bcc6..ec74fea720 100644 --- a/test/cruds/removing-rows.spec.ts +++ b/test/cruds/removing-rows.spec.ts @@ -5,7 +5,6 @@ import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {MatrixVertex} from '../../src/DependencyGraph' import {InvalidArgumentsError} from '../../src' import {CellAddress} from '../../src/parser' -import '../testConfig' import { adr, expectArrayWithSameContent, expectEngineToBeTheSameAs, diff --git a/test/cruds/removing-sheet.spec.ts b/test/cruds/removing-sheet.spec.ts index a530ce2920..959d98e209 100644 --- a/test/cruds/removing-sheet.spec.ts +++ b/test/cruds/removing-sheet.spec.ts @@ -5,7 +5,6 @@ import {ColumnIndex} from '../../src/ColumnSearch/ColumnIndex' import {MatrixVertex} from '../../src/DependencyGraph' import {NoSheetWithNameError} from '../../src' import {CellAddress} from '../../src/parser' -import '../testConfig' import { adr, detailedError, expectArrayWithSameContent, diff --git a/test/date.spec.ts b/test/date.spec.ts index c0e11c6ba6..4486c5e892 100644 --- a/test/date.spec.ts +++ b/test/date.spec.ts @@ -2,7 +2,6 @@ import {Config} from '../src/Config' import {DateTimeHelper, SimpleDate} from '../src/DateTimeHelper' import moment from 'moment' import {Maybe} from '../src/Maybe' -import './testConfig' describe('Date helpers', () => { it('#dateToNumber should return number representation of a date', () => { diff --git a/test/disable-matrix-optimizations.spec.ts b/test/disable-matrix-optimizations.spec.ts index c71964548d..2b649d1c59 100644 --- a/test/disable-matrix-optimizations.spec.ts +++ b/test/disable-matrix-optimizations.spec.ts @@ -1,7 +1,6 @@ import {HyperFormula} from '../src' import {AbsoluteCellRange} from '../src/AbsoluteCellRange' import {EmptyCellVertex, MatrixVertex, ValueCellVertex} from '../src/DependencyGraph' -import './testConfig.ts' import {adr} from './testUtils' describe('Disable matrix optimizatoins', () => { diff --git a/test/emitting-events.spec.ts b/test/emitting-events.spec.ts index b546160789..03742e473d 100644 --- a/test/emitting-events.spec.ts +++ b/test/emitting-events.spec.ts @@ -1,7 +1,7 @@ import {HyperFormula, ExportedCellChange, ExportedNamedExpressionChange} from '../src' import {Events} from '../src/Emitter' import {ErrorType} from '../src/Cell' -import './testConfig' + import { adr, detailedError } from './testUtils' describe('Events', () => { diff --git a/test/engine.spec.ts b/test/engine.spec.ts index c8d79571dc..2718953e9c 100644 --- a/test/engine.spec.ts +++ b/test/engine.spec.ts @@ -1,6 +1,5 @@ import {DetailedCellError, HyperFormula} from '../src' import {CellType, CellValueType, EmptyValue, ErrorType} from '../src/Cell' -import './testConfig.ts' import {plPL} from '../src/i18n' import {adr, detailedError} from './testUtils' diff --git a/test/extending-plugins.spec.ts b/test/extending-plugins.spec.ts index 7bdc971273..a790ceca2c 100644 --- a/test/extending-plugins.spec.ts +++ b/test/extending-plugins.spec.ts @@ -1,7 +1,6 @@ import {HyperFormula} from '../src' import {ErrorType} from '../src' import {FunctionPlugin, PluginFunctionType} from '../src/interpreter/plugin/FunctionPlugin' -import './testConfig.ts' import {adr, detailedError} from './testUtils' class FooPlugin extends FunctionPlugin { diff --git a/test/format/format-interpreter.spec.ts b/test/format/format-interpreter.spec.ts index c0537f750a..395ae4fbbb 100644 --- a/test/format/format-interpreter.spec.ts +++ b/test/format/format-interpreter.spec.ts @@ -1,7 +1,6 @@ import {Config} from '../../src/Config' import {DateTimeHelper} from '../../src/DateTimeHelper' import {format} from '../../src/format/format' -import '../testConfig' describe('FormatInterpreter', () => { const config = new Config() diff --git a/test/graph-builder.spec.ts b/test/graph-builder.spec.ts index 22d8167deb..7d151dc164 100644 --- a/test/graph-builder.spec.ts +++ b/test/graph-builder.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../src' import {EmptyCellVertex, MatrixVertex, ValueCellVertex} from '../src/DependencyGraph' -import './testConfig.ts' import {adr, colEnd, colStart} from './testUtils' describe('GraphBuilder', () => { diff --git a/test/helpers/licenseKey/agpl-v3.spec.ts b/test/helpers/licenseKey/agpl-v3.spec.ts new file mode 100644 index 0000000000..e39dfc4292 --- /dev/null +++ b/test/helpers/licenseKey/agpl-v3.spec.ts @@ -0,0 +1,18 @@ +/** + * The license key message is printed only once per window/process env. + * Jest provides complete isolation between files only. That is why the test + * contains only one case about "console.warn" message. + */ +import {HyperFormula} from '../../../src' + +describe('license key', () => { + it('should warn message about invalid key', async () => { + spyOn(console, 'warn') + + HyperFormula.buildEmpty({ + licenseKey: 'agpl-v3', + }) + + expect(console.warn).not.toHaveBeenCalled(); + }) +}) diff --git a/test/helpers/licenseKey/invalid-agpl-version.spec.ts b/test/helpers/licenseKey/invalid-agpl-version.spec.ts new file mode 100644 index 0000000000..290944ea5b --- /dev/null +++ b/test/helpers/licenseKey/invalid-agpl-version.spec.ts @@ -0,0 +1,18 @@ +/** + * The license key message is printed only once per window/process env. + * Jest provides complete isolation between files only. That is why the test + * contains only one case about "console.warn" message. + */ +import {HyperFormula} from '../../../src' + +describe('license key', () => { + it('should warn message about invalid key', async () => { + spyOn(console, 'warn') + + HyperFormula.buildEmpty({ + licenseKey: 'agpl-v1', + }) + + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.'); + }) +}) diff --git a/test/helpers/licenseKey/invalid-key.spec.ts b/test/helpers/licenseKey/invalid-key.spec.ts new file mode 100644 index 0000000000..a4b1472a72 --- /dev/null +++ b/test/helpers/licenseKey/invalid-key.spec.ts @@ -0,0 +1,18 @@ +/** + * The license key message is printed only once per window/process env. + * Jest provides complete isolation between files only. That is why the test + * contains only one case about "console.warn" message. + */ +import {HyperFormula} from '../../../src' + +describe('license key', () => { + it('should warn message about invalid key', async () => { + spyOn(console, 'warn') + + HyperFormula.buildEmpty({ + licenseKey: '11111-11111-11111-11111-11111', + }) + + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.'); + }) +}) diff --git a/test/helpers/licenseKey/missing-key.spec.ts b/test/helpers/licenseKey/missing-key.spec.ts new file mode 100644 index 0000000000..baf3513701 --- /dev/null +++ b/test/helpers/licenseKey/missing-key.spec.ts @@ -0,0 +1,18 @@ +/** + * The license key message is printed only once per window/process env. + * Jest provides complete isolation between files only. That is why the test + * contains only one case about "console.warn" message. + */ +import {HyperFormula} from '../../../src' + +describe('license key', () => { + it('should warn message about missing key', async () => { + spyOn(console, 'warn') + + HyperFormula.buildEmpty({ + licenseKey: '', + }) + + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is missing.'); + }) +}) diff --git a/test/helpers/licenseKey/non-commercial-key.spec.ts b/test/helpers/licenseKey/non-commercial-key.spec.ts new file mode 100644 index 0000000000..4cc39e2b72 --- /dev/null +++ b/test/helpers/licenseKey/non-commercial-key.spec.ts @@ -0,0 +1,18 @@ +/** + * The license key message is printed only once per window/process env. + * Jest provides complete isolation between files only. That is why the test + * contains only one case about "console.warn" message. + */ +import {HyperFormula} from '../../../src' + +describe('license key', () => { + it('should warn message about invalid key', async () => { + spyOn(console, 'warn') + + HyperFormula.buildEmpty({ + licenseKey: 'non-commercial-and-evaluation', + }) + + expect(console.warn).not.toHaveBeenCalled(); + }) +}) diff --git a/test/i18n.spec.ts b/test/i18n.spec.ts index 2ad6319962..0b0a5b5bf4 100644 --- a/test/i18n.spec.ts +++ b/test/i18n.spec.ts @@ -2,7 +2,6 @@ import {HyperFormula} from '../src' import {Config} from '../src/Config' import {languages, plPL, TranslationPackage} from '../src/i18n' import {CellAddress} from '../src/parser' -import './testConfig.ts' import {adr, extractReference} from './testUtils' describe('i18n', () => { diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts index 3eb532d379..0e75423cd6 100644 --- a/test/interpreter.spec.ts +++ b/test/interpreter.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../src' import {ErrorType} from '../src/Cell' -import './testConfig' import {adr, detailedError} from './testUtils' describe('Interpreter', () => { diff --git a/test/interpreter/boolean-operators.spec.ts b/test/interpreter/boolean-operators.spec.ts index bacbffb598..f1a89f4e0d 100644 --- a/test/interpreter/boolean-operators.spec.ts +++ b/test/interpreter/boolean-operators.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Interpreter - Boolean operators', () => { @@ -338,4 +337,3 @@ describe('Interpreter - Boolean operators', () => { expect(engine.getCellValue(adr('F1'))).toEqual(detailedError(ErrorType.DIV_BY_ZERO)) }) }) - diff --git a/test/interpreter/coercions.spec.ts b/test/interpreter/coercions.spec.ts index 21236dd052..1dd76117c0 100644 --- a/test/interpreter/coercions.spec.ts +++ b/test/interpreter/coercions.spec.ts @@ -8,7 +8,6 @@ import { coerceScalarToBoolean, coerceScalarToString } from '../../src/interpreter/ArithmeticHelper' -import '../testConfig' import {adr, detailedError} from '../testUtils' import {NumberLiteralHelper} from '../../src/NumberLiteralHelper' diff --git a/test/interpreter/criterion-computations.spec.ts b/test/interpreter/criterion-computations.spec.ts index 368a666f10..fade17499d 100644 --- a/test/interpreter/criterion-computations.spec.ts +++ b/test/interpreter/criterion-computations.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula} from '../../src' -import '../testConfig' import {adr} from '../testUtils' describe('Criterions - operators computations', () => { diff --git a/test/interpreter/date-arithmetic.spec.ts b/test/interpreter/date-arithmetic.spec.ts index 82748bc08d..37d937af4b 100644 --- a/test/interpreter/date-arithmetic.spec.ts +++ b/test/interpreter/date-arithmetic.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula} from '../../src' -import '../testConfig' import {adr} from '../testUtils' describe('Date arithmetic', () => { diff --git a/test/interpreter/error-literals.spec.ts b/test/interpreter/error-literals.spec.ts index 0c592d2b4a..b54d06c3a4 100644 --- a/test/interpreter/error-literals.spec.ts +++ b/test/interpreter/error-literals.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Error literals', () => { @@ -35,7 +34,7 @@ describe('Error literals', () => { expect(engine.getCellValue(adr('D1'))).toEqual(detailedError(ErrorType.NA)) // GT expect(engine.getCellValue(adr('E1'))).toEqual(detailedError(ErrorType.NA)) // LT expect(engine.getCellValue(adr('F1'))).toEqual(detailedError(ErrorType.NA)) // GTE - expect(engine.getCellValue(adr('G1'))).toEqual(detailedError(ErrorType.NA)) // LTE + expect(engine.getCellValue(adr('G1'))).toEqual(detailedError(ErrorType.NA)) // LTE expect(engine.getCellValue(adr('H1'))).toEqual(detailedError(ErrorType.NA)) // NOT EQUAL expect(engine.getCellValue(adr('I1'))).toEqual(detailedError(ErrorType.NA)) // ADD expect(engine.getCellValue(adr('J1'))).toEqual(detailedError(ErrorType.NA)) // SUB diff --git a/test/interpreter/function-abs.spec.ts b/test/interpreter/function-abs.spec.ts index 2b215d639b..ad47207ec1 100644 --- a/test/interpreter/function-abs.spec.ts +++ b/test/interpreter/function-abs.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ABS', () => { diff --git a/test/interpreter/function-acos.spec.ts b/test/interpreter/function-acos.spec.ts index c9ae769653..cb1159445c 100644 --- a/test/interpreter/function-acos.spec.ts +++ b/test/interpreter/function-acos.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ACOS', () => { diff --git a/test/interpreter/function-and.spec.ts b/test/interpreter/function-and.spec.ts index 5964eda209..2958f16db3 100644 --- a/test/interpreter/function-and.spec.ts +++ b/test/interpreter/function-and.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function AND', () => { diff --git a/test/interpreter/function-asin.spec.ts b/test/interpreter/function-asin.spec.ts index c06012dcb2..e9547395e6 100644 --- a/test/interpreter/function-asin.spec.ts +++ b/test/interpreter/function-asin.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ASIN', () => { diff --git a/test/interpreter/function-atan.spec.ts b/test/interpreter/function-atan.spec.ts index 39f0e215d1..d09a76aba8 100644 --- a/test/interpreter/function-atan.spec.ts +++ b/test/interpreter/function-atan.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ATAN', () => { diff --git a/test/interpreter/function-atan2.spec.ts b/test/interpreter/function-atan2.spec.ts index 5e7832b174..57d52c0fab 100644 --- a/test/interpreter/function-atan2.spec.ts +++ b/test/interpreter/function-atan2.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ATAN2', () => { diff --git a/test/interpreter/function-average.spec.ts b/test/interpreter/function-average.spec.ts index ad52e4cb5b..2e0ea69376 100644 --- a/test/interpreter/function-average.spec.ts +++ b/test/interpreter/function-average.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('AVERAGE', () => { diff --git a/test/interpreter/function-averagea.spec.ts b/test/interpreter/function-averagea.spec.ts index 59ccd7e92b..29d1a492aa 100644 --- a/test/interpreter/function-averagea.spec.ts +++ b/test/interpreter/function-averagea.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('AVERAGEA', () => { diff --git a/test/interpreter/function-averageif.spec.ts b/test/interpreter/function-averageif.spec.ts index 76b9244ba4..95d260d7f8 100644 --- a/test/interpreter/function-averageif.spec.ts +++ b/test/interpreter/function-averageif.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function AVERAGEIF - argument validations and combinations', () => { diff --git a/test/interpreter/function-columns.spec.ts b/test/interpreter/function-columns.spec.ts index 06ef2dd497..175a1ba5a3 100644 --- a/test/interpreter/function-columns.spec.ts +++ b/test/interpreter/function-columns.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function COLUMNS', () => { diff --git a/test/interpreter/function-concatenate.spec.ts b/test/interpreter/function-concatenate.spec.ts index c9f7feac45..7eb0697c67 100644 --- a/test/interpreter/function-concatenate.spec.ts +++ b/test/interpreter/function-concatenate.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('function CONCATENATE', () => { diff --git a/test/interpreter/function-correl.spec.ts b/test/interpreter/function-correl.spec.ts index 7b5a5cb2cb..4c9e1f09dc 100644 --- a/test/interpreter/function-correl.spec.ts +++ b/test/interpreter/function-correl.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('CORREL', () => { diff --git a/test/interpreter/function-cos.spec.ts b/test/interpreter/function-cos.spec.ts index 686ece589a..90c4b281ef 100644 --- a/test/interpreter/function-cos.spec.ts +++ b/test/interpreter/function-cos.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function COS', () => { diff --git a/test/interpreter/function-cot.spec.ts b/test/interpreter/function-cot.spec.ts index 225ade18d9..1315b2877c 100644 --- a/test/interpreter/function-cot.spec.ts +++ b/test/interpreter/function-cot.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function COT', () => { diff --git a/test/interpreter/function-count.spec.ts b/test/interpreter/function-count.spec.ts index fac4334e0c..b13db1223d 100644 --- a/test/interpreter/function-count.spec.ts +++ b/test/interpreter/function-count.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('COUNT', () => { diff --git a/test/interpreter/function-counta.spec.ts b/test/interpreter/function-counta.spec.ts index 3373524e28..559fa0570f 100644 --- a/test/interpreter/function-counta.spec.ts +++ b/test/interpreter/function-counta.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('COUNTA', () => { diff --git a/test/interpreter/function-countblank.spec.ts b/test/interpreter/function-countblank.spec.ts index 75cf501436..beced92344 100644 --- a/test/interpreter/function-countblank.spec.ts +++ b/test/interpreter/function-countblank.spec.ts @@ -1,6 +1,5 @@ import {EmptyValue, HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('COUNTBLANK', () => { diff --git a/test/interpreter/function-countif.spec.ts b/test/interpreter/function-countif.spec.ts index e8fb72a84f..4926a04333 100644 --- a/test/interpreter/function-countif.spec.ts +++ b/test/interpreter/function-countif.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' import {StatType} from '../../src/statistics' diff --git a/test/interpreter/function-countifs.spec.ts b/test/interpreter/function-countifs.spec.ts index ee310a27e4..c151a852b9 100644 --- a/test/interpreter/function-countifs.spec.ts +++ b/test/interpreter/function-countifs.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' import {StatType} from '../../src/statistics' diff --git a/test/interpreter/function-countunique.spec.ts b/test/interpreter/function-countunique.spec.ts index a30fc25777..a2d1b9e068 100644 --- a/test/interpreter/function-countunique.spec.ts +++ b/test/interpreter/function-countunique.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function COUNTUNIQUE', () => { diff --git a/test/interpreter/function-date.spec.ts b/test/interpreter/function-date.spec.ts index f4c363cd82..70d0669e01 100644 --- a/test/interpreter/function-date.spec.ts +++ b/test/interpreter/function-date.spec.ts @@ -1,6 +1,5 @@ import {EmptyValue, HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {Config} from '../../src/Config' import {adr, dateNumberToString, detailedError} from '../testUtils' diff --git a/test/interpreter/function-day.spec.ts b/test/interpreter/function-day.spec.ts index 3908b9fa16..9bd7070732 100644 --- a/test/interpreter/function-day.spec.ts +++ b/test/interpreter/function-day.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function DAY', () => { diff --git a/test/interpreter/function-degrees.spec.ts b/test/interpreter/function-degrees.spec.ts index 62fe389472..3c4c4c5765 100644 --- a/test/interpreter/function-degrees.spec.ts +++ b/test/interpreter/function-degrees.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function DEGREES', () => { diff --git a/test/interpreter/function-eomonth.spec.ts b/test/interpreter/function-eomonth.spec.ts index b88be15aa8..0042d2520e 100644 --- a/test/interpreter/function-eomonth.spec.ts +++ b/test/interpreter/function-eomonth.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType, SimpleCellAddress} from '../../src/Cell' -import '../testConfig' import {Config} from '../../src/Config' import {adr, dateNumberToString, detailedError} from '../testUtils' diff --git a/test/interpreter/function-even.spec.ts b/test/interpreter/function-even.spec.ts index f93f3c6954..dc8677800e 100644 --- a/test/interpreter/function-even.spec.ts +++ b/test/interpreter/function-even.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function EVEN', () => { diff --git a/test/interpreter/function-exp.spec.ts b/test/interpreter/function-exp.spec.ts index a0b9c0ab83..596b141665 100644 --- a/test/interpreter/function-exp.spec.ts +++ b/test/interpreter/function-exp.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function EXP', () => { diff --git a/test/interpreter/function-false.spec.ts b/test/interpreter/function-false.spec.ts index 77acca46d8..3c17316ba6 100644 --- a/test/interpreter/function-false.spec.ts +++ b/test/interpreter/function-false.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function FALSE', () => { diff --git a/test/interpreter/function-if.spec.ts b/test/interpreter/function-if.spec.ts index af49b6aa96..97bd0382e4 100644 --- a/test/interpreter/function-if.spec.ts +++ b/test/interpreter/function-if.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function IF', () => { diff --git a/test/interpreter/function-index.spec.ts b/test/interpreter/function-index.spec.ts index 5d8a99625b..77b97bc8fb 100644 --- a/test/interpreter/function-index.spec.ts +++ b/test/interpreter/function-index.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig.ts' import {adr, detailedError} from '../testUtils' describe('Function INDEX', () => { diff --git a/test/interpreter/function-int.spec.ts b/test/interpreter/function-int.spec.ts index 43cdaa1c07..cf200ef131 100644 --- a/test/interpreter/function-int.spec.ts +++ b/test/interpreter/function-int.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function INT', () => { diff --git a/test/interpreter/function-isblank.spec.ts b/test/interpreter/function-isblank.spec.ts index f1250a8b0c..dff19c3730 100644 --- a/test/interpreter/function-isblank.spec.ts +++ b/test/interpreter/function-isblank.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISBLANK', () => { diff --git a/test/interpreter/function-iserror.spec.ts b/test/interpreter/function-iserror.spec.ts index 4570e7f1b7..1c95d7b7a6 100644 --- a/test/interpreter/function-iserror.spec.ts +++ b/test/interpreter/function-iserror.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISERROR', () => { diff --git a/test/interpreter/function-iseven.spec.ts b/test/interpreter/function-iseven.spec.ts index e4850e6003..d65b13ed12 100644 --- a/test/interpreter/function-iseven.spec.ts +++ b/test/interpreter/function-iseven.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISEVEN', () => { diff --git a/test/interpreter/function-islogical.spec.ts b/test/interpreter/function-islogical.spec.ts index 63d49f1ac1..41dff8cc93 100644 --- a/test/interpreter/function-islogical.spec.ts +++ b/test/interpreter/function-islogical.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISLOGICAL', () => { diff --git a/test/interpreter/function-isnontext.spec.ts b/test/interpreter/function-isnontext.spec.ts index 180900d816..f68b380736 100644 --- a/test/interpreter/function-isnontext.spec.ts +++ b/test/interpreter/function-isnontext.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISNONTEXT', () => { diff --git a/test/interpreter/function-isnumber.spec.ts b/test/interpreter/function-isnumber.spec.ts index 9a5095e597..fefc6fcc3d 100644 --- a/test/interpreter/function-isnumber.spec.ts +++ b/test/interpreter/function-isnumber.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISNUMBER', () => { diff --git a/test/interpreter/function-isodd.spec.ts b/test/interpreter/function-isodd.spec.ts index 2a5956357d..e1d686f5bf 100644 --- a/test/interpreter/function-isodd.spec.ts +++ b/test/interpreter/function-isodd.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISODD', () => { diff --git a/test/interpreter/function-istext.spec.ts b/test/interpreter/function-istext.spec.ts index 7347b0de17..09c7e18672 100644 --- a/test/interpreter/function-istext.spec.ts +++ b/test/interpreter/function-istext.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ISTEXT', () => { diff --git a/test/interpreter/function-ln.spec.ts b/test/interpreter/function-ln.spec.ts index 47067664a8..928a8c3861 100644 --- a/test/interpreter/function-ln.spec.ts +++ b/test/interpreter/function-ln.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function LN', () => { diff --git a/test/interpreter/function-log.spec.ts b/test/interpreter/function-log.spec.ts index 14a8b4da7e..3c4e976518 100644 --- a/test/interpreter/function-log.spec.ts +++ b/test/interpreter/function-log.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function LOG', () => { diff --git a/test/interpreter/function-log10.spec.ts b/test/interpreter/function-log10.spec.ts index 1e591d215d..65282fde82 100644 --- a/test/interpreter/function-log10.spec.ts +++ b/test/interpreter/function-log10.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function LOG10', () => { diff --git a/test/interpreter/function-match.spec.ts b/test/interpreter/function-match.spec.ts index e09f91cd81..9f3f98e3ee 100644 --- a/test/interpreter/function-match.spec.ts +++ b/test/interpreter/function-match.spec.ts @@ -1,7 +1,6 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' import {ColumnBinarySearch} from '../../src/ColumnSearch/ColumnBinarySearch' -import '../testConfig.ts' import {adr, detailedError} from '../testUtils' describe('Function MATCH', () => { diff --git a/test/interpreter/function-max.spec.ts b/test/interpreter/function-max.spec.ts index d0b3e8bb68..980cda3a24 100644 --- a/test/interpreter/function-max.spec.ts +++ b/test/interpreter/function-max.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('MAX', () => { diff --git a/test/interpreter/function-maxa.spec.ts b/test/interpreter/function-maxa.spec.ts index fa73623695..be22924b30 100644 --- a/test/interpreter/function-maxa.spec.ts +++ b/test/interpreter/function-maxa.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('MAXA', () => { diff --git a/test/interpreter/function-median.spec.ts b/test/interpreter/function-median.spec.ts index 5598184865..131894f551 100644 --- a/test/interpreter/function-median.spec.ts +++ b/test/interpreter/function-median.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function MEDIAN', () => { diff --git a/test/interpreter/function-min.spec.ts b/test/interpreter/function-min.spec.ts index fcb7c9b945..6bcfb772c2 100644 --- a/test/interpreter/function-min.spec.ts +++ b/test/interpreter/function-min.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('MIN', () => { diff --git a/test/interpreter/function-mina.spec.ts b/test/interpreter/function-mina.spec.ts index 2d5bc3d55f..f97c231192 100644 --- a/test/interpreter/function-mina.spec.ts +++ b/test/interpreter/function-mina.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('MINA', () => { diff --git a/test/interpreter/function-month.spec.ts b/test/interpreter/function-month.spec.ts index 6d5c2c2686..8b22f43476 100644 --- a/test/interpreter/function-month.spec.ts +++ b/test/interpreter/function-month.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function MONTH', () => { diff --git a/test/interpreter/function-not.spec.ts b/test/interpreter/function-not.spec.ts index c8ad9e8788..e632669492 100644 --- a/test/interpreter/function-not.spec.ts +++ b/test/interpreter/function-not.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function NOT', () => { diff --git a/test/interpreter/function-odd.spec.ts b/test/interpreter/function-odd.spec.ts index 57ae146111..17cd7ef7c4 100644 --- a/test/interpreter/function-odd.spec.ts +++ b/test/interpreter/function-odd.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ODD', () => { diff --git a/test/interpreter/function-or.spec.ts b/test/interpreter/function-or.spec.ts index d98231e8e0..cff8d05a15 100644 --- a/test/interpreter/function-or.spec.ts +++ b/test/interpreter/function-or.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function OR', () => { diff --git a/test/interpreter/function-radians.spec.ts b/test/interpreter/function-radians.spec.ts index 4ceccee01f..e62f431012 100644 --- a/test/interpreter/function-radians.spec.ts +++ b/test/interpreter/function-radians.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function RADIANS', () => { diff --git a/test/interpreter/function-rand.spec.ts b/test/interpreter/function-rand.spec.ts index d34e457a69..a478805e9d 100644 --- a/test/interpreter/function-rand.spec.ts +++ b/test/interpreter/function-rand.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Interpreter - function RAND', () => { diff --git a/test/interpreter/function-round.spec.ts b/test/interpreter/function-round.spec.ts index e449a132e3..20f5057beb 100644 --- a/test/interpreter/function-round.spec.ts +++ b/test/interpreter/function-round.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ROUND', () => { diff --git a/test/interpreter/function-rounddown.spec.ts b/test/interpreter/function-rounddown.spec.ts index 6f95e4dea6..9e6b072bfd 100644 --- a/test/interpreter/function-rounddown.spec.ts +++ b/test/interpreter/function-rounddown.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ROUNDDOWN', () => { diff --git a/test/interpreter/function-roundup.spec.ts b/test/interpreter/function-roundup.spec.ts index 0035d41302..17e3932fb9 100644 --- a/test/interpreter/function-roundup.spec.ts +++ b/test/interpreter/function-roundup.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ROUNDUP', () => { diff --git a/test/interpreter/function-rows.spec.ts b/test/interpreter/function-rows.spec.ts index 18a5bcf66d..e0953558e0 100644 --- a/test/interpreter/function-rows.spec.ts +++ b/test/interpreter/function-rows.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function ROWS', () => { diff --git a/test/interpreter/function-sin.spec.ts b/test/interpreter/function-sin.spec.ts index 294cea9fbe..6eb0d4b8bf 100644 --- a/test/interpreter/function-sin.spec.ts +++ b/test/interpreter/function-sin.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function SIN', () => { diff --git a/test/interpreter/function-split.spec.ts b/test/interpreter/function-split.spec.ts index dbd215e27d..aba256b4c8 100644 --- a/test/interpreter/function-split.spec.ts +++ b/test/interpreter/function-split.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function SPLIT', () => { diff --git a/test/interpreter/function-sum.spec.ts b/test/interpreter/function-sum.spec.ts index 88d9b2021f..8d3d2ac916 100644 --- a/test/interpreter/function-sum.spec.ts +++ b/test/interpreter/function-sum.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('SUM', () => { diff --git a/test/interpreter/function-sumif.spec.ts b/test/interpreter/function-sumif.spec.ts index 628989c4c8..f9a779985e 100644 --- a/test/interpreter/function-sumif.spec.ts +++ b/test/interpreter/function-sumif.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' import {StatType} from '../../src/statistics' diff --git a/test/interpreter/function-sumproduct.spec.ts b/test/interpreter/function-sumproduct.spec.ts index 02ec5ad1ae..96d5db0e35 100644 --- a/test/interpreter/function-sumproduct.spec.ts +++ b/test/interpreter/function-sumproduct.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function SUMPRODUCT', () => { diff --git a/test/interpreter/function-sumsq.spec.ts b/test/interpreter/function-sumsq.spec.ts index 39aa7bd7f3..95a818e1a2 100644 --- a/test/interpreter/function-sumsq.spec.ts +++ b/test/interpreter/function-sumsq.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('SUMSQ', () => { diff --git a/test/interpreter/function-tan.spec.ts b/test/interpreter/function-tan.spec.ts index ef824eb322..0ffd4b0070 100644 --- a/test/interpreter/function-tan.spec.ts +++ b/test/interpreter/function-tan.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function TAN', () => { diff --git a/test/interpreter/function-text.spec.ts b/test/interpreter/function-text.spec.ts index 037d732fb0..d8bd76e953 100644 --- a/test/interpreter/function-text.spec.ts +++ b/test/interpreter/function-text.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {SimpleDateTime} from '../../src/DateTimeHelper' import {defaultStringifyDateTime} from '../../src/format/format' import {Maybe} from '../../src/Maybe' diff --git a/test/interpreter/function-true.spec.ts b/test/interpreter/function-true.spec.ts index 0611d7e78e..01e39d08b1 100644 --- a/test/interpreter/function-true.spec.ts +++ b/test/interpreter/function-true.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function TRUE', () => { diff --git a/test/interpreter/function-trunc.spec.ts b/test/interpreter/function-trunc.spec.ts index 6dd0838895..5cc1e602ed 100644 --- a/test/interpreter/function-trunc.spec.ts +++ b/test/interpreter/function-trunc.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function TRUNC', () => { diff --git a/test/interpreter/function-vlookup.spec.ts b/test/interpreter/function-vlookup.spec.ts index e1185aa390..ce689e2d79 100644 --- a/test/interpreter/function-vlookup.spec.ts +++ b/test/interpreter/function-vlookup.spec.ts @@ -2,9 +2,7 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' import {ConfigParams} from '../../src/Config' import {Sheet} from '../../src/GraphBuilder' -import '../testConfig.ts' import {adr, detailedError} from '../testUtils' - const sharedExamples = (builder: (sheet: Sheet, config?: Partial) => HyperFormula) => { describe('VLOOKUP - args validation', () => { it('not enough parameters', function() { diff --git a/test/interpreter/function-xor.spec.ts b/test/interpreter/function-xor.spec.ts index 959bac2d07..ff377ff095 100644 --- a/test/interpreter/function-xor.spec.ts +++ b/test/interpreter/function-xor.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function XOR', () => { diff --git a/test/interpreter/function-year.spec.ts b/test/interpreter/function-year.spec.ts index a491e7e75b..59dc2201d9 100644 --- a/test/interpreter/function-year.spec.ts +++ b/test/interpreter/function-year.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Function YEAR', () => { diff --git a/test/interpreter/matrix-plugin.spec.ts b/test/interpreter/matrix-plugin.spec.ts index 8a4ba66b98..c4553fad4f 100644 --- a/test/interpreter/matrix-plugin.spec.ts +++ b/test/interpreter/matrix-plugin.spec.ts @@ -1,9 +1,7 @@ import {EmptyValue, HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' import {MatrixPlugin} from '../../src/interpreter/plugin/MatrixPlugin' -import '../testConfig.ts' import {adr, detailedError} from '../testUtils' - const configWithMatrixPlugin = {functionPlugins: [MatrixPlugin]} describe('Matrix plugin', () => { diff --git a/test/interpreter/number-literals.spec.ts b/test/interpreter/number-literals.spec.ts index d95eab8f04..9ad8f8e2a0 100644 --- a/test/interpreter/number-literals.spec.ts +++ b/test/interpreter/number-literals.spec.ts @@ -1,7 +1,6 @@ import {HyperFormula} from '../../src' import {adr, detailedError} from '../testUtils' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {Config} from '../../src/Config' describe('Number literals', () => { @@ -42,7 +41,7 @@ describe('Number literals', () => { })) expect(engine.getCellValue(adr('A1'))).toEqual(1002.2) }) - + it('should work for multiple thousand separator in one literal', () => { const engine = HyperFormula.buildFromArray([['="1 000 000" + 2']], new Config({ thousandSeparator: ' ' @@ -63,4 +62,4 @@ describe('Number literals', () => { })) expect(engine.getCellValue(adr('A1'))).toEqual(1002.3) }) -}) \ No newline at end of file +}) diff --git a/test/interpreter/operator-concatenate.spec.ts b/test/interpreter/operator-concatenate.spec.ts index 973f6dcaeb..c18c889f33 100644 --- a/test/interpreter/operator-concatenate.spec.ts +++ b/test/interpreter/operator-concatenate.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Interpreter - concatenate operator', () => { diff --git a/test/interpreter/operator-division.spec.ts b/test/interpreter/operator-division.spec.ts index 51b1dc013e..152856559e 100644 --- a/test/interpreter/operator-division.spec.ts +++ b/test/interpreter/operator-division.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Operator DIVISION', () => { diff --git a/test/interpreter/operator-minus.spec.ts b/test/interpreter/operator-minus.spec.ts index 7876d601d1..a46c47ed59 100644 --- a/test/interpreter/operator-minus.spec.ts +++ b/test/interpreter/operator-minus.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Operator MINUS', () => { diff --git a/test/interpreter/operator-percent.spec.ts b/test/interpreter/operator-percent.spec.ts index b25f78ddb5..0a51665c7b 100644 --- a/test/interpreter/operator-percent.spec.ts +++ b/test/interpreter/operator-percent.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Percent operator', () => { diff --git a/test/interpreter/operator-plus.spec.ts b/test/interpreter/operator-plus.spec.ts index c0bf1269bd..25b009504e 100644 --- a/test/interpreter/operator-plus.spec.ts +++ b/test/interpreter/operator-plus.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Operator PLUS', () => { diff --git a/test/interpreter/operator-power.spec.ts b/test/interpreter/operator-power.spec.ts index ff24ddb2d2..31c955a7b1 100644 --- a/test/interpreter/operator-power.spec.ts +++ b/test/interpreter/operator-power.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Operator POWER', () => { diff --git a/test/interpreter/operator-times.spec.ts b/test/interpreter/operator-times.spec.ts index 1b889eb7b3..8cb6e3bb4e 100644 --- a/test/interpreter/operator-times.spec.ts +++ b/test/interpreter/operator-times.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Operator TIMES', () => { diff --git a/test/interpreter/operator-unary-minus.spec.ts b/test/interpreter/operator-unary-minus.spec.ts index c7c1dbb5fb..599e9e6ffb 100644 --- a/test/interpreter/operator-unary-minus.spec.ts +++ b/test/interpreter/operator-unary-minus.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Unary operator MINUS', () => { diff --git a/test/interpreter/operator-unary-plus.spec.ts b/test/interpreter/operator-unary-plus.spec.ts index fcb14215f6..b34577df62 100644 --- a/test/interpreter/operator-unary-plus.spec.ts +++ b/test/interpreter/operator-unary-plus.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../../src' import {ErrorType} from '../../src/Cell' -import '../testConfig' import {adr, detailedError} from '../testUtils' describe('Unary operator PLUS', () => { diff --git a/test/interpreter/precision.spec.ts b/test/interpreter/precision.spec.ts index c556bdbcc7..f9aa895b19 100644 --- a/test/interpreter/precision.spec.ts +++ b/test/interpreter/precision.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula} from '../../src' -import '../testConfig' import {adr} from '../testUtils' describe('Imprecise comparisons', () => { diff --git a/test/matrix-size-check.spec.ts b/test/matrix-size-check.spec.ts index 880c722d02..ae5d94a9fb 100644 --- a/test/matrix-size-check.spec.ts +++ b/test/matrix-size-check.spec.ts @@ -5,7 +5,6 @@ import {SheetMapping} from '../src/DependencyGraph' import {buildTranslationPackage, enGB} from '../src/i18n' import {checkMatrixSize, MatrixSize} from '../src/Matrix' import {ParserWithCaching} from '../src/parser' -import './testConfig.ts' import {adr} from './testUtils' describe('Matrix size check tests', () => { diff --git a/test/named-expressions.spec.ts b/test/named-expressions.spec.ts index bb6ea34080..788b49c176 100644 --- a/test/named-expressions.spec.ts +++ b/test/named-expressions.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula, ExportedNamedExpressionChange, EmptyValue} from '../src' -import './testConfig' import {adr, detailedError} from './testUtils' import {ErrorType} from '../src/Cell' diff --git a/test/parser/boolean-operators.spec.ts b/test/parser/boolean-operators.spec.ts index df1db066a8..d964cc337f 100644 --- a/test/parser/boolean-operators.spec.ts +++ b/test/parser/boolean-operators.spec.ts @@ -12,7 +12,6 @@ import { NotEqualOpAst, ParserWithCaching, } from '../../src/parser' -import '../testConfig' describe('Parser - Boolean operators', () => { it('Equals operator', () => { diff --git a/test/parser/concatenate-operator.spec.ts b/test/parser/concatenate-operator.spec.ts index f56bbb67d9..978318c418 100644 --- a/test/parser/concatenate-operator.spec.ts +++ b/test/parser/concatenate-operator.spec.ts @@ -3,7 +3,6 @@ import {Config} from '../../src/Config' import {SheetMapping} from '../../src/DependencyGraph' import {buildTranslationPackage, enGB} from '../../src/i18n' import {AstNodeType, ConcatenateOpAst, ParserWithCaching, ProcedureAst} from '../../src/parser' -import '../testConfig' describe('Parser - Concatenate operators', () => { it('Greater than operator', () => { diff --git a/test/parser/parser-caching.spec.ts b/test/parser/parser-caching.spec.ts index ba9f47ae35..ef5e0768d2 100644 --- a/test/parser/parser-caching.spec.ts +++ b/test/parser/parser-caching.spec.ts @@ -5,7 +5,6 @@ import {buildTranslationPackage, enGB} from '../../src/i18n' import { ParserWithCaching, } from '../../src/parser' -import '../testConfig' describe('ParserWithCaching - caching', () => { it('it use cache for similar formulas', () => { diff --git a/test/parser/parser.spec.ts b/test/parser/parser.spec.ts index f3e79f1a64..d9481ee277 100644 --- a/test/parser/parser.spec.ts +++ b/test/parser/parser.spec.ts @@ -29,7 +29,6 @@ import { import {ColumnAddress} from '../../src/parser/ColumnAddress' import {adr, unregisterAllLanguages} from '../testUtils' import {RowAddress} from '../../src/parser/RowAddress' -import '../testConfig' describe('ParserWithCaching', () => { beforeEach(() => { diff --git a/test/parser/percent-operator.spec.ts b/test/parser/percent-operator.spec.ts index 0453f7b6d0..8d67c97640 100644 --- a/test/parser/percent-operator.spec.ts +++ b/test/parser/percent-operator.spec.ts @@ -4,7 +4,6 @@ import {SheetMapping} from '../../src/DependencyGraph' import {buildTranslationPackage, enGB} from '../../src/i18n' import {AstNodeType, MinusUnaryOpAst, ParserWithCaching, PlusUnaryOpAst, PlusOpAst} from '../../src/parser' import {PercentOpAst, TimesOpAst} from '../../src/parser/Ast' -import '../testConfig' describe('percent', () => { it('should parse % as operator', () => { diff --git a/test/parser/range-offset.spec.ts b/test/parser/range-offset.spec.ts index 0ca0bf675b..68e84c5b54 100644 --- a/test/parser/range-offset.spec.ts +++ b/test/parser/range-offset.spec.ts @@ -4,7 +4,6 @@ import {buildTranslationPackage, enGB} from '../../src/i18n' import {AstNodeType, CellRangeAst, ParserWithCaching, ParsingErrorType} from '../../src/parser' import {RangeSheetReferenceType} from '../../src/parser/Ast' import {Config} from '../../src/Config' -import '../testConfig' describe('Parser - range offset', () => { it('OFFSET - usage with range', () => { diff --git a/test/parser/volatile-functions-detection.spec.ts b/test/parser/volatile-functions-detection.spec.ts index 1a93f94e43..305d7408e9 100644 --- a/test/parser/volatile-functions-detection.spec.ts +++ b/test/parser/volatile-functions-detection.spec.ts @@ -5,7 +5,6 @@ import {buildTranslationPackage, enGB} from '../../src/i18n' import { ParserWithCaching, } from '../../src/parser' -import '../testConfig' describe('ParserWithCaching - volatile functions detection', () => { it('detects volatile functions', () => { diff --git a/test/square-plugin-example.spec.ts b/test/square-plugin-example.spec.ts index 6d69fca778..216e03217d 100644 --- a/test/square-plugin-example.spec.ts +++ b/test/square-plugin-example.spec.ts @@ -2,7 +2,6 @@ import {HyperFormula} from '../src' import {CellError, ErrorType, SimpleCellAddress} from '../src/Cell' import {FunctionPlugin} from '../src/interpreter/plugin/FunctionPlugin' import {ProcedureAst} from '../src/parser' -import './testConfig.ts' import {adr, detailedError} from './testUtils' class SquarePlugin extends FunctionPlugin { diff --git a/test/temporary-formulas.spec.ts b/test/temporary-formulas.spec.ts index b4b0ded00e..e6150563f5 100644 --- a/test/temporary-formulas.spec.ts +++ b/test/temporary-formulas.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../src' import {ErrorType} from '../src/Cell' -import './testConfig' import {detailedError} from './testUtils' describe('Temporary formulas - normalization', () => { diff --git a/test/testConfig.ts b/test/testConfig.ts deleted file mode 100644 index b33b31eec7..0000000000 --- a/test/testConfig.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {HyperFormula} from '../src' -import {Config} from '../src/Config' -import {AlwaysSparse} from '../src/DependencyGraph/AddressMapping/ChooseAddressMappingPolicy' -import {languages} from '../src/i18n' -import {unregisterAllLanguages} from './testUtils' - -Config.defaultConfig = Object.assign({}, Config.defaultConfig, { - chooseAddressMappingPolicy: new AlwaysSparse(), - functionPlugins: [], - gpuMode: 'cpu', - matrixDetection: false, - useStats: true -}) - -beforeEach(() => { - unregisterAllLanguages() - const defaultLanguage = Config.defaultConfig.language - HyperFormula.registerLanguage(defaultLanguage, languages[defaultLanguage]) -}) diff --git a/test/undo-redo.spec.ts b/test/undo-redo.spec.ts index 1b2cb14ec4..6e685e6e9f 100644 --- a/test/undo-redo.spec.ts +++ b/test/undo-redo.spec.ts @@ -1,5 +1,4 @@ import {HyperFormula, NoOperationToUndo} from '../src' -import './testConfig' import { expectEngineToBeTheSameAs, } from './testUtils' diff --git a/test/volatile-functions.spec.ts b/test/volatile-functions.spec.ts index 2418d93bbc..4f3114309f 100644 --- a/test/volatile-functions.spec.ts +++ b/test/volatile-functions.spec.ts @@ -1,6 +1,5 @@ import {HyperFormula} from '../src' import {simpleCellAddress} from '../src/Cell' -import './testConfig' import {adr} from './testUtils' describe('Interpreter - function RAND', () => { From be8d9cc1ec0681fba41d444c73510adacc847c74 Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:41:07 +0200 Subject: [PATCH 2/6] Fix ESLint complains --- src/helpers/licenseKey.ts | 52 +++++++++---------- test/_setupFiles/globalSetup.ts | 9 ++-- test/helpers/licenseKey/agpl-v3.spec.ts | 4 +- .../licenseKey/invalid-agpl-version.spec.ts | 4 +- test/helpers/licenseKey/invalid-key.spec.ts | 4 +- test/helpers/licenseKey/missing-key.spec.ts | 4 +- .../licenseKey/non-commercial-key.spec.ts | 4 +- 7 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/helpers/licenseKey.ts b/src/helpers/licenseKey.ts index 9c1f89c3ac..2f8fcefeb7 100644 --- a/src/helpers/licenseKey.ts +++ b/src/helpers/licenseKey.ts @@ -1,14 +1,19 @@ +/** + * @license + * Copyright (c) 2020 Handsoncode. All rights reserved. + */ + // @ts-nocheck const consoleMessages = { - invalid: () => `The license key for HyperFormula is invalid.`, - expired: ({ keyValidityDate }) => `The license key for HyperFormula expired` + + invalid: () => 'The license key for HyperFormula is invalid.', + expired: ({ keyValidityDate }) => 'The license key for HyperFormula expired' + ` on ${keyValidityDate}, and is not valid for the installed version.`, - missing: () => `The license key for HyperFormula is missing.`, + missing: () => 'The license key for HyperFormula is missing.', } let _notified = false -export function checkLicenseKeyValidity(licenseKey) { +export function checkLicenseKeyValidity(licenseKey: string) { const messageDescriptor = { template: 'missing', args: {}, @@ -36,30 +41,23 @@ export function checkLicenseKeyValidity(licenseKey) { if (!_notified && messageDescriptor.template !== 'valid') { console.warn(consoleMessages[messageDescriptor.template](messageDescriptor.args)) - _notified = true; + _notified = true } } -const _rl = '\x6C\x65\x6E\x67\x74\x68' -const _hd = (v) => parseInt(v, 16) -const _pi = (v) => parseInt(v, 10) -const _nm = (v) => (v+'').replace(/\-/g, '') -const _ss = (v, s, l) => v['\x73\x75\x62\x73\x74\x72'](s, l) -const _cp = (v) => v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0) - 65 - -function _extractTime(v) { - return _nm(v)[_rl] === (50>>1) ? _hd(_ss(_nm(v), _hd('12'), _cp('\x46'))) / (_hd(_ss(_nm(v), _cp('C'), _cp('\x59')>>4)) || ((~~![][_rl])<<3) + 1) : 0; -}; -function _checkKeySchema(v: string): string { - v = (v+'').replace(/\-/g, ''); - - if (v[_rl] !== _cp('\x5A')) { - return false; - } - - let sp = 0; - - return [[0, _cp('\x47') + 1],[_cp('\x48'), _cp('\x48') - 1],[_cp('G') + _cp('H'), _cp('\x47')]].reduce((e, [a, b], c) => { - e|=(_pi(`${_pi(_hd(_ss(v, ...[sp + a - (c === (3>>2) ? 0 : 2), b + (!c ? 0 : 2)]))+(_hd(_ss(v, ...[sp + a + b, 2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp += 2;return e; - },_cp('A'))===([] + 1>>1); +/* eslint-disable */ +const _rl='\x6C\x65\x6E\x67\x74\x68' +const _hd=(v)=>parseInt(v,16) +const _pi=(v)=>parseInt(v,10) +const _nm=(v)=>(v+'').replace(/\-/g,'') +const _ss=(v,s,l)=>v['\x73\x75\x62\x73\x74\x72'](s,l) +const _cp=(v)=>v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0)-65 +function _extractTime(v) {return _nm(v)[_rl]===(50>>1)?_hd(_ss(_nm(v),_hd('12'),_cp('\x46')))/(_hd(_ss(_nm(v),_cp('C'),_cp('\x59')>>4))||((~~![][_rl])<<3)+1):0} +function _checkKeySchema(v) { + v = (v+'').replace(/\-/g, '') + if (v[_rl] !== _cp('\x5A')) {return false} + let sp = 0;return [[0,_cp('\x47')+1],[_cp('\x48'),_cp('\x48')-1],[_cp('G')+_cp('H'),_cp('\x47')]].reduce((e,[a,b],c)=>{ + e|=(_pi(`${_pi(_hd(_ss(v,...[sp+a-(c===(3>>2)?0:2),b+(!c?0:2)]))+(_hd(_ss(v,...[sp+a+b,2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp+=2;return e + },_cp('A'))===([]+1>>1) } +/* eslint-enable */ diff --git a/test/_setupFiles/globalSetup.ts b/test/_setupFiles/globalSetup.ts index 2742921fb1..15b56e7bc4 100644 --- a/test/_setupFiles/globalSetup.ts +++ b/test/_setupFiles/globalSetup.ts @@ -2,13 +2,14 @@ * This script file presents you the opportunity of running some code immediately * before the test framework has been installed in the environment. */ -export default async function() { - const htConfig = require('./../../ht.config'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const htConfig = require('./../../ht.config') +export default function() { // Extract all HF constants to the process environment namespance. // So the HT_RELEASE_DATE consts and other will be accessible while // testing the lib. Object.keys(htConfig).forEach((key) => { - process.env[key] = htConfig[key]; - }); + process.env[key] = htConfig[key] + }) } diff --git a/test/helpers/licenseKey/agpl-v3.spec.ts b/test/helpers/licenseKey/agpl-v3.spec.ts index e39dfc4292..100b430c99 100644 --- a/test/helpers/licenseKey/agpl-v3.spec.ts +++ b/test/helpers/licenseKey/agpl-v3.spec.ts @@ -6,13 +6,13 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', async () => { + it('should warn message about invalid key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ licenseKey: 'agpl-v3', }) - expect(console.warn).not.toHaveBeenCalled(); + expect(console.warn).not.toHaveBeenCalled() }) }) diff --git a/test/helpers/licenseKey/invalid-agpl-version.spec.ts b/test/helpers/licenseKey/invalid-agpl-version.spec.ts index 290944ea5b..c0d6f1b35b 100644 --- a/test/helpers/licenseKey/invalid-agpl-version.spec.ts +++ b/test/helpers/licenseKey/invalid-agpl-version.spec.ts @@ -6,13 +6,13 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', async () => { + it('should warn message about invalid key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ licenseKey: 'agpl-v1', }) - expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.'); + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.') }) }) diff --git a/test/helpers/licenseKey/invalid-key.spec.ts b/test/helpers/licenseKey/invalid-key.spec.ts index a4b1472a72..7ab25a53a4 100644 --- a/test/helpers/licenseKey/invalid-key.spec.ts +++ b/test/helpers/licenseKey/invalid-key.spec.ts @@ -6,13 +6,13 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', async () => { + it('should warn message about invalid key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ licenseKey: '11111-11111-11111-11111-11111', }) - expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.'); + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is invalid.') }) }) diff --git a/test/helpers/licenseKey/missing-key.spec.ts b/test/helpers/licenseKey/missing-key.spec.ts index baf3513701..b1d3d404d0 100644 --- a/test/helpers/licenseKey/missing-key.spec.ts +++ b/test/helpers/licenseKey/missing-key.spec.ts @@ -6,13 +6,13 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about missing key', async () => { + it('should warn message about missing key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ licenseKey: '', }) - expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is missing.'); + expect(console.warn).toHaveBeenCalledWith('The license key for HyperFormula is missing.') }) }) diff --git a/test/helpers/licenseKey/non-commercial-key.spec.ts b/test/helpers/licenseKey/non-commercial-key.spec.ts index 4cc39e2b72..127f71cc34 100644 --- a/test/helpers/licenseKey/non-commercial-key.spec.ts +++ b/test/helpers/licenseKey/non-commercial-key.spec.ts @@ -6,13 +6,13 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', async () => { + it('should warn message about invalid key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ licenseKey: 'non-commercial-and-evaluation', }) - expect(console.warn).not.toHaveBeenCalled(); + expect(console.warn).not.toHaveBeenCalled() }) }) From c2dccffa80a605a14361cf1d6336787f4d6f8793 Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Tue, 14 Apr 2020 11:01:30 +0200 Subject: [PATCH 3/6] Update tests description and remove whitespaces --- src/helpers/licenseKey.ts | 6 +++--- test/helpers/licenseKey/agpl-v3.spec.ts | 2 +- test/helpers/licenseKey/invalid-agpl-version.spec.ts | 2 +- test/helpers/licenseKey/invalid-key.spec.ts | 2 +- test/helpers/licenseKey/missing-key.spec.ts | 2 +- test/helpers/licenseKey/non-commercial-key.spec.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/helpers/licenseKey.ts b/src/helpers/licenseKey.ts index 2f8fcefeb7..7aaed5badf 100644 --- a/src/helpers/licenseKey.ts +++ b/src/helpers/licenseKey.ts @@ -54,9 +54,9 @@ const _ss=(v,s,l)=>v['\x73\x75\x62\x73\x74\x72'](s,l) const _cp=(v)=>v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0)-65 function _extractTime(v) {return _nm(v)[_rl]===(50>>1)?_hd(_ss(_nm(v),_hd('12'),_cp('\x46')))/(_hd(_ss(_nm(v),_cp('C'),_cp('\x59')>>4))||((~~![][_rl])<<3)+1):0} function _checkKeySchema(v) { - v = (v+'').replace(/\-/g, '') - if (v[_rl] !== _cp('\x5A')) {return false} - let sp = 0;return [[0,_cp('\x47')+1],[_cp('\x48'),_cp('\x48')-1],[_cp('G')+_cp('H'),_cp('\x47')]].reduce((e,[a,b],c)=>{ + v=(v+'').replace(/\-/g,'') + if(v[_rl]!==_cp('\x5A')){return false} + let sp=0;return [[0,_cp('\x47')+1],[_cp('\x48'),_cp('\x48')-1],[_cp('G')+_cp('H'),_cp('\x47')]].reduce((e,[a,b],c)=>{ e|=(_pi(`${_pi(_hd(_ss(v,...[sp+a-(c===(3>>2)?0:2),b+(!c?0:2)]))+(_hd(_ss(v,...[sp+a+b,2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp+=2;return e },_cp('A'))===([]+1>>1) } diff --git a/test/helpers/licenseKey/agpl-v3.spec.ts b/test/helpers/licenseKey/agpl-v3.spec.ts index 100b430c99..875a033d47 100644 --- a/test/helpers/licenseKey/agpl-v3.spec.ts +++ b/test/helpers/licenseKey/agpl-v3.spec.ts @@ -6,7 +6,7 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', () => { + it('should not warn a message about invalid key when "agpl-v3" is used', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ diff --git a/test/helpers/licenseKey/invalid-agpl-version.spec.ts b/test/helpers/licenseKey/invalid-agpl-version.spec.ts index c0d6f1b35b..86758db4a2 100644 --- a/test/helpers/licenseKey/invalid-agpl-version.spec.ts +++ b/test/helpers/licenseKey/invalid-agpl-version.spec.ts @@ -6,7 +6,7 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', () => { + it('should warn a message about invalid key when wrong "agpl" license version is used', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ diff --git a/test/helpers/licenseKey/invalid-key.spec.ts b/test/helpers/licenseKey/invalid-key.spec.ts index 7ab25a53a4..8581986f2b 100644 --- a/test/helpers/licenseKey/invalid-key.spec.ts +++ b/test/helpers/licenseKey/invalid-key.spec.ts @@ -6,7 +6,7 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', () => { + it('should warn a message about invalid key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ diff --git a/test/helpers/licenseKey/missing-key.spec.ts b/test/helpers/licenseKey/missing-key.spec.ts index b1d3d404d0..ce3974d1e6 100644 --- a/test/helpers/licenseKey/missing-key.spec.ts +++ b/test/helpers/licenseKey/missing-key.spec.ts @@ -6,7 +6,7 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about missing key', () => { + it('should warn a message about missing key', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ diff --git a/test/helpers/licenseKey/non-commercial-key.spec.ts b/test/helpers/licenseKey/non-commercial-key.spec.ts index 127f71cc34..a0588d2b77 100644 --- a/test/helpers/licenseKey/non-commercial-key.spec.ts +++ b/test/helpers/licenseKey/non-commercial-key.spec.ts @@ -6,7 +6,7 @@ import {HyperFormula} from '../../../src' describe('license key', () => { - it('should warn message about invalid key', () => { + it('should not warn a message about invalid key when "non-commercial-and-evaluation" is used', () => { spyOn(console, 'warn') HyperFormula.buildEmpty({ From f62e71ef3b501de2d836f0c1409bdd420af0fc47 Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Wed, 15 Apr 2020 11:09:28 +0200 Subject: [PATCH 4/6] Add licenseKeyValidityState prop to the Config Adds "licenseKeyValidityState" property to the Config class. The property holds a state about checking the license key validity. The property is protected from modification by defining its getter only. Additionally, the commit adds TS definition for the licenseKey checker helper and the result of the expired message is formatted better. --- src/BuildEngineFactory.ts | 3 -- src/Config.ts | 17 +++++++ src/helpers/_licenseKey.ts | 22 +++++++++ src/helpers/licenseKey.ts | 99 ++++++++++++++++++++++++++------------ 4 files changed, 107 insertions(+), 34 deletions(-) create mode 100644 src/helpers/_licenseKey.ts diff --git a/src/BuildEngineFactory.ts b/src/BuildEngineFactory.ts index 77f6777fbf..7b26b936af 100644 --- a/src/BuildEngineFactory.ts +++ b/src/BuildEngineFactory.ts @@ -19,7 +19,6 @@ import {NumberLiteralHelper} from './NumberLiteralHelper' import {buildLexerConfig, ParserWithCaching, Unparser} from './parser' import {Serialization} from './Serialization' import {EmptyStatistics, Statistics, StatType} from './statistics' -import {checkLicenseKeyValidity} from './helpers/licenseKey' export type EngineState = { config: Config, @@ -39,8 +38,6 @@ export type EngineState = { export class BuildEngineFactory { private static buildEngine(config: Config, sheets: Sheets = {}, stats: Statistics = config.useStats ? new Statistics() : new EmptyStatistics()): EngineState { - checkLicenseKeyValidity(config.licenseKey) - stats.start(StatType.BUILD_ENGINE_TOTAL) const lazilyTransformingAstService = new LazilyTransformingAstService(stats) diff --git a/src/Config.ts b/src/Config.ts index 945e0968b9..5b83bf3840 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -46,6 +46,7 @@ import {TrigonometryPlugin} from './interpreter/plugin/TrigonometryPlugin' import {VlookupPlugin} from './interpreter/plugin/VlookupPlugin' import {Maybe} from './Maybe' import {ParserConfig} from './parser/ParserConfig' +import {LicenseKeyValidityState, checkLicenseKeyValidity} from './helpers/licenseKey' type GPUMode = 'gpu' | 'cpu' | 'dev' @@ -459,6 +460,21 @@ export class Config implements ConfigParams, ParserConfig { * @internal */ public readonly translationPackage: TranslationPackage + /** + * Set automatically based on licenseKey checking result. + * + * @internal + */ + #licenseKeyValidityState: LicenseKeyValidityState + /** + * Proxied property to its private counterpart. This makes the property + * as accessible as the other Config options but without ability to change the value. + * + * @internal + */ + public get licenseKeyValidityState() { + return this.#licenseKeyValidityState; + } constructor( { @@ -504,6 +520,7 @@ export class Config implements ConfigParams, ParserConfig { this.decimalSeparator = this.valueFromParam(decimalSeparator, ['.', ','], 'decimalSeparator') this.language = this.valueFromParam(language, 'string', 'language') this.licenseKey = this.valueFromParam(licenseKey, 'string', 'licenseKey') + this.#licenseKeyValidityState = checkLicenseKeyValidity(this.licenseKey); this.thousandSeparator = this.valueFromParam(thousandSeparator, ['', ',', ' ', '.'], 'thousandSeparator') this.localeLang = this.valueFromParam(localeLang, 'string', 'localeLang') this.functionPlugins = functionPlugins ?? Config.defaultConfig.functionPlugins diff --git a/src/helpers/_licenseKey.ts b/src/helpers/_licenseKey.ts new file mode 100644 index 0000000000..350f98782f --- /dev/null +++ b/src/helpers/_licenseKey.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright (c) 2020 Handsoncode. All rights reserved. + */ + +// @ts-nocheck +/* eslint-disable */ +const _rl='\x6C\x65\x6E\x67\x74\x68' +const _hd=(v)=>parseInt(v,16) +const _pi=(v)=>parseInt(v,10) +const _nm=(v)=>(v+'').replace(/\-/g,'') +const _ss=(v,s,l)=>v['\x73\x75\x62\x73\x74\x72'](s,l) +const _cp=(v)=>v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0)-65 +export function extractTime(v) {return _nm(v)[_rl]===(50>>1)?_hd(_ss(_nm(v),_hd('12'),_cp('\x46')))/(_hd(_ss(_nm(v),_cp('C'),_cp('\x59')>>4))||((~~![][_rl])<<3)+1):0} +export function checkKeySchema(v) { + v=(v+'').replace(/\-/g,'') + if(v[_rl]!==_cp('\x5A')){return false} + let sp=0;return [[0,_cp('\x47')+1],[_cp('\x48'),_cp('\x48')-1],[_cp('G')+_cp('H'),_cp('\x47')]].reduce((e,[a,b],c)=>{ + e|=(_pi(`${_pi(_hd(_ss(v,...[sp+a-(c===(3>>2)?0:2),b+(!c?0:2)]))+(_hd(_ss(v,...[sp+a+b,2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp+=2;return e + },_cp('A'))===([]+1>>1) +} +/* eslint-enable */ diff --git a/src/helpers/licenseKey.ts b/src/helpers/licenseKey.ts index 7aaed5badf..c0f607d74f 100644 --- a/src/helpers/licenseKey.ts +++ b/src/helpers/licenseKey.ts @@ -3,8 +3,37 @@ * Copyright (c) 2020 Handsoncode. All rights reserved. */ -// @ts-nocheck -const consoleMessages = { +import {extractTime, checkKeySchema} from './_licenseKey' + +/** + * The list of all available states which the license checker can return. + */ +export const enum LicenseKeyValidityState { + VALID = 'valid', + INVALID = 'invalid', + EXPIRED = 'expired', + MISSING = 'missing' +} + +type LicenseKeyInvalidState = Exclude + +interface TemplateVars { + [key: string]: string; +} + +type ConsoleMessages = { + [key in LicenseKeyInvalidState]: (templateVars: TemplateVars) => string +} + +type MessageDescriptor = { + template: LicenseKeyValidityState + vars: TemplateVars +} + +/** + * List of all not valid messages which may occur. + */ +const consoleMessages: ConsoleMessages = { invalid: () => 'The license key for HyperFormula is invalid.', expired: ({ keyValidityDate }) => 'The license key for HyperFormula expired' + ` on ${keyValidityDate}, and is not valid for the installed version.`, @@ -13,51 +42,59 @@ const consoleMessages = { let _notified = false -export function checkLicenseKeyValidity(licenseKey: string) { - const messageDescriptor = { - template: 'missing', - args: {}, +/** + * Checks if the provided license key is grammatically valid or not expired. + * + * @param {string} licenseKey The license key to check. + * @returns {LicenseKeyValidityState} Returns the checking state. + */ +export function checkLicenseKeyValidity(licenseKey: string): LicenseKeyValidityState { + const messageDescriptor: MessageDescriptor = { + template: LicenseKeyValidityState.MISSING, + vars: {}, } if (licenseKey === 'non-commercial-and-evaluation' || licenseKey === 'agpl-v3') { - messageDescriptor.template = 'valid' + messageDescriptor.template = LicenseKeyValidityState.VALID - } else if (typeof licenseKey === 'string' && _checkKeySchema(licenseKey)) { - const [day, month, year] = process.env.HT_RELEASE_DATE.split('/') + } else if (typeof licenseKey === 'string' && checkKeySchema(licenseKey)) { + const [day, month, year] = (process.env.HT_RELEASE_DATE || '').split('/') const releaseDays = Math.floor(new Date(`${month}/${day}/${year}`).getTime() / 8.64e7) - const keyValidityDays = _extractTime(licenseKey) + const keyValidityDays = extractTime(licenseKey) - messageDescriptor.args.keyValidityDate = new Date((keyValidityDays + 1) * 8.64e7).toISOString() + messageDescriptor.vars.keyValidityDate = formatDate(new Date((keyValidityDays + 1) * 8.64e7)) if (releaseDays > keyValidityDays) { - messageDescriptor.template = 'expired' + messageDescriptor.template = LicenseKeyValidityState.EXPIRED } else { - messageDescriptor.template = 'valid' + messageDescriptor.template = LicenseKeyValidityState.VALID } } else if (licenseKey !== '') { - messageDescriptor.template = 'invalid' + messageDescriptor.template = LicenseKeyValidityState.INVALID } - if (!_notified && messageDescriptor.template !== 'valid') { - console.warn(consoleMessages[messageDescriptor.template](messageDescriptor.args)) + if (!_notified && messageDescriptor.template !== LicenseKeyValidityState.VALID) { + console.warn(consoleMessages[messageDescriptor.template](messageDescriptor.vars)) _notified = true } + + return messageDescriptor.template; } -/* eslint-disable */ -const _rl='\x6C\x65\x6E\x67\x74\x68' -const _hd=(v)=>parseInt(v,16) -const _pi=(v)=>parseInt(v,10) -const _nm=(v)=>(v+'').replace(/\-/g,'') -const _ss=(v,s,l)=>v['\x73\x75\x62\x73\x74\x72'](s,l) -const _cp=(v)=>v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0)-65 -function _extractTime(v) {return _nm(v)[_rl]===(50>>1)?_hd(_ss(_nm(v),_hd('12'),_cp('\x46')))/(_hd(_ss(_nm(v),_cp('C'),_cp('\x59')>>4))||((~~![][_rl])<<3)+1):0} -function _checkKeySchema(v) { - v=(v+'').replace(/\-/g,'') - if(v[_rl]!==_cp('\x5A')){return false} - let sp=0;return [[0,_cp('\x47')+1],[_cp('\x48'),_cp('\x48')-1],[_cp('G')+_cp('H'),_cp('\x47')]].reduce((e,[a,b],c)=>{ - e|=(_pi(`${_pi(_hd(_ss(v,...[sp+a-(c===(3>>2)?0:2),b+(!c?0:2)]))+(_hd(_ss(v,...[sp+a+b,2]))+[]).padStart(2,'0'))}`)%97||2)>>1;sp+=2;return e - },_cp('A'))===([]+1>>1) +/** + * Formats a Date instance to hard-coded format MMMM DD, YYYY. + * + * @param {Date} date The date to format. + * @returns {string} + */ +function formatDate(date: Date): string { + const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' + ] + const month = monthNames[date.getMonth()]; + const day = date.getDate(); + const year = date.getFullYear(); + + return `${month} ${day}, ${year}` } -/* eslint-enable */ From 7f36ae0dd7dd274ac34cfbe2a89415886ccbd372 Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Wed, 15 Apr 2020 11:18:09 +0200 Subject: [PATCH 5/6] Fix eslint complains --- src/helpers/licenseKey.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/helpers/licenseKey.ts b/src/helpers/licenseKey.ts index c0f607d74f..4e23c518ca 100644 --- a/src/helpers/licenseKey.ts +++ b/src/helpers/licenseKey.ts @@ -18,7 +18,7 @@ export const enum LicenseKeyValidityState { type LicenseKeyInvalidState = Exclude interface TemplateVars { - [key: string]: string; + [key: string]: string, } type ConsoleMessages = { @@ -26,8 +26,8 @@ type ConsoleMessages = { } type MessageDescriptor = { - template: LicenseKeyValidityState - vars: TemplateVars + template: LicenseKeyValidityState, + vars: TemplateVars, } /** @@ -79,7 +79,7 @@ export function checkLicenseKeyValidity(licenseKey: string): LicenseKeyValidityS _notified = true } - return messageDescriptor.template; + return messageDescriptor.template } /** @@ -92,9 +92,9 @@ function formatDate(date: Date): string { const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] - const month = monthNames[date.getMonth()]; - const day = date.getDate(); - const year = date.getFullYear(); + const month = monthNames[date.getMonth()] + const day = date.getDate() + const year = date.getFullYear() return `${month} ${day}, ${year}` } From 36ea75bd3073a28c5676ed9830779a8481b6994c Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Wed, 15 Apr 2020 11:25:54 +0200 Subject: [PATCH 6/6] Remove extra semicolons --- src/Config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Config.ts b/src/Config.ts index 5b83bf3840..d8cdf04036 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -473,7 +473,7 @@ export class Config implements ConfigParams, ParserConfig { * @internal */ public get licenseKeyValidityState() { - return this.#licenseKeyValidityState; + return this.#licenseKeyValidityState } constructor( @@ -520,7 +520,7 @@ export class Config implements ConfigParams, ParserConfig { this.decimalSeparator = this.valueFromParam(decimalSeparator, ['.', ','], 'decimalSeparator') this.language = this.valueFromParam(language, 'string', 'language') this.licenseKey = this.valueFromParam(licenseKey, 'string', 'licenseKey') - this.#licenseKeyValidityState = checkLicenseKeyValidity(this.licenseKey); + this.#licenseKeyValidityState = checkLicenseKeyValidity(this.licenseKey) this.thousandSeparator = this.valueFromParam(thousandSeparator, ['', ',', ' ', '.'], 'thousandSeparator') this.localeLang = this.valueFromParam(localeLang, 'string', 'localeLang') this.functionPlugins = functionPlugins ?? Config.defaultConfig.functionPlugins