Skip to content

Commit

Permalink
fix(core): lint/logging
Browse files Browse the repository at this point in the history
- remove deprecated jasmine done use/warnings
- fix private property to state lint warning
- fix lint warn on guaranteed boolean statement

Signed-off-by: Cory Rylan <splintercode.cb@gmail.com>
  • Loading branch information
coryrylan committed Nov 23, 2021
1 parent afe24aa commit a1772a3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/index.ts
Expand Up @@ -5,7 +5,10 @@
*/

// we export any non component code such as utilities at the root '@clr/core'
export { I18nService, componentStringsDefault } from '@cds/core/internal';
export { I18nService } from '@cds/core/internal';

// we don't re-export componentStringsDefault from @cds/internal to prevent rollup complaining about a unsed import being rexported
export { componentStringsDefault } from './internal/services/i18n.service.js';

// type global attribute utilities
declare global {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/internal-components/popup/popup.element.ts
Expand Up @@ -23,6 +23,7 @@ import {
reverseAnimation,
setAttributes,
setPopupPosition,
state,
} from '@cds/core/internal';
import { html } from 'lit';
import { query } from 'lit/decorators/query.js';
Expand Down Expand Up @@ -102,7 +103,7 @@ export class CdsInternalPopup extends CdsInternalStaticOverlay implements Animat
* positioning logic may override your changes.
*/
/** @private */
@property({ type: Boolean, reflect: true })
@state({ type: Boolean, reflect: true, attribute: 'responsive' })
responsive = false;

@event()
Expand Down
18 changes: 6 additions & 12 deletions packages/core/src/internal/motion/utils.spec.ts
Expand Up @@ -109,29 +109,27 @@ describe('Animation Helpers: ', () => {
];

describe('runPropertyAnimations()', () => {
it('logs a warning if the element it is passed is not animatable', async done => {
it('logs a warning if the element it is passed is not animatable', async () => {
const testElement = await createTestElement(html`<div>ohai</div>`);
spyOn(LogService, 'warn');
expect(testElement).toBeDefined();
const didRun = await runPropertyAnimations(new Map(), (testElement as unknown) as AnimatableElement);
expect(LogService.warn).toHaveBeenCalled();
expect(didRun).toBe(false);
removeTestElement(testElement);
done();
});

it('bails if the host element does not have the property (weird edge case)', async done => {
it('bails if the host element does not have the property (weird edge case)', async () => {
const testElement = await createTestElement(html`<div>ohai</div>`);
const propMap: Map<string, any> = new Map();
propMap.set('jabberwocky', 'wat');

const didRun = await runPropertyAnimations(propMap, (testElement as unknown) as AnimatableElement);
expect(didRun).toBe(false);
removeTestElement(testElement);
done();
});

it('bails if the host element property and the new propval have not changed (another weird edge case)', async done => {
it('bails if the host element property and the new propval have not changed (another weird edge case)', async () => {
const testElement = await createTestElement(html`<test-animate-utils-element>ohai</test-animate-utils-element>`);
const component = testElement.querySelector<TestAnimateUtilsElement & AnimatableElement>(
'test-animate-utils-element'
Expand All @@ -144,10 +142,9 @@ describe('Animation Helpers: ', () => {
const didRun = await runPropertyAnimations(propMap, component);
expect(didRun).toBe(false);
removeTestElement(testElement);
done();
});

it('bails if there is no animation associated with the property value', async done => {
it('bails if there is no animation associated with the property value', async () => {
const testElement = await createTestElement(html`<div class="hayy">ohai</div>`);
const component = testElement.querySelector('.hayy');
const propMap: Map<string, any> = new Map();
Expand All @@ -156,10 +153,9 @@ describe('Animation Helpers: ', () => {
const didRun = await runPropertyAnimations(propMap, (component as unknown) as AnimatableElement);
expect(didRun).toBe(false);
removeTestElement(testElement);
done();
});

it('runs if there is an animation associated with the property value', async done => {
it('runs if there is an animation associated with the property value', async () => {
const testElement = await createTestElement(html`<test-animate-utils-element>ohai</test-animate-utils-element>`);
const component = testElement.querySelector<TestAnimateUtilsElement>('test-animate-utils-element');
ClarityMotion.add('something', [{ animation: [{ opacity: 0 }, { opacity: 1 }] }]);
Expand All @@ -170,10 +166,9 @@ describe('Animation Helpers: ', () => {
const didRun = await runPropertyAnimations(propMap, (component as unknown) as AnimatableElement);
expect(didRun).toBe(true);
removeTestElement(testElement);
done();
});

it('does NOT run if there is an animation label associated with the property value but no animation in ClarityMotion', async done => {
it('does NOT run if there is an animation label associated with the property value but no animation in ClarityMotion', async () => {
const testElement = await createTestElement(html`<test-animate-utils-element>ohai</test-animate-utils-element>`);
const component = testElement.querySelector<TestAnimateUtilsElement>('test-animate-utils-element');
component.everythingIsFine = false;
Expand All @@ -183,7 +178,6 @@ describe('Animation Helpers: ', () => {
const didRun = await runPropertyAnimations(propMap, (component as unknown) as AnimatableElement);
expect(didRun).toBe(false);
removeTestElement(testElement);
done();
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/internal/utils/focus-trap.ts
Expand Up @@ -51,7 +51,7 @@ export function refocusIfOutsideFocusTrapElement(
const focusableChildren = queryAllFocusable(focusTrapElement);
const orderedFocusableChildrenAsArray = reorderCloseButtonSlot(Array.from(focusableChildren));

if (isReboundEl !== null && orderedFocusableChildrenAsArray !== []) {
if (isReboundEl !== null) {
if (isReboundEl === 'top') {
elementToRefocus = arrayTail(orderedFocusableChildrenAsArray) as HTMLElement;
} else if (isReboundEl === 'bottom') {
Expand Down

0 comments on commit a1772a3

Please sign in to comment.