Skip to content

Commit

Permalink
Correct tests for polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiancook committed Sep 12, 2023
1 parent dea3e9d commit 8b4ead2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Native JavaScript [navigation](https://github.com/WICG/navigation-api) implement

### Test Coverage

![Web Platform Tests 129/237](https://img.shields.io/badge/Web%20Platform%20Tests-129%2F237-brightgreen) ![92.71%25 lines covered](https://img.shields.io/badge/lines-92.71%25-brightgreen) ![92.71%25 statements covered](https://img.shields.io/badge/statements-92.71%25-brightgreen) ![83.11%25 functions covered](https://img.shields.io/badge/functions-83.11%25-brightgreen) ![82.85%25 branches covered](https://img.shields.io/badge/branches-82.85%25-brightgreen)
![Web Platform Tests 129/237](https://img.shields.io/badge/Web%20Platform%20Tests-129%2F237-brightgreen) ![92.48%25 lines covered](https://img.shields.io/badge/lines-92.48%25-brightgreen) ![92.48%25 statements covered](https://img.shields.io/badge/statements-92.48%25-brightgreen) ![82.03%25 functions covered](https://img.shields.io/badge/functions-82.03%25-brightgreen) ![80.84%25 branches covered](https://img.shields.io/badge/branches-80.84%25-brightgreen)

[//]: # (badges)

Expand Down
8 changes: 1 addition & 7 deletions example/polyfill-rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2072,12 +2072,6 @@ const globalWindow = typeof window === "undefined" ? undefined : window;

const globalSelf = typeof self === "undefined" ? undefined : self;

function isLike(value, ...and) {
if (!and.length)
return !!value;
return !!value && and.every((value) => !!value);
}

const NavigationKey = "__@virtualstate/navigation/key";
const NavigationMeta = "__@virtualstate/navigation/meta";
function getWindowHistory(givenWindow = globalWindow) {
Expand Down Expand Up @@ -2575,7 +2569,7 @@ function getCompletePolyfill(options = DEFAULT_POLYFILL_OPTIONS) {
}
});
function submit() {
if (isLike(event.originalEvent)) {
if (like(event.originalEvent)) {
const anchor = getAnchorFromEvent(event.originalEvent);
if (anchor) {
return submitAnchor(anchor);
Expand Down
8 changes: 1 addition & 7 deletions example/rollup.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/get-polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {
import {globalSelf} from "./global-self";
import {v4} from "./util/uuid-or-random";
import {NavigationHistoryEntrySerialized} from "./navigation-entry";
import {isEvent} from "./event-target";
import {isLike} from "@virtualstate/focus";

export interface NavigationPolyfillOptions {
/**
Expand Down Expand Up @@ -698,7 +696,7 @@ export function getCompletePolyfill(options: NavigationPolyfillOptions = DEFAULT
});

function submit() {
if (isLike<EventPrototype>(event.originalEvent)) {
if (like<EventPrototype>(event.originalEvent)) {
const anchor = getAnchorFromEvent(event.originalEvent);
if (anchor) {
return submitAnchor(anchor);
Expand Down
5 changes: 2 additions & 3 deletions src/tests/navigation.scope.faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ function createElement(type: string) {
});
}
target.matches = (query: string) => {
if (query === type) return true;
if (query === "a[href]") {
if (query.startsWith("a[href]")) {
return type === "a" && !!target.href
}
return false;
return query.startsWith(type);
}
target.appendChild = (child: { parentElement: unknown }) => {
children.add(child)
Expand Down

0 comments on commit 8b4ead2

Please sign in to comment.