From 837250344839a7df4ff6043629648ccbef8ec2b2 Mon Sep 17 00:00:00 2001 From: Patrick RoDee Date: Thu, 9 Jan 2020 17:03:38 -0800 Subject: [PATCH] WIP add tests --- packages/mdc-textfield/test/component.test.ts | 2 +- test/unit/mdc-dom/ponyfill.test.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/mdc-textfield/test/component.test.ts b/packages/mdc-textfield/test/component.test.ts index 1b4bb932efc..97ab4959362 100644 --- a/packages/mdc-textfield/test/component.test.ts +++ b/packages/mdc-textfield/test/component.test.ts @@ -284,7 +284,7 @@ describe('MDCTextField', () => { const component = new MDCTextField(root); const adapter = (component.getDefaultFoundation() as any).adapter_; expect(adapter.hasClass('foo')).toBe(false); - expect(adapter.getLabelWidth()).toEqual(0); + expect(adapter.getLabelWidth()).toBeGreaterThan(0); expect(() => adapter.floatLabel).not.toThrow(); }); diff --git a/test/unit/mdc-dom/ponyfill.test.js b/test/unit/mdc-dom/ponyfill.test.js index 69306fbd993..201ea462e7f 100644 --- a/test/unit/mdc-dom/ponyfill.test.js +++ b/test/unit/mdc-dom/ponyfill.test.js @@ -25,7 +25,7 @@ import {assert} from 'chai'; import bel from 'bel'; import td from 'testdouble'; -import {closest, matches} from '../../../packages/mdc-dom/ponyfill.ts'; +import {closest, matches, estimateScrollWidth} from '../../../packages/mdc-dom/ponyfill.ts'; suite('MDCDom - ponyfill'); @@ -86,3 +86,19 @@ test('#matches supports vendor prefixes', () => { assert.isTrue(matches({webkitMatchesSelector: () => true}, '')); assert.isTrue(matches({msMatchesSelector: () => true}, '')); }); + +test('#estimateScrollWidth returns the default width when the element is not hidden', () => { + const root = bel` + + `; + const el = root.querySelector('#i0'); + assert.strictEqual(estimateScrollWidth(el), 10); +}); + +test('#estimateScrollWidth returns the estimated width when the element is hidden', () => { + const root = bel` + + `; + const el = root.querySelector('#i0'); + assert.strictEqual(estimateScrollWidth(el), 10); +});