Skip to content

Commit

Permalink
fix test code, pkg upgrade and update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
blckclov3r committed Sep 15, 2024
1 parent 0095ca4 commit d2a5463
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 227 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ If you prefer not to install the package and want to include the ECMAScript modu
project, you can use the following script tag:

- CDN (
jsDelivr): [`https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.9/dist/index.mjs`](https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.9/dist/index.mjs)
jsDelivr): [`https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.10/dist/index.mjs`](https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.10/dist/index.mjs)

- NPM: [`https://unpkg.com/use-postal-ph@1.1.9/dist/index.mjs`](https://unpkg.com/use-postal-ph@1.1.9/dist/index.mjs)
- NPM: [`https://unpkg.com/use-postal-ph@1.1.10/dist/index.mjs`](https://unpkg.com/use-postal-ph@1.1.10/dist/index.mjs)

Import Statement:

```html

<script type="module">
import usePostalPH from 'https://unpkg.com/use-postal-ph@1.1.9/dist/index.mjs';
import usePostalPH from 'https://unpkg.com/use-postal-ph@1.1.10/dist/index.mjs';
const {
fetchDataLists,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-postal-ph",
"version": "1.1.9",
"version": "1.1.10",
"description": "This utility library is specifically designed for the Philippines, providing comprehensive information on postal codes,\nmunicipalities, locations, and regions. Moreover, searching within the library is case insensitive.",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
38 changes: 19 additions & 19 deletions tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import usePostalPH from './../src/index';

test.describe('index.ts', () => {
const {fetchPostCodes, fetchMunicipalities, fetchRegions, fetchLocations, fetchDataLists} = usePostalPH();
test('post-code', async () => {
const postCodes = await fetchPostCodes();
const postCodeSearch = await fetchPostCodes({search: '6045'});
const postCodeWithLimit = await fetchPostCodes({limit: 10});
test('post-code', () => {
const postCodes = fetchPostCodes();
const postCodeSearch = fetchPostCodes({search: '6045'});
const postCodeWithLimit = fetchPostCodes({limit: 10});
expect(postCodeSearch).toEqual({
"location": "Cebu",
"municipality": "Talisay",
Expand All @@ -15,7 +15,7 @@ test.describe('index.ts', () => {
});
if (postCodeWithLimit) {
if ('data' in postCodeWithLimit) {
const data: number[] = postCodeWithLimit.data;
const data = postCodeWithLimit.data;
expect(data).toHaveLength(10)
}
}
Expand All @@ -26,14 +26,14 @@ test.describe('index.ts', () => {
}
}
});
test('municipality', async () => {
const municipalities = await fetchMunicipalities();
const municipalitySearch = await fetchMunicipalities({search: 'Talisayan'});
const municipalityWithLimit = await fetchMunicipalities({limit: 10});
test('municipality', () => {
const municipalities = fetchMunicipalities();
const municipalitySearch = fetchMunicipalities({search: 'Talisayan'});
const municipalityWithLimit = fetchMunicipalities({limit: 10});
if (municipalities) {
if ('data' in municipalities) {
const data = municipalities.data;
expect(data).toHaveLength(1876)
expect(data).toHaveLength(1877);
}
}
if (municipalitySearch) {
Expand All @@ -54,9 +54,9 @@ test.describe('index.ts', () => {
}
}
});
test('region', async () => {
const regionSearch = await fetchRegions({search: 'XII'});
const regionWithLimit = await fetchMunicipalities({limit: 10});
test('region', () => {
const regionSearch = fetchRegions({search: 'XII'});
const regionWithLimit = fetchMunicipalities({limit: 10});
if (regionSearch) {
if ('data' in regionSearch) {
const data = regionSearch.data;
Expand All @@ -70,9 +70,9 @@ test.describe('index.ts', () => {
}
}
});
test('location', async () => {
const locationSearch = await fetchLocations({search: 'Cebu'});
const locationWithLimit = await fetchLocations({limit: 10});
test('location', () => {
const locationSearch = fetchLocations({search: 'Cebu'});
const locationWithLimit = fetchLocations({limit: 10});
if (locationSearch) {
if ('data' in locationSearch) {
const data = locationSearch.data;
Expand All @@ -86,9 +86,9 @@ test.describe('index.ts', () => {
}
}
});
test('dataLists', async () => {
const dataListSearch = await fetchDataLists({post_code: '6045'});
const dataListWithLimit = await fetchDataLists({limit: 10});
test('dataLists', () => {
const dataListSearch = fetchDataLists({post_code: '6045'});
const dataListWithLimit = fetchDataLists({limit: 10});
if (dataListSearch) {
if ('data' in dataListSearch) {
const data = dataListSearch.data;
Expand Down
14 changes: 10 additions & 4 deletions tests/web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ import {expect, Page, test} from '@playwright/test';
const baseUrl = 'https://use-postal-ph.vercel.app/';

async function setup(page: Page) {
await page.goto(baseUrl);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveTitle(/use-postal-ph/);
try {
await page.context().clearCookies();
// Increase timeout and wait until the network is idle
await page.goto(baseUrl, {timeout: 60000, waitUntil: 'networkidle'});
await expect(page).toHaveTitle(/use-postal-ph/ as unknown as string);
} catch (error) {
throw error;
}

const buttons = ['Main', 'Municipality', 'Region', 'Location', 'Post Code'];
for (const buttonName of buttons) {
const button = await page.getByRole('button', {name: buttonName});
Expand All @@ -19,7 +25,7 @@ async function clickButton(page: Page, buttonName: string) {

async function selectOptionAndSubmit(page: Page, comboboxName: string, optionName: string) {
const combobox = await page.getByRole('combobox', {name: comboboxName});
await combobox.type(optionName);
await combobox.fill(optionName);
await page.getByRole('option', {name: optionName, exact: true}).click();
const submitButton = page.locator('.MuiBox-root > button').first();
await submitButton.waitFor({state: 'visible'});
Expand Down
Loading

0 comments on commit d2a5463

Please sign in to comment.