mirror of
https://github.com/material-components/material-web.git
synced 2026-03-09 00:09:23 +08:00
ts-ify tests
This commit is contained in:
parent
04d52303f0
commit
28e048f388
12
package-lock.json
generated
12
package-lock.json
generated
@ -2106,9 +2106,9 @@
|
||||
}
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.7.tgz",
|
||||
"integrity": "sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==",
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.0.tgz",
|
||||
"integrity": "sha512-zw8UvoBEImn392tLjxoavuonblX/4Yb9ha4KBU10FirCfwgzhKO0dvyJSF9ByxV1xK1r2AgnAi/tvQaLgxQqxA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai-as-promised": {
|
||||
@ -2438,6 +2438,12 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mocha": {
|
||||
"version": "5.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz",
|
||||
"integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mz": {
|
||||
"version": "0.0.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/mz/-/mz-0.0.29.tgz",
|
||||
|
||||
@ -29,8 +29,10 @@
|
||||
"watch:tests": "npm run build && tsc --build test/tsconfig.json -w & tsc --build test/tsconfig-node.json -w"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.0",
|
||||
"@types/command-line-args": "^5.0.0",
|
||||
"@types/command-line-usage": "^5.0.1",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@typescript-eslint/eslint-plugin": "^1.12.0",
|
||||
"@typescript-eslint/parser": "^1.12.0",
|
||||
"@webcomponents/webcomponentsjs": "^2.2.8",
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
"tsBuildInfoFile": ".tsbuildinfo",
|
||||
},
|
||||
"include": [
|
||||
"benchmark/**/*.ts"
|
||||
"benchmark/**/*.ts",
|
||||
"unit/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"benchmark/cli.ts"
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {Card} from '@material/mwc-card';
|
||||
|
||||
let element;
|
||||
|
||||
suite('mwc-card');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-card');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-button', () => {
|
||||
assert.instanceOf(element, Card);
|
||||
});
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {assert, expect} from 'chai';
|
||||
import {fake} from 'sinon';
|
||||
import {Checkbox} from '@material/mwc-checkbox';
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {Chip} from '@material/mwc-chips/mwc-chip.js';
|
||||
import {ChipSet} from '@material/mwc-chips/mwc-chip-set.js';
|
||||
|
||||
let element;
|
||||
|
||||
suite('mwc-chip');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-chip');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-chip', () => {
|
||||
assert.instanceOf(element, Chip);
|
||||
});
|
||||
|
||||
suite('mwc-chip-set');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-chip-set');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-chip-set', () => {
|
||||
assert.instanceOf(element, ChipSet);
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {Dialog} from '@material/mwc-dialog';
|
||||
|
||||
let element;
|
||||
|
||||
suite('mwc-dialog');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-dialog');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-dialog', () => {
|
||||
assert.instanceOf(element, Dialog);
|
||||
});
|
||||
@ -73,12 +73,12 @@ test('setting `icon` sets `aria-label` of the button', async () => {
|
||||
test('setting `label` sets `aria-label` of the button, overriding `icon`', async () => {
|
||||
element.icon = 'check';
|
||||
await element.updateComplete;
|
||||
button = element.shadowRoot.querySelector('button');
|
||||
let button = element.shadowRoot.querySelector('button');
|
||||
assert.equal(button.getAttribute('aria-label'), 'check');
|
||||
|
||||
element.label = 'label text';
|
||||
await element.updateComplete;
|
||||
let button = element.shadowRoot.querySelector('button');
|
||||
button = element.shadowRoot.querySelector('button');
|
||||
assert.equal(button.getAttribute('aria-label'), 'label text');
|
||||
|
||||
element.label = undefined;
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {assert, expect} from 'chai';
|
||||
import {IconButton} from '@material/mwc-icon-button';
|
||||
|
||||
const ICON_SELECTOR = '.mdc-icon-button__icon.mdc-icon-button__icon--on';
|
||||
@ -122,7 +122,14 @@ svgTemplate.innerHTML = `
|
||||
<svg slot="offIcon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0zm0 0h24v24H0V0z"/><path d="M16.59 7.58L10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg>`;
|
||||
|
||||
test('nodes with `slot=icon` will serve as the on icon', async () => {
|
||||
const icon = svgTemplate.content.querySelector('svg[slot="icon"]').cloneNode(true);
|
||||
const iconQuery = svgTemplate.content.querySelector('svg[slot="icon"]');
|
||||
expect(iconQuery).to.be.ok;
|
||||
|
||||
if (!iconQuery) {
|
||||
return;
|
||||
}
|
||||
|
||||
const icon = iconQuery.cloneNode(true);
|
||||
element.appendChild(icon);
|
||||
await element.updateComplete;
|
||||
const iconSlot = element.shadowRoot.querySelector('slot[name="icon"]');
|
||||
@ -130,7 +137,14 @@ test('nodes with `slot=icon` will serve as the on icon', async () => {
|
||||
});
|
||||
|
||||
test('nodes with `slot=offIcon` will serve as the off icon', async () => {
|
||||
const icon = svgTemplate.content.querySelector('svg[slot="offIcon"]').cloneNode(true);
|
||||
const iconQuery = svgTemplate.content.querySelector('svg[slot="offIcon"]');
|
||||
expect(iconQuery).to.be.ok;
|
||||
|
||||
if (!iconQuery) {
|
||||
return;
|
||||
}
|
||||
|
||||
const icon = iconQuery.cloneNode(true);
|
||||
element.appendChild(icon);
|
||||
await element.updateComplete;
|
||||
const iconSlot = element.shadowRoot.querySelector('slot[name="offIcon"]');
|
||||
@ -138,7 +152,14 @@ test('nodes with `slot=offIcon` will serve as the off icon', async () => {
|
||||
});
|
||||
|
||||
test('icon-button does not toggle with only slotted icon', async () => {
|
||||
const icon = svgTemplate.content.querySelector('svg[slot="icon"]').cloneNode(true);
|
||||
const iconQuery = svgTemplate.content.querySelector('svg[slot="icon"]');
|
||||
expect(iconQuery).to.be.ok;
|
||||
|
||||
if (!iconQuery) {
|
||||
return;
|
||||
}
|
||||
|
||||
const icon = iconQuery.cloneNode(true);
|
||||
element.appendChild(icon);
|
||||
await element.updateComplete;
|
||||
assert.equal(element.on, true);
|
||||
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {ListItem} from '@material/mwc-list/mwc-list-item.js';
|
||||
import {ListItemSeparator} from '@material/mwc-list/mwc-list-item-separator.js';
|
||||
|
||||
let element;
|
||||
|
||||
suite('mwc-list-item');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-list-item');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-list-item', () => {
|
||||
assert.instanceOf(element, ListItem);
|
||||
});
|
||||
|
||||
suite('mwc-list-item-separator');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-list-item-separator');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-list-item-separator', () => {
|
||||
assert.instanceOf(element, ListItemSeparator);
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {Menu} from '@material/mwc-menu';
|
||||
|
||||
let element;
|
||||
|
||||
suite('mwc-menu');
|
||||
|
||||
beforeEach(() => {
|
||||
element = document.createElement('mwc-menu');
|
||||
document.body.appendChild(element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
|
||||
test('initializes as an mwc-menu', () => {
|
||||
assert.instanceOf(element, Menu);
|
||||
});
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {assert, expect} from 'chai';
|
||||
import {fake} from 'sinon';
|
||||
import {Switch} from '@material/mwc-switch';
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {Textfield} from '@material/mwc-textfield';
|
||||
import {TextField} from '@material/mwc-textfield';
|
||||
|
||||
let element;
|
||||
|
||||
@ -31,5 +31,5 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
test('initializes as an mwc-textfield', () => {
|
||||
assert.instanceOf(element, Textfield);
|
||||
assert.instanceOf(element, TextField);
|
||||
});
|
||||
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {assert} from 'chai';
|
||||
import {style as typographyStyle} from '@material/mwc-typography';
|
||||
import {TemplateResult} from 'lit-html';
|
||||
|
||||
suite('mwc-typography');
|
||||
|
||||
test('initializes as an mwc-typography', () => {
|
||||
assert.instanceOf(typographyStyle, TemplateResult);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user