Skip to content

Commit

Permalink
feat: prettier --write packages/quark/src/**/*.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
xsf0105 committed Nov 8, 2022
1 parent 7eaad5e commit 6c22936
Show file tree
Hide file tree
Showing 44 changed files with 1,188 additions and 1,156 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"init": "yarn && yarn run link && cd example && yarn",
"dev": "cd example && yarn run dev",
"link": "node ./scripts/link",
"codeformat": "prettier --write packages/quark-reactify/src/**/*.ts",
"codeformat": "prettier --write packages/quark/src/**/*.test.js",
"clean": "lerna clean -y",
"prepare": "husky install",
"copydocs": "node ./scripts/copydocs",
Expand Down
41 changes: 21 additions & 20 deletions packages/quark/src/cell/index.test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
import { expect, fixture } from '@open-wc/testing';
import '../../../lib/cell';
import { expect, fixture } from "@open-wc/testing";
import "../../../lib/cell";

const data = {
title: '标题',
desc : '描述',
to : '#/button'
}
title: "标题",
desc: "描述",
to: "#/button",
};
let el;

describe('<quark-cell>', async () => {
it('to attribute', async () => {
describe("<quark-cell>", async () => {
it("to attribute", async () => {
el = await fixture(
`<quark-cell
`<quark-cell
to=${data.to}
>
</quark-cell>`);
</quark-cell>`
);
expect(el.to).to.be.equal(data.to);
});


it('title attribute', async () => {
it("title attribute", async () => {
el = await fixture(
`<quark-cell title=${data.title}>
</quark-cell>`);
const titleE = el.shadowRoot.querySelector('.title');
`<quark-cell title=${data.title}>
</quark-cell>`
);
const titleE = el.shadowRoot.querySelector(".title");
expect(titleE.innerHTML).to.equal(data.title);
expect(el.title).to.equal(data.title);
});

it('desc attribute', async () => {
it("desc attribute", async () => {
el = await fixture(
`<quark-cell desc=${data.desc}>
</quark-cell>`);
const descE = el.shadowRoot.querySelector('.desc');
`<quark-cell desc=${data.desc}>
</quark-cell>`
);
const descE = el.shadowRoot.querySelector(".desc");
expect(descE.innerHTML).to.equal(data.desc);
expect(el.desc).to.equal(data.desc);
});

});
43 changes: 22 additions & 21 deletions packages/quark/src/checkbox/index.test.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
import { expect, fixture, html } from '@open-wc/testing';
import sinon from 'sinon';
import '../../../lib/checkbox';
import { expect, fixture, html } from "@open-wc/testing";
import sinon from "sinon";
import "../../../lib/checkbox";
const data = {
disabled: 'true',
shape: 'square',
size : 'big',
disabled: "true",
shape: "square",
size: "big",
checked: true,
}
};
let el;
describe('quark-checkbox', async () => {
describe("quark-checkbox", async () => {
before(async () => {
el = await fixture(
`<quark-checkbox
`<quark-checkbox
disabled=${data.disabled}
shape=${data.shape}
size=${data.size}
checked=${data.checked}
>
</quark-checkbox>`);
</quark-checkbox>`
);
});

it('checkbox exist', async () => {
const badge = el.shadowRoot.querySelector('.quark-checkbox-wrapper');
it("checkbox exist", async () => {
const badge = el.shadowRoot.querySelector(".quark-checkbox-wrapper");
expect(badge).to.exist;
});

it('disabled attribute', () => {
it("disabled attribute", () => {
expect(el.type).to.equal(data.type);
});

it('shape attribute', () => {
it("shape attribute", () => {
expect(el.content).to.equal(data.content);
});

it('size attribute', () => {
it("size attribute", () => {
expect(el.size).to.equal(data.size);
});

it('checked attribute', () => {
it("checked attribute", () => {
expect(el.checked).to.equal(data.checked);
});

it('click Event', async() => {
it("click Event", async () => {
const node = await fixture(
`<quark-checkbox :checked="false">方形</quark-checkbox>`
);
const eventspy = sinon.spy();
node.addEventListener('change', eventspy);
const checkbox = node.shadowRoot.querySelector('.quark-checkbox-wrapper');
checkbox.dispatchEvent(new Event('click'));
expect(eventspy.called).to.equal(true);
node.addEventListener("change", eventspy);
const checkbox = node.shadowRoot.querySelector(".quark-checkbox-wrapper");
checkbox.dispatchEvent(new Event("click"));
expect(eventspy.called).to.equal(true);
});
});
63 changes: 33 additions & 30 deletions packages/quark/src/countdown/index.test.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@

import { expect, fixture } from '@open-wc/testing';
import '../../../lib/button';
import { expect, fixture } from "@open-wc/testing";
import "../../../lib/button";

const data = {
slotText: '主要按钮',
disabled : false,
type : 'primary',
icon : 'user',
slotText: "主要按钮",
disabled: false,
type: "primary",
icon: "user",
loading: true,
shape: 'round',
}
shape: "round",
};
let el;

describe('<quark-button>', async () => {

it('icon exist', async () => {
describe("<quark-button>", async () => {
it("icon exist", async () => {
el = await fixture(
`<quark-button
`<quark-button
icon=${data.user}
>
${data.slotText}
</quark-button>`);
const icon = el.shadowRoot.querySelector('.icon');
</quark-button>`
);
const icon = el.shadowRoot.querySelector(".icon");
expect(icon).to.exist;
});


it('disabled attribute', async () => {
it("disabled attribute", async () => {
el = await fixture(
`<quark-button disabled=${data.disabled}>
`<quark-button disabled=${data.disabled}>
${data.slotText}
</quark-button>`);
</quark-button>`
);
expect(el.disabled).to.equal(data.disabled);
});

it('type attribute', async () => {
it("type attribute", async () => {
el = await fixture(
`<quark-button type=${data.type}>
`<quark-button type=${data.type}>
${data.slotText}
</quark-button>`);
</quark-button>`
);
expect(el.type).to.equal(data.type);
});

it('loading attribute', async () => {
it("loading attribute", async () => {
el = await fixture(
`<quark-button loading=${data.loading}>
`<quark-button loading=${data.loading}>
${data.slotText}
</quark-button>`);
</quark-button>`
);
expect(el.loading).to.equal(data.loading);
});

it('shape attribute', async () => {
it("shape attribute", async () => {
el = await fixture(
`<quark-button shape=${data.shape}>
`<quark-button shape=${data.shape}>
${data.slotText}
</quark-button>`);
</quark-button>`
);
expect(el.shape).to.equal(data.shape);
});

it('slot attribute', async () => {
it("slot attribute", async () => {
el = await fixture(
`<quark-button shape=${data.shape}>${data.slotText}</quark-button>`);
`<quark-button shape=${data.shape}>${data.slotText}</quark-button>`
);
const slot = el.textContent;
expect(data.slotText).to.equal(slot);
});
Expand Down
42 changes: 21 additions & 21 deletions packages/quark/src/datetimepicker/index.test.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { expect, fixture } from '@open-wc/testing';
import '../../../lib/datetime-picker';
import { expect, fixture } from "@open-wc/testing";
import "../../../lib/datetime-picker";

const data = {
title: '请选择时间',
title: "请选择时间",
open: true,
bottomhidden : true,
}
bottomhidden: true,
};
let el;

describe('<quark-datetime-picker>', async () => {

it('element exist', async () => {
el = await fixture(
`<quark-datetime-picker
describe("<quark-datetime-picker>", async () => {
it("element exist", async () => {
el = await fixture(
`<quark-datetime-picker
title=${data.title}
open=${data.open}
>
</quark-datetime-picker>`);
const container = el.shadowRoot.querySelector('.picker-container');
const header = el.shadowRoot.querySelector('.picker-header');
const headerTitle = el.shadowRoot.querySelector('.header-title');
const content = el.shadowRoot.querySelector('.picker-content');
const bottom = el.shadowRoot.querySelector('.picker-bottom');
expect(container).to.exist;
expect(header).to.exist;
expect(headerTitle).to.exist;
expect(content).to.exist;
expect(bottom).to.exist;
</quark-datetime-picker>`
);
const container = el.shadowRoot.querySelector(".picker-container");
const header = el.shadowRoot.querySelector(".picker-header");
const headerTitle = el.shadowRoot.querySelector(".header-title");
const content = el.shadowRoot.querySelector(".picker-content");
const bottom = el.shadowRoot.querySelector(".picker-bottom");
expect(container).to.exist;
expect(header).to.exist;
expect(headerTitle).to.exist;
expect(content).to.exist;
expect(bottom).to.exist;
});
});
Loading

0 comments on commit 6c22936

Please sign in to comment.