Skip to content

Commit

Permalink
Replace AVA with Vitest (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Aug 26, 2024
1 parent 6b702d0 commit cf2c41d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
with:
node-version-file: package.json
- run: npm install
- run: npx ava
- run: npx vitest
16 changes: 8 additions & 8 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import test from 'ava';
import {test, expect, assert} from 'vitest';
import {Window} from 'happy-dom';
import shortenUrl, {applyToLink} from './index.js';

Expand All @@ -7,7 +7,7 @@ globalThis.document = new Window({url: currentLocation}).document;

function urlMatcherMacro(t, shouldMatch = []) {
for (const [originalUrl, expectedShortenedUrl] of shouldMatch) {
t.is(shortenUrl(originalUrl, currentLocation), expectedShortenedUrl);
expect(shortenUrl(originalUrl, currentLocation)).toBe(expectedShortenedUrl);
}
}

Expand Down Expand Up @@ -541,18 +541,18 @@ test('External URLs', urlMatcherMacro, new Map([
],
]));

test('applyToLink', t => {
test('applyToLink', () => {
const a = document.createElement('a');
a.href = 'https://github.com';
a.textContent = 'https://github.com';
t.true(applyToLink(a, currentLocation));
t.is(a.textContent, 'github.com');
assert(applyToLink(a, currentLocation));
assert.equal(a.textContent, 'github.com');
});

test('applyToLink with a link that generates a HTML child element', t => {
test('applyToLink with a link that generates a HTML child element', () => {
const a = document.createElement('a');
a.href = 'https://github.com/fregante/shorten-repo-url/blob/master/.gitignore';
a.textContent = 'https://github.com/fregante/shorten-repo-url/blob/master/.gitignore';
t.true(applyToLink(a, currentLocation));
t.is(a.innerHTML, '<code>master</code>/.gitignore');
assert(applyToLink(a, currentLocation));
assert.equal(a.innerHTML, '<code>master</code>/.gitignore');
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"index.d.ts"
],
"scripts": {
"test": "xo && tsd && ava"
"test": "xo && tsd && vitest run"
},
"xo": {
"parser": "@typescript-eslint/parser",
Expand All @@ -46,9 +46,9 @@
},
"devDependencies": {
"@sindresorhus/tsconfig": "^5.0.0",
"ava": "^6.1.3",
"happy-dom": "^15.0.0",
"tsd": "^0.31.1",
"vitest": "^2.0.5",
"xo": "^0.58.0"
},
"engines": {
Expand Down

0 comments on commit cf2c41d

Please sign in to comment.