From 30ea8cb880a68b2f2336cc341c272fd813165e30 Mon Sep 17 00:00:00 2001
From: DavidAtSafelite
Date: Mon, 24 Jul 2023 14:27:39 -0400
Subject: [PATCH] Linting changes to ux-compontents
---
jsconfig.json | 20 +++++
src/ux-components/alert/alert.spec.js | 80 +++++++----------
src/ux-components/alert/alert.vue | 61 ++++++++-----
.../button-main/button-main.spec.js | 34 +++-----
src/ux-components/button-main/button-main.vue | 19 +++--
src/ux-components/checkbox/checkbox.spec.js | 1 -
src/ux-components/checkbox/checkbox.vue | 24 ++++--
.../list-button-horizontal.spec.js | 7 +-
.../list-button-horizontal.vue | 27 +++---
.../list-button/list-button.spec.js | 13 ++-
src/ux-components/list-button/list-button.vue | 29 ++++---
src/ux-components/list-card/list-card.spec.js | 7 +-
src/ux-components/list-card/list-card.vue | 37 +++++---
src/ux-components/loader/loader.vue | 4 +-
.../modal-button-main.spec.js | 58 +++++--------
.../modal-button-main/modal-button-main.vue | 25 +++---
src/ux-components/radio/radio.spec.js | 7 +-
src/ux-components/radio/radio.vue | 85 ++++++++++---------
src/ux-components/text-link/text-link.vue | 45 ++++++----
19 files changed, 325 insertions(+), 258 deletions(-)
create mode 100644 jsconfig.json
diff --git a/jsconfig.json b/jsconfig.json
new file mode 100644
index 00000000..bc38f5ed
--- /dev/null
+++ b/jsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "target": "esnext",
+ "module": "esnext",
+ "baseUrl": "./",
+ "moduleResolution": "node",
+ "paths": {
+ "@/*": [
+ "src/*"
+ ]
+ },
+ "lib": [
+ "esnext",
+ "dom",
+ "dom.iterable",
+ "scripthost"
+ ]
+ }
+ }
+
\ No newline at end of file
diff --git a/src/ux-components/alert/alert.spec.js b/src/ux-components/alert/alert.spec.js
index d8d57fee..23d0451b 100644
--- a/src/ux-components/alert/alert.spec.js
+++ b/src/ux-components/alert/alert.spec.js
@@ -6,8 +6,7 @@ import alert from './alert';
describe('alert.vue', () => {
it("Should add class 'alert-dismissible' if isDismissible is true", async () => {
// Arrange
- const wrapper = shallowMount(
- alert,
+ const wrapper = shallowMount(alert,
setupMocks({
propsData: {
isDismissible: true,
@@ -15,8 +14,7 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
- })
- );
+ }));
const wrapperDiv = wrapper.find('div');
@@ -26,8 +24,7 @@ describe('alert.vue', () => {
it('Should add specified alert class', async () => {
// Arrange
- const wrapper = shallowMount(
- alert,
+ const wrapper = shallowMount(alert,
setupMocks({
propsData: {
alertClass: 'warning',
@@ -35,8 +32,7 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
- })
- );
+ }));
const wrapperDiv = wrapper.find('div');
@@ -54,24 +50,21 @@ describe('alert.vue', () => {
it('Should container a tag if the manualCopy contains a {routerLink: testName, testLink} placeholder', () => {
// Arrange & Act
- const wrapper = shallowMount(
- alert,
+ const wrapper = shallowMount(alert,
setupMocks({
propsData: {
manualHeadline: 'testHeader',
manualCopy: 'testCopy with a {routerLink: testName, testLink} inside of it',
cmsWidgetName: 'alert'
}
- })
- );
+ }));
// Assert
expect(wrapper.findComponent(RouterLinkStub).exists()).toBe(true);
});
it("Should contain 'n+1' tags if the body copy has 'n'
tags", () => {
// Arrange & Act
- const wrapper = shallowMount(
- alert,
+ const wrapper = shallowMount(alert,
setupMocks({
propsData: {
manualHeadline: 'testHeader',
@@ -79,22 +72,19 @@ describe('alert.vue', () => {
'
testCopy with a {routerLink: testName, testLink} inside of it
and two paragraphs
',
cmsWidgetName: 'alert'
}
- })
- );
+ }));
// Assert
expect(wrapper.findAll('p').length === 3).toBe(true);
});
it('Should call scrollIntoView() when the clientBoundingRect is not entirely in the viewport (out of view top)', () => {
// Arrange
- var viewPortHeight = 200;
+ const viewPortHeight = 200;
setUpViewPort(viewPortHeight);
- Element.prototype.getBoundingClientRect = jest.fn(() => {
- return { top: -100, bottom: 200 };
- });
+ Element.prototype.getBoundingClientRect = jest.fn(() => ({ top: -100, bottom: 200 }));
- var mockScrollIntoView = jest.fn();
+ const mockScrollIntoView = jest.fn();
Element.prototype.scrollIntoView = mockScrollIntoView;
// Act
@@ -109,14 +99,12 @@ describe('alert.vue', () => {
it('Should call scrollIntoView() when the clientBoundingRect is not entirely in the viewport (bottom is hidden behind footer)', () => {
// Arrange
- var viewPortHeight = 240;
+ const viewPortHeight = 240;
setUpViewPort(viewPortHeight);
- Element.prototype.getBoundingClientRect = jest.fn(() => {
- return { top: 100, bottom: 200 };
- });
+ Element.prototype.getBoundingClientRect = jest.fn(() => ({ top: 100, bottom: 200 }));
- var mockScrollIntoView = jest.fn();
+ const mockScrollIntoView = jest.fn();
Element.prototype.scrollIntoView = mockScrollIntoView;
// Act
@@ -131,19 +119,16 @@ describe('alert.vue', () => {
it("Should not call scrollIntoView() when the clientBoundingRect is not entirely in the viewport but 'shouldScrollToOnMount' is false", () => {
// Arrange
- var viewPortHeight = 200;
+ const viewPortHeight = 200;
setUpViewPort(viewPortHeight);
- Element.prototype.getBoundingClientRect = jest.fn(() => {
- return { top: -100, bottom: 200 };
- });
+ Element.prototype.getBoundingClientRect = jest.fn(() => ({ top: -100, bottom: 200 }));
- var mockScrollIntoView = jest.fn();
+ const mockScrollIntoView = jest.fn();
Element.prototype.scrollIntoView = mockScrollIntoView;
// Act
- const wrapper = shallowMount(
- alert,
+ const wrapper = shallowMount(alert,
setupMocks({
propsData: {
shouldScrollToOnMount: false,
@@ -151,8 +136,7 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
- })
- );
+ }));
// Assert
// This is an implementation detail - we just need to test that the final step of snapping
@@ -163,14 +147,12 @@ describe('alert.vue', () => {
it('Should not call scrollIntoView() when the clientBoundingRect is entirely in the viewport', () => {
// Arrange
- var viewPortHeight = 500;
+ const viewPortHeight = 500;
setUpViewPort(viewPortHeight);
- Element.prototype.getBoundingClientRect = jest.fn(() => {
- return { top: 100, bottom: 200 };
- });
+ Element.prototype.getBoundingClientRect = jest.fn(() => ({ top: 100, bottom: 200 }));
- var mockScrollIntoView = jest.fn();
+ const mockScrollIntoView = jest.fn();
Element.prototype.scrollIntoView = mockScrollIntoView;
// Act
@@ -187,18 +169,20 @@ describe('alert.vue', () => {
const mockMixin = {
methods: {
getCmsContent: jest.fn(),
- getFooterInfoBoxHeight: jest.fn(() => 50),
+ getFooterInfoBoxHeight: jest.fn(() => 50)
},
computed: {
- dynamicStrings: jest.fn(() => {
- return { ROUTER_LINK: 'routerLink:' };
- }),
+ dynamicStrings: jest.fn(() => ({ ROUTER_LINK: 'routerLink:' })),
cssClassNameForCmsWidget() {
return 'widget-name-';
}
}
};
+/**
+ *
+ * @param height
+ */
function setUpViewPort(height) {
Object.defineProperty(global.window, 'innerHeight', {
writable: true,
@@ -213,6 +197,10 @@ function setUpViewPort(height) {
});
}
+/**
+ *
+ * @param mountOptionsMockData
+ */
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = {
propsData: {
@@ -222,9 +210,7 @@ function setupMocks(mountOptionsMockData = {}) {
},
mixins: [mockMixin]
};
- const baseMountOptions = getMountOptions(
- Object.assign(defaultMountOptions, mountOptionsMockData)
- );
+ const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}
diff --git a/src/ux-components/alert/alert.vue b/src/ux-components/alert/alert.vue
index 5883c336..8ec4a76c 100644
--- a/src/ux-components/alert/alert.vue
+++ b/src/ux-components/alert/alert.vue
@@ -4,32 +4,47 @@
role="alert"
:class="[
isDismissible ? 'alert-dismissible' : '',
- this.alertClass,
- this.cssClassNameForCmsWidget,
+ alertClass,
+ cssClassNameForCmsWidget,
]">
- {{ alertHeadline }}
-
+
+ {{ alertHeadline }}
+
+
-
-
-
+
+
+
{{ getRouterLinkDisplayTextFromCopy(copy) }}
+ }">{{ getRouterLinkDisplayTextFromCopy(copy) }}
-