mirror of
https://github.com/morris/vanilla-todo.git
synced 2025-09-09 05:30:42 +02:00
add basic testing, fix #8
This commit is contained in:
27
test/e2e/addItem.test.mjs
Normal file
27
test/e2e/addItem.test.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test("Add item to today's todo list (Enter)", async ({ page }) => {
|
||||
await page.goto('http://localhost:8080');
|
||||
|
||||
const input = page.locator('.-today .todo-item-input > input').filter();
|
||||
await input.focus();
|
||||
await input.type('Hello, world!');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await expect(page.locator('.-today .todo-item > .label')).toHaveText(
|
||||
'Hello, world!'
|
||||
);
|
||||
});
|
||||
|
||||
test("Add item to today's todo list (click)", async ({ page }) => {
|
||||
await page.goto('http://localhost:8080');
|
||||
|
||||
const input = page.locator('.-today .todo-item-input > input').filter();
|
||||
await input.focus();
|
||||
await input.type('Hello, world!');
|
||||
await page.locator('.-today .todo-item-input > .save').click();
|
||||
|
||||
await expect(page.locator('.-today .todo-item > .label')).toHaveText(
|
||||
'Hello, world!'
|
||||
);
|
||||
});
|
9
test/unit/util.test.mjs
Normal file
9
test/unit/util.test.mjs
Normal file
@@ -0,0 +1,9 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import util from '../../public/scripts/util.js';
|
||||
|
||||
test('formatDate', () => {
|
||||
expect(util.formatDate(new Date(0))).toEqual('January 1st 1970');
|
||||
expect(util.formatDate(new Date('2023-05-13 12:00:00'))).toEqual(
|
||||
'May 13th 2023'
|
||||
);
|
||||
});
|
Reference in New Issue
Block a user