Skip to content

Commit

Permalink
WIP add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickrodee committed Jan 10, 2020
1 parent e933b88 commit 8372503
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/mdc-textfield/test/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
18 changes: 17 additions & 1 deletion test/unit/mdc-dom/ponyfill.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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`<span>
<span id="i0" style="width:10px;"></span>
</span>`;
const el = root.querySelector('#i0');
assert.strictEqual(estimateScrollWidth(el), 10);
});

test('#estimateScrollWidth returns the estimated width when the element is hidden', () => {
const root = bel`<span style="display:none;">
<span id="i0" style="width:10px;"></span>
</span>`;
const el = root.querySelector('#i0');
assert.strictEqual(estimateScrollWidth(el), 10);
});

0 comments on commit 8372503

Please sign in to comment.