Skip to content

Commit

Permalink
await repeat tests, fix incorrect import in router, attempt longer ti…
Browse files Browse the repository at this point in the history
…meout in router tests
  • Loading branch information
chrisdholt committed Oct 11, 2023
1 parent 7f779b6 commit 39c0191
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
56 changes: 28 additions & 28 deletions packages/web-components/fast-element/src/templating/repeat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,21 @@ describe("The repeat", () => {

behavior.bind(controller);

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
createOutput(size, void 0, void 0, input => `<div>${input}</div>`)
);

data.items = [];

await Updates.next();

expect(toHTML(parent)).to.equal("");
await expect(toHTML(parent)).to.equal("");

data.items = createArray(size);

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
createOutput(size, void 0, void 0, input => `<div>${input}</div>`)
);
});
Expand All @@ -290,7 +290,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(`${createOutput(size)}newitem`);
await expect(toHTML(parent)).to.equal(`${createOutput(size)}newitem`);
});
});

Expand All @@ -313,7 +313,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size, x => x !== index)}`
);
});
Expand All @@ -337,7 +337,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(`${createOutput(size, x => x !== 0)}`);
await expect(toHTML(parent)).to.equal(`${createOutput(size, x => x !== 0)}`);
});
});

Expand All @@ -360,7 +360,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size, x => x !== index)}newitem1newitem2`
);
});
Expand All @@ -386,7 +386,7 @@ describe("The repeat", () => {
await Updates.next();

expectViewPositionToBeCorrect(behavior);
expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size, x => x !== index)}newitem1newitem2`
);
});
Expand All @@ -409,7 +409,7 @@ describe("The repeat", () => {
const mid = Math.floor(vm.items.length/2)
vm.items.splice(mid, 1, { name: "newitem1" });
await Updates.next();
expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1${createOutput(vm.items.slice(mid +1).length , void 0, void 0, void 0, mid +1 ) }`);
await expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1${createOutput(vm.items.slice(mid +1).length , void 0, void 0, void 0, mid +1 ) }`);
});

it(`updates rendered HTML when a single item is spliced from the middle of an array of size ${size} with recycle property set to false`, async () => {
Expand All @@ -433,7 +433,7 @@ describe("The repeat", () => {
await Updates.next();

expectViewPositionToBeCorrect(behavior);
expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1${createOutput(vm.items.slice(mid +1).length , void 0, void 0, void 0, mid +1 ) }`);
await expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1${createOutput(vm.items.slice(mid +1).length , void 0, void 0, void 0, mid +1 ) }`);
});
});

Expand All @@ -454,7 +454,7 @@ describe("The repeat", () => {
const mid = Math.floor(vm.items.length/2)
vm.items.splice(mid, 2, { name: "newitem1" }, { name: "newitem2" });
await Updates.next();
expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1newitem2${createOutput(vm.items.slice(mid +2).length , void 0, void 0, void 0, mid +2 ) }`);
await expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1newitem2${createOutput(vm.items.slice(mid +2).length , void 0, void 0, void 0, mid +2 ) }`);
});

it(`updates rendered HTML when 2 items are spliced from the middle of an array of size ${size} with recycle property set to false`, async () => {
Expand All @@ -475,7 +475,7 @@ describe("The repeat", () => {
const mid = Math.floor(vm.items.length/2)
vm.items.splice(mid, 2, { name: "newitem1" }, { name: "newitem2" });
await Updates.next();
expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1newitem2${createOutput(vm.items.slice(mid +2).length , void 0, void 0, void 0, mid +2 ) }`);
await expect(toHTML(parent)).to.equal(`${createOutput(mid)}newitem1newitem2${createOutput(vm.items.slice(mid +2).length , void 0, void 0, void 0, mid +2 ) }`);
});
it(`updates rendered HTML when all items are spliced to replace entire array with an array of size ${size}`, async () => {
const { parent, targets, nodeId } = createLocation();
Expand All @@ -496,12 +496,12 @@ describe("The repeat", () => {
vm.items.splice(0, vm.items.length, ...vm.items);
await Updates.next();
expectViewPositionToBeCorrect(behavior);
expect(toHTML(parent)).to.equal(createOutput(size));
await expect(toHTML(parent)).to.equal(createOutput(size));

vm.items.splice(0, vm.items.length, ...vm.items);
await Updates.next();
expectViewPositionToBeCorrect(behavior);
expect(toHTML(parent)).to.equal(createOutput(size));
await expect(toHTML(parent)).to.equal(createOutput(size));
});
});

Expand All @@ -523,7 +523,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`newitem1newitem2${createOutput(size, x => x !== 0)}`
);
});
Expand All @@ -549,7 +549,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(createOutput(size, () => true, "*"));
await expect(toHTML(parent)).to.equal(createOutput(size, () => true, "*"));
});
});

Expand Down Expand Up @@ -578,7 +578,7 @@ describe("The repeat", () => {

for (let i = 0; i < size; ++i) {
const str = `child-item${i + 1}root-root`;
expect(text.indexOf(str)).to.not.equal(-1);
await expect(text.indexOf(str)).to.not.equal(-1);
}
});
});
Expand All @@ -602,7 +602,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shift${createOutput(size, index => index !== 0)}`
);
});
Expand All @@ -627,7 +627,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shiftshift${createOutput(size, index => index !== 0)}`
);
});
Expand All @@ -653,7 +653,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shift2${createOutput(size, index => index !== 0)}`
);
});
Expand All @@ -678,7 +678,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size, index => index !== 0)}shift3`
);
});
Expand All @@ -703,7 +703,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size, index => index !== 0)}shift3`
);
});
Expand All @@ -728,7 +728,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size)}`
);
});
Expand All @@ -753,7 +753,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`${createOutput(size-1)}shift3`
);
});
Expand All @@ -779,7 +779,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shift1shift2${createOutput(size-1)}shift3`
);
});
Expand All @@ -805,7 +805,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shift1shift2${createOutput(size)}`
);
});
Expand All @@ -831,7 +831,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(
await expect(toHTML(parent)).to.equal(
`shift1shift2${createOutput(size -1, index => index !== 0, void 0, void 0, 1 ) }`
);
});
Expand Down Expand Up @@ -865,7 +865,7 @@ describe("The repeat", () => {

await Updates.next();

expect(toHTML(parent)).to.equal(`${createOutput(size)}newitem`);
await expect(toHTML(parent)).to.equal(`${createOutput(size)}newitem`);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/web-components/fast-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"devDependencies": {
"@esm-bundle/chai": "4.3.4-fix.0",
"@microsoft/api-extractor": "7.24.2",
"@web/test-runner": "0.17.0",
"@web/test-runner-playwright": "0.10.1",
"@types/mocha": "^7.0.2",
"@types/webpack-env": "^1.15.2",
"esm": "^3.2.25",
Expand All @@ -49,9 +51,7 @@
"ts-loader": "^7.0.2",
"ts-node": "^8.9.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.7.0",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2"
"typescript": "^4.7.0"
},
"dependencies": {
"@microsoft/fast-element": "^2.0.0-beta.26"
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/fast-router/src/recognizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Endpoint,
RecognizedRoute,
} from "./recognizer.js";
import { expect } from "@esm-bundle/chai";;
import { expect } from "@esm-bundle/chai";

describe(DefaultRouteRecognizer.name, function () {
interface RecognizeSpec {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { playwrightLauncher } from "@web/test-runner-playwright";

export default {
concurrency: 10,
coverage: true,
nodeResolve: true,
testsFinishTimeout: 200000,
// in a monorepo you need to set set the root dir to resolve modules
rootDir: "../../../",
playwright: true,
browsers: [
playwrightLauncher({ product: "chromium" }),
playwrightLauncher({ product: "firefox" }),
playwrightLauncher({ product: "webkit" }),
],
files: [
"dist/esm/**/*.spec.js",
Expand Down

0 comments on commit 39c0191

Please sign in to comment.