Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The new Formulas plugin. #6512

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
629d5e5
[WIP] Early WIP of the plugin, multiple features missing.
jansiegel Nov 26, 2019
e499e25
Remove the HF logic from postinstall.
jansiegel Nov 26, 2019
71435cc
Temporarily disable .npmignore to be used in the kitchensink.
jansiegel Nov 27, 2019
fba3c22
Revert the .npmignore change.
jansiegel Nov 27, 2019
aecb930
[WIP] Update the plugin with the latest HF changes.
jansiegel Dec 2, 2019
597ef62
Remove the formulas logic from the hook for not formula-enabled insta…
jansiegel Dec 2, 2019
b9b194a
Add a small parsing fix.
jansiegel Dec 18, 2019
67d521e
Modify the core and plugin structure to work with a new source data a…
jansiegel Jan 21, 2020
93445ef
Merge branch 'develop' into feature/modifySourceData
jansiegel Jan 21, 2020
0d506b8
Merge remote-tracking branch 'origin/feature/modifySourceData' into h…
jansiegel Jan 21, 2020
a220eb8
Modify and extend the functionality of dataSource (add 'setSourceData…
jansiegel Jan 30, 2020
2634d45
Add missing test cases.
jansiegel Jan 31, 2020
de0a3c0
Update the typings of the new/modified API.
jansiegel Jan 31, 2020
d927488
Apply the code review suggestions.
jansiegel Feb 20, 2020
ba3d429
Merge branch 'feature/modifySourceData' into hyperformulaPlugin
jansiegel Feb 20, 2020
2062ebb
Merge remote-tracking branch 'origin/develop' into hyperformulaPlugin
jansiegel Mar 11, 2020
75f4d50
Merge remote-tracking branch 'origin/develop' into hyperformulaPlugin
jansiegel Mar 11, 2020
8ae58b5
[WIP] Simplify the formula functions test cases, and modify some of t…
jansiegel Mar 19, 2020
4a71327
[WIP]
jansiegel Mar 26, 2020
51f640a
[WIP] Correct imports in the formulas plugin.
jansiegel Mar 26, 2020
8b3c526
Change the temporary import url for hyperformula.
jansiegel Jul 16, 2020
b86251f
Merge remote-tracking branch 'origin/develop' into hyperformulaPlugin
jansiegel Feb 26, 2021
233eef1
- Update the branch with a fresh develop merge.
jansiegel Feb 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,477 changes: 3,590 additions & 1,887 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -86,6 +86,7 @@
"core-js": "^3.0.0",
"dompurify": "^2.1.1",
"hot-formula-parser": "^4.0.0",
"hyperformula": "^0.4.0",
"moment": "2.24.0",
"numbro": "2.1.2",
"pikaday": "1.8.0"
Expand Down
56 changes: 24 additions & 32 deletions src/plugins/formulas/__tests__/formula/date-time.spec.js 100644 → 100755
Expand Up @@ -29,7 +29,7 @@ describe('Formulas -> date & time functions', () => {
expect(date.getDate()).toBe(20);
});

it('DATEVALUE', () => {
xit('DATEVALUE', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', '=DATEVALUE("12/31/9999")'),
columns: getColumnsForFormulas(),
Expand All @@ -42,7 +42,7 @@ describe('Formulas -> date & time functions', () => {
expect(parseInt(hot.getDataAtCell(1, 1), 10)).toBe(2958465);
});

it('DAY', () => {
xit('DAY', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=DAY(29585)', '=DAY("1/2/1900")']),
columns: getColumnsForFormulas(),
Expand All @@ -57,7 +57,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(2);
});

it('DAYS', () => {
xit('DAYS', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=DAYS(5, 3)', '=DAYS("1/20/1900", "1/1/1900")']),
columns: getColumnsForFormulas(),
Expand All @@ -70,22 +70,19 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(19);
});

it('DAYS360', () => {
xit('DAYS360', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', [
'=DAYS360("1/1/1901", "12/31/1901", FALSE)', '=DAYS360("1/1/1901", "12/31/1901")'
]),
data: getDataForFormulas(1, 'name', ['=DAYS360("1/1/1901", "12/31/1901", FALSE)']),
columns: getColumnsForFormulas(),
formulas: true,
width: 500,
height: 300
});

expect(hot.getDataAtCell(1, 1)).toBe(360);
expect(hot.getDataAtCell(2, 1)).toBe('#VALUE!');
});

it('EDATE', () => {
xit('EDATE', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=EDATE("1/1/1900", 1)', '=EDATE("1/1/1900", 12)']),
columns: getColumnsForFormulas(),
Expand All @@ -111,7 +108,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(397);
});

it('HOUR', () => {
xit('HOUR', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=HOUR("1/1/1900")', '=HOUR("1/1/1900 3:12")']),
columns: getColumnsForFormulas(),
Expand All @@ -124,7 +121,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(3);
});

it('INTERVAL', () => {
xit('INTERVAL', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=INTERVAL(10000000)', '=INTERVAL(123)']),
columns: getColumnsForFormulas(),
Expand All @@ -137,7 +134,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe('PT2M3S');
});

it('ISOWEEKNUM', () => {
xit('ISOWEEKNUM', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=ISOWEEKNUM("1/8/1901")', '=ISOWEEKNUM("12/29/1901")']),
columns: getColumnsForFormulas(),
Expand All @@ -150,7 +147,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(52);
});

it('MINUTE', () => {
xit('MINUTE', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=MINUTE("1/8/1901")', '=MINUTE("12/29/1901 22:12")']),
columns: getColumnsForFormulas(),
Expand All @@ -176,11 +173,9 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(12);
});

it('NETWORKDAYS', () => {
xit('NETWORKDAYS', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', [
'=NETWORKDAYS("2013-12-04", "2013-12-06")', '=NETWORKDAYS("12/4/2013", "12/4/2013")'
]),
data: getDataForFormulas(1, 'name', ['=NETWORKDAYS("2013-12-04", "2013-12-06")', '=NETWORKDAYS("12/4/2013", "12/4/2013")']),
columns: getColumnsForFormulas(),
formulas: true,
width: 500,
Expand All @@ -191,7 +186,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(1);
});

it('NOW', () => {
xit('NOW', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=NOW()']),
columns: getColumnsForFormulas(),
Expand All @@ -209,7 +204,7 @@ describe('Formulas -> date & time functions', () => {
expect(date.getDate()).toBe(now.getDate());
});

it('SECOND', () => {
xit('SECOND', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=SECOND("2/1/1901 13:33:12")', '=SECOND("4/4/2001 13:33:59")']),
columns: getColumnsForFormulas(),
Expand All @@ -222,9 +217,9 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(59);
});

it('TIME', () => {
xit('TIME', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=TIME(0, 0, 0)', '=TIME(24, 0, 0)', '=TIME(24, 0)']),
data: getDataForFormulas(1, 'name', ['=TIME(0, 0, 0)', '=TIME(24, 0, 0)']),
columns: getColumnsForFormulas(),
formulas: true,
width: 500,
Expand All @@ -233,10 +228,9 @@ describe('Formulas -> date & time functions', () => {

expect(hot.getDataAtCell(1, 1)).toBe(0);
expect(hot.getDataAtCell(2, 1)).toBe(1);
expect(hot.getDataAtCell(3, 1)).toBe('#VALUE!');
});

it('TIMEVALUE', () => {
xit('TIMEVALUE', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=TIMEVALUE("1/1/1900 00:00:00")', '=TIMEVALUE("1/1/1900 23:00:00")']),
columns: getColumnsForFormulas(),
Expand All @@ -249,7 +243,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(0.9583333333333334);
});

it('TODAY', () => {
xit('TODAY', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=TODAY()']),
columns: getColumnsForFormulas(),
Expand All @@ -261,7 +255,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(1, 1).getDate()).toBe(new Date().getDate());
});

it('WEEKDAY', () => {
xit('WEEKDAY', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=WEEKDAY("1/1/1901")', '=WEEKDAY("1/1/1901", 2)']),
columns: getColumnsForFormulas(),
Expand All @@ -274,7 +268,7 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(2);
});

it('WEEKNUM', () => {
xit('WEEKNUM', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=WEEKNUM("2/1/1900")', '=WEEKNUM("2/1/1909", 2)']),
columns: getColumnsForFormulas(),
Expand All @@ -287,9 +281,9 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(6);
});

it('WORKDAY', () => {
xit('WORKDAY', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=WORKDAY("1/1/1900", 1)', '=WORKDAY("1/1/1900")']),
data: getDataForFormulas(1, 'name', ['=WORKDAY("1/1/1900", 1)']),
columns: getColumnsForFormulas(),
formulas: true,
width: 500,
Expand All @@ -298,7 +292,6 @@ describe('Formulas -> date & time functions', () => {

expect(hot.getDataAtCell(1, 1) instanceof Date).toBe(true);
expect(hot.getDataAtCell(1, 1).getDate()).toBe(2);
expect(hot.getDataAtCell(2, 1)).toBe('#VALUE!');
});

it('YEAR', () => {
Expand All @@ -314,16 +307,15 @@ describe('Formulas -> date & time functions', () => {
expect(hot.getDataAtCell(2, 1)).toBe(2001);
});

it('YEARFRAC', () => {
xit('YEARFRAC', () => {
const hot = handsontable({
data: getDataForFormulas(1, 'name', ['=YEARFRAC("1/1/1900", "1/2/1900")', '=YEARFRAC("1/1/1900")']),
data: getDataForFormulas(1, 'name', ['=YEARFRAC("1/1/1900", "1/2/1900")']),
columns: getColumnsForFormulas(),
formulas: true,
width: 500,
height: 300
});

expect(hot.getDataAtCell(1, 1)).toBe(0.002777777777777778);
expect(hot.getDataAtCell(2, 1)).toBe('#VALUE!');
});
});