-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mazipan/revert-gtm
- Loading branch information
Showing
6 changed files
with
247 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { getCurrentLongDate, getCurrentMonthAndYear } from "../date-utils"; | ||
|
||
describe("getCurrentLongDate", () => { | ||
let dateSpy: jest.SpyInstance; | ||
|
||
beforeAll(() => { | ||
dateSpy = jest | ||
.spyOn(global.Date, "now") | ||
.mockImplementation(() => new Date("2021-06-14 00:00:00").getTime()); | ||
}); | ||
|
||
afterAll(() => { | ||
dateSpy.mockRestore(); | ||
}); | ||
|
||
// Skip dulu, local malahan failed | ||
it.skip("should return correct long date", () => { | ||
// Node.js can not return "toLocaleString" correctly using locale id | ||
// It will return using default locale en-US | ||
// TODO: change this after got a workaround to make this works | ||
// expect(getCurrentLongDate()).toBe("June 14, 2021"); | ||
|
||
// expect id locale | ||
expect(getCurrentLongDate()).toBe("14 Juni 2021"); | ||
expect(dateSpy).toBeCalledTimes(1); | ||
}); | ||
}); | ||
|
||
describe("getCurrentMonthAndYear", () => { | ||
let dateSpy: jest.SpyInstance; | ||
|
||
beforeAll(() => { | ||
dateSpy = jest | ||
.spyOn(global.Date, "now") | ||
.mockImplementation(() => Date.parse("2021-06-14")); | ||
}); | ||
|
||
afterAll(() => { | ||
dateSpy.mockRestore(); | ||
}); | ||
|
||
// Skip dulu, local malahan failed | ||
it.skip("should return correct month and year", () => { | ||
// Node.js can not return "toLocaleString" correctly using locale id | ||
// It will return using default locale en-US | ||
// TODO: change this after got a workaround to make this works | ||
// expect(getCurrentMonthAndYear()).toBe("June 2021"); | ||
|
||
// expect id locale | ||
expect(getCurrentMonthAndYear()).toBe("Juni 2021"); | ||
expect(dateSpy).toBeCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { makeBreadcrumbJsonLd } from "../jsonld-generator"; | ||
|
||
describe("jsonLdGenerator", () => { | ||
it("should return correct schema", () => { | ||
const param = [ | ||
{ | ||
name: "Province", | ||
href: "/provinces/", | ||
}, | ||
]; | ||
const result = makeBreadcrumbJsonLd(param); | ||
const expectedResult = { | ||
"@context": "https://schema.org", | ||
"@type": "BreadcrumbList", | ||
itemListElement: [ | ||
{ | ||
"@type": "ListItem", | ||
item: "https://www.wargabantuwarga.com/", | ||
name: "Home", | ||
position: 1, | ||
}, | ||
{ | ||
"@type": "ListItem", | ||
item: "https://www.wargabantuwarga.com/provinces/", | ||
name: "Province", | ||
position: 2, | ||
}, | ||
], | ||
}; | ||
|
||
expect(result).toStrictEqual(expectedResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { getContactMeta, getProvinceMeta, Meta } from "../meta"; | ||
import { Contact } from "../provinces"; | ||
|
||
describe("getProvinceMeta", () => { | ||
const fixtures = [ | ||
[ | ||
"DKI Jakarta", | ||
{ | ||
description: | ||
"Informasi seputar COVID-19 dan kontak fasilitas/alat kesehatan di Provinsi DKI Jakarta yang dikumpulkan relawan melalui pencarian di internet atau media sosial.", | ||
title: | ||
"Informasi Faskes & Alkes untuk COVID-19 di Provinsi DKI Jakarta", | ||
} as Meta, | ||
], | ||
]; | ||
|
||
it.each(fixtures)( | ||
"should return correct value when %s is provided", | ||
(input, expected) => { | ||
expect(getProvinceMeta(input as string)).toStrictEqual(expected as Meta); | ||
}, | ||
); | ||
}); | ||
|
||
describe("getContactMeta", () => { | ||
const fixtures = [ | ||
[ | ||
"All data contact are exist", | ||
"DKI Jakarta", | ||
{ | ||
id: "3rmedika-gas", | ||
slug: "3rmedika-gas", | ||
keterangan: "Isi ulang tabung oksigen", | ||
lokasi: "Jakarta Barat", | ||
penyedia: "3R Medika Gas", | ||
}, | ||
{ | ||
description: | ||
"Informasi 3R Medika Gas - Isi ulang tabung oksigen di Jakarta Barat, DKI Jakarta yang dikumpulkan relawan melalui pencarian di internet atau media sosial.", | ||
title: | ||
"3R Medika Gas - Isi ulang tabung oksigen di Jakarta Barat, DKI Jakarta", | ||
} as Meta, | ||
], | ||
[ | ||
"Penyedia data unavailable", | ||
"DKI Jakarta", | ||
{ | ||
id: "3rmedika-gas", | ||
slug: "3rmedika-gas", | ||
keterangan: "Isi ulang tabung oksigen", | ||
lokasi: "Jakarta Barat", | ||
penyedia: "", | ||
}, | ||
{ | ||
description: | ||
"Informasi Isi ulang tabung oksigen di Jakarta Barat, DKI Jakarta yang dikumpulkan relawan melalui pencarian di internet atau media sosial.", | ||
title: "Isi ulang tabung oksigen di Jakarta Barat, DKI Jakarta", | ||
} as Meta, | ||
], | ||
[ | ||
"Lokasi data unavailable", | ||
"DKI Jakarta", | ||
{ | ||
id: "3rmedika-gas", | ||
slug: "3rmedika-gas", | ||
keterangan: "Isi ulang tabung oksigen", | ||
lokasi: "", | ||
penyedia: "", | ||
}, | ||
{ | ||
description: | ||
"Informasi Isi ulang tabung oksigen di DKI Jakarta yang dikumpulkan relawan melalui pencarian di internet atau media sosial.", | ||
title: "Isi ulang tabung oksigen di DKI Jakarta", | ||
} as Meta, | ||
], | ||
]; | ||
|
||
it.each(fixtures)( | ||
"should return correct result when: %s", | ||
(_, provinceName, contact, expected) => { | ||
expect( | ||
getContactMeta(provinceName as string, contact as Contact), | ||
).toStrictEqual(expected as Meta); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters