A local-first personal finance app
:bug: making desktop-client tests independent (#765)
Matiss Janis Aboltinsd9bc64e792b7
diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js b/packages/desktop-client/src/components/accounts/TransactionsTable.test.jsindex 75249bc395..742c42ed0d 100644--- a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js+++ b/packages/desktop-client/src/components/accounts/TransactionsTable.test.js@@ -785,7 +785,6 @@ describe('Transactions', () => {expect(getTransactions()[1].amount).toBe(-4500);expect(getTransactions()[2].is_child).toBe(true);expect(getTransactions()[2].amount).toBe(-1000);- expect(getTransactions().slice(0, 3)).toMatchSnapshot();});test('escape closes the new transaction rows', () => {@@ -922,7 +921,48 @@ describe('Transactions', () => {// This snapshot makes sure the data is as we expect. It also// shows the sort order and makes sure that is correct- expect(getTransactions().slice(0, 3)).toMatchSnapshot();+ const parentId = getTransactions()[0].id;+ expect(getTransactions().slice(0, 3)).toEqual([+ {+ account: accounts[0].id,+ amount: -2777,+ category: null,+ cleared: false,+ date: '2017-01-01',+ error: null,+ id: expect.any(String),+ is_parent: true,+ notes: 'Notes',+ payee: 'payed-to',+ sort_order: 0,+ },+ {+ account: accounts[0].id,+ amount: -1000,+ cleared: false,+ date: '2017-01-01',+ error: null,+ id: expect.any(String),+ is_child: true,+ parent_id: parentId,+ payee: 'payed-to',+ sort_order: -1,+ starting_balance_flag: null,+ },+ {+ account: accounts[0].id,+ amount: -1777,+ cleared: false,+ date: '2017-01-01',+ error: null,+ id: expect.any(String),+ is_child: true,+ parent_id: parentId,+ payee: 'payed-to',+ sort_order: -2,+ starting_balance_flag: null,+ },+ ]);// Make sure deleting a split transaction updates the state again,// and deleting all split transactions turns it into a normaldiff --git a/packages/desktop-client/src/components/accounts/__snapshots__/TransactionsTable.test.js.snap b/packages/desktop-client/src/components/accounts/__snapshots__/TransactionsTable.test.js.snapdeleted file mode 100644index 31a291ce97..0000000000--- a/packages/desktop-client/src/components/accounts/__snapshots__/TransactionsTable.test.js.snap+++ /dev/null@@ -1,85 +0,0 @@-// Jest Snapshot v1, https://goo.gl/fbAQLP--exports[`Transactions adding a new split transaction works 1`] = `-Array [- Object {- "account": "testing-uuid-975046",- "amount": -5500,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-759284",- "is_parent": true,- },- Object {- "account": "testing-uuid-975046",- "amount": -4500,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-57883",- "is_child": true,- "parent_id": "testing-uuid-759284",- "payee": undefined,- "sort_order": -1,- "starting_balance_flag": null,- },- Object {- "account": "testing-uuid-975046",- "amount": -1000,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-661157",- "is_child": true,- "parent_id": "testing-uuid-759284",- "payee": undefined,- "sort_order": -2,- "starting_balance_flag": null,- },-]-`;--exports[`Transactions transaction can be split, updated, and deleted 1`] = `-Array [- Object {- "account": "testing-uuid-975046",- "amount": -2777,- "category": null,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-795958",- "is_parent": true,- "notes": "Notes",- "payee": "guy",- "sort_order": 0,- },- Object {- "account": "testing-uuid-975046",- "amount": -1000,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-216379",- "is_child": true,- "parent_id": "testing-uuid-795958",- "payee": "guy",- "sort_order": -1,- "starting_balance_flag": null,- },- Object {- "account": "testing-uuid-975046",- "amount": -1777,- "cleared": false,- "date": "2017-01-01",- "error": null,- "id": "testing-uuid-482499",- "is_child": true,- "parent_id": "testing-uuid-795958",- "payee": "guy",- "sort_order": -2,- "starting_balance_flag": null,- },-]-`;diff --git a/packages/loot-design/src/setupTests.js b/packages/loot-design/src/setupTests.jsindex 62079beb0b..a33a44c42a 100644--- a/packages/loot-design/src/setupTests.js+++ b/packages/loot-design/src/setupTests.js@@ -1,7 +1,5 @@import { resetStore } from 'loot-core/src/mocks/redux';-const uuid = require('loot-core/src/platform/uuid');-global.IS_TESTING = true;global.Actual = {};@@ -12,26 +10,9 @@ jest.mock(children({ height: 1000, width: 600 }),);-// Why 2? There were already tests written assuming a specific-// transaction is negative, and 1 doesn't give me that data.-let seed = 2;-Math.random = function random() {- var x = Math.sin(seed++) * 10000;- return x - Math.floor(x);-};-global.Date.now = () => 123456789;-uuid.v4 = function () {- return Promise.resolve('testing-uuid-' + Math.floor(Math.random() * 1000000));-};--uuid.v4Sync = function () {- return 'testing-uuid-' + Math.floor(Math.random() * 1000000);-};-global.__resetWorld = () => {- seed = 2;resetStore();};diff --git a/upcoming-release-notes/765.md b/upcoming-release-notes/765.mdnew file mode 100644index 0000000000..a4e2b167f1--- /dev/null+++ b/upcoming-release-notes/765.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Make desktop-client integration tests independent