From 840f3327431708e4779b03ea9aa67ef6d2ae85df Mon Sep 17 00:00:00 2001 From: Will McVay Date: Fri, 11 Oct 2019 12:05:57 +0100 Subject: [PATCH 1/2] [CLD-291] A few width tweaks --- package.json | 2 +- src/styles/pages/map.scss | 8 +-- src/styles/pages/page-container.scss | 2 +- src/styles/utilities.scss | 96 ---------------------------- 4 files changed, 6 insertions(+), 102 deletions(-) delete mode 100644 src/styles/utilities.scss diff --git a/package.json b/package.json index a0acca2070..10dd795745 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test-e2e:ci": "concurrently --success=\"first\" \"yarn start\" \"yarn test-e2e\" -k" }, "dependencies": { - "@reapit/elements": "^0.4.15", + "@reapit/elements": "^0.4.21", "dayjs": "^1.8.16", "formik": "^1.5.8", "hardtack": "^4.1.0", diff --git a/src/styles/pages/map.scss b/src/styles/pages/map.scss index 21a8424117..4d8ae74554 100644 --- a/src/styles/pages/map.scss +++ b/src/styles/pages/map.scss @@ -3,8 +3,8 @@ .mapContainer { overflow: hidden; position: absolute; - left: 366px; - width: calc(100vw - 366px); + left: 382px; + width: calc(100vw - 376px); top: 0; height: 100%; @@ -49,8 +49,8 @@ .mapPanel { position: absolute; bottom: 0; - width: calc(100vw - 366px); - left: 366px; + width: calc(100vw - 382px); + left: 382px; display: flex; background-color: #fff; padding: 1.5rem; diff --git a/src/styles/pages/page-container.scss b/src/styles/pages/page-container.scss index 04f35ce8fd..7e62eeafe6 100644 --- a/src/styles/pages/page-container.scss +++ b/src/styles/pages/page-container.scss @@ -28,7 +28,7 @@ position: absolute; background:rgb(249, 251, 253); height: 100%; - width: 300px; + width: 316px; left: 66px; top: 0; overflow: scroll; diff --git a/src/styles/utilities.scss b/src/styles/utilities.scss deleted file mode 100644 index c0ef37a916..0000000000 --- a/src/styles/utilities.scss +++ /dev/null @@ -1,96 +0,0 @@ -$units: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; - -@each $unit in $units { - .mt-#{$unit} { - margin-top: ($unit * 1rem/4); - } - .mb-#{$unit} { - margin-bottom: ($unit * 1rem/4); - } - .ml-#{$unit} { - margin-left: ($unit * 1rem/4); - } - .mr-#{$unit} { - margin-right: ($unit * 1rem/4); - } - .mx-#{$unit} { - margin-left: ($unit * 1rem/4); - margin-right: ($unit * 1rem/4); - } - .my-#{$unit} { - margin-top: ($unit * 1rem/4); - margin-bottom: ($unit * 1rem/4); - } - - .pt-#{$unit} { - padding-top: ($unit * 1rem/4); - } - .pb-#{$unit} { - padding-bottom: ($unit * 1rem/4); - } - .pl-#{$unit} { - padding-left: ($unit * 1rem/4); - } - .pr-#{$unit} { - padding-right: ($unit * 1rem/4); - } - .px-#{$unit} { - padding-left: ($unit * 1rem/4); - padding-right: ($unit * 1rem/4); - } - .py-#{$unit} { - padding-top: ($unit * 1rem/4); - padding-bottom: ($unit * 1rem/4); - } -} - -.flex { - display: flex; -} - -.inline-flex { - display: inline-flex; -} - -.justify-between { - justify-content: space-between; -} - -.justify-center { - justify-content: center; -} - -.justify-end { - justify-content: flex-end; -} - -.items-center { - align-items: center; -} - -.text-center { - text-align: center; -} - -.pin { - left: 0; - top: 0; - right: 0; - bottom: 0; -} - -.absolute { - position: absolute; -} - -.relative { - position: relative; -} - -.capitalize { - text-transform: capitalize; -} - -.sticky { - position: sticky; -} From 6a2bcba15ef7714a44038e5fdf676f1d9ed13655 Mon Sep 17 00:00:00 2001 From: Will McVay Date: Fri, 11 Oct 2019 12:56:36 +0100 Subject: [PATCH 2/2] [CLD-291] Fixes tests --- package.json | 1 + src/sagas/__tests__/appointments.ts | 4 ++-- src/scripts/jest-setup.js | 10 +++++++--- src/utils/__tests__/get-next-appointments.ts | 8 ++++---- yarn.lock | 13 +++++++++---- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 10dd795745..2ff74ee1f5 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "lint-staged": "^8.1.7", "loader-utils": "^1.2.3", "mini-css-extract-plugin": "^0.7.0", + "mockdate": "^2.0.5", "node-sass": "^4.12.0", "prettier": "^1.17.1", "prettier-plugin-packagejson": "^2.0.1", diff --git a/src/sagas/__tests__/appointments.ts b/src/sagas/__tests__/appointments.ts index 606be443b7..ded4b6828c 100644 --- a/src/sagas/__tests__/appointments.ts +++ b/src/sagas/__tests__/appointments.ts @@ -52,7 +52,7 @@ describe('appointments should fetch data', () => { expect(gen.next(mockHeaders).value).toEqual( call(fetcher, { url: - '/appointments?Start=2019-12-18T00:00:00.000Z&End=2019-12-18T23:59:59.999Z&IncludeCancelled=true&IncludeUnconfirmed=true', + '/appointments?Start=2019-10-10T00:00:00.000Z&End=2019-10-10T23:59:59.999Z&IncludeCancelled=true&IncludeUnconfirmed=true', api: REAPIT_API_BASE_URL, method: 'GET', headers: mockHeaders @@ -93,7 +93,7 @@ describe('appointments should fetch data', () => { expect(gen.next(mockHeaders).value).toEqual( call(fetcher, { url: - '/appointments?Start=2019-12-18T00:00:00.000Z&End=2019-12-18T23:59:59.999Z&IncludeCancelled=true&IncludeUnconfirmed=true', + '/appointments?Start=2019-10-10T00:00:00.000Z&End=2019-10-10T23:59:59.999Z&IncludeCancelled=true&IncludeUnconfirmed=true', api: REAPIT_API_BASE_URL, method: 'GET', headers: mockHeaders diff --git a/src/scripts/jest-setup.js b/src/scripts/jest-setup.js index 589368f671..4688242b54 100644 --- a/src/scripts/jest-setup.js +++ b/src/scripts/jest-setup.js @@ -1,6 +1,7 @@ const Adapter = require('enzyme-adapter-react-16') const Enzyme = require('enzyme') const fetchMock = require('jest-fetch-mock') +const MockDate = require('mockdate') Enzyme.configure({ adapter: new Adapter() }) global.fetch = fetchMock @@ -38,6 +39,9 @@ window.matchMedia = } } -jest.mock('dayjs', () => - jest.fn((...args) => jest.requireActual('dayjs')(args.filter(arg => arg).length > 0 ? args : '2019-12-18T16:30:00')) -) +// Had to remove this mock because dayjs.extend throws an error as not being mocked - see this PR: https://github.com/reapit/elements/pull/82 +// jest.mock('dayjs', () => +// jest.fn((...args) => jest.requireActual('dayjs')(args.filter(arg => arg).length > 0 ? args : '2019-12-18T16:30:00')) +// ) +// Replaced with this for now: +MockDate.set(1570747191389) diff --git a/src/utils/__tests__/get-next-appointments.ts b/src/utils/__tests__/get-next-appointments.ts index 3ed560bc04..82ce519374 100644 --- a/src/utils/__tests__/get-next-appointments.ts +++ b/src/utils/__tests__/get-next-appointments.ts @@ -4,11 +4,11 @@ import { AppointmentModel } from '@/types/appointments' describe('getTodayNextAppointment', () => { test('Should return the next appointment in today', () => { const appointments: AppointmentModel[] = [ - { start: '2019-12-18T16:30:00' }, - { start: '2019-14-18T16:30:00' }, - { start: '2019-12-18T17:10:00' } + { start: '2019-10-10T22:00:00' }, + { start: '2019-10-10T22:45:00' }, + { start: '2019-10-10T23:00:00' } ] - expect(getTodayNextAppointment(appointments)).toBe(appointments[2]) + expect(getTodayNextAppointment(appointments)).toBe(appointments[1]) }) test('Should return undefined if appointments are from another day(s)', () => { diff --git a/yarn.lock b/yarn.lock index f486fe5280..5920c5b7ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -325,10 +325,10 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@reapit/elements@^0.4.15": - version "0.4.15" - resolved "https://registry.yarnpkg.com/@reapit/elements/-/elements-0.4.15.tgz#1529fa7c9cc88f2649148b085e19e6ab133c71aa" - integrity sha512-wltKu6nJXmhHe4d6kwiVtVJylOlAdkg4SfuDKwaJ1gStRPOvBdvB2GXio0Hu2yQ0iadFa45oiD2L51ikCWOD8g== +"@reapit/elements@^0.4.21": + version "0.4.21" + resolved "https://registry.yarnpkg.com/@reapit/elements/-/elements-0.4.21.tgz#5373a5aa9bdfa583390415b5538d6ba6886abda5" + integrity sha512-PCaqMJ1it7RUpD63cEmluLVvQpJVjXMA2RUr7n2TsGR64zi/AIxeDXiT7qZR7JOOCE3TePwsDiGTiidSYUKhYw== dependencies: bulma "^0.7.5" dayjs "^1.8.16" @@ -6350,6 +6350,11 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@ dependencies: minimist "0.0.8" +mockdate@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/mockdate/-/mockdate-2.0.5.tgz#70c6abf9ed4b2dae65c81dfc170dd1a5cec53620" + integrity sha512-ST0PnThzWKcgSLyc+ugLVql45PvESt3Ul/wrdV/OPc/6Pr8dbLAIJsN1cIp41FLzbN+srVTNIRn+5Cju0nyV6A== + moo@^0.4.3: version "0.4.3" resolved "https://registry.yarnpkg.com/moo/-/moo-0.4.3.tgz#3f847a26f31cf625a956a87f2b10fbc013bfd10e"