Skip to content

Commit bf69f39

Browse files
committed
chore: migrate tests to jest
1 parent 5d719e8 commit bf69f39

File tree

9 files changed

+20
-10
lines changed

9 files changed

+20
-10
lines changed

jest.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"preset": "es-jest",
3+
"testRegex": ["/test/.*\\.test\\.js$", "/locale-tests/.*\\.test\\.js$"],
4+
"testTimeout": 20000
5+
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"typings": "dist/npm/main.d.ts",
1212
"scripts": {
1313
"build-package": "gulp build-rollup-package build-cdn",
14-
"test": "gulp test",
15-
"locale-tests": "gulp test --tests=\"locale-tests/generated-locales.js\"",
14+
"test": "jest -- test/",
15+
"locale-tests": "jest -- locale-tests/",
1616
"lint": "eslint ./src",
1717
"semantic-release": "semantic-release pre && semantic-prerelease publish && semantic-release post"
1818
},
@@ -32,9 +32,11 @@
3232
"cldr-numbers-full": "^41.0.0",
3333
"cldr-units-full": "^41.0.0",
3434
"cz-conventional-changelog": "^1.1.5",
35+
"es-jest": "^1.5.0",
3536
"eslint": "^8.16.0",
3637
"ghooks": "^1.0.3",
3738
"gulp": "^4.0.0",
39+
"jest-cli": "^26.6.3",
3840
"semantic-release": "^6.3.6",
3941
"validate-commit-msg": "^1.1.1"
4042
},
File renamed without changes.
File renamed without changes.

test/dates.js renamed to test/dates.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ describe('date parsing', () => {
440440
it("returns null if no value is passed", () => {
441441
const result = parseDate();
442442

443-
expect(result).toBeNull(null);
443+
expect(result).toBeNull();
444444
});
445445

446446
it('parses d ISO format', function () {
@@ -461,7 +461,7 @@ describe('date parsing', () => {
461461
});
462462

463463
it('short year 29 should return year 2029', function () {
464-
expect(parseDate("12/23/29", "M/d/yy").getFullYear(), 2029);
464+
expect(parseDate("12/23/29", "M/d/yy").getFullYear()).toBe(2029);
465465
});
466466

467467
it('prases formats with leading and trailing spaces', function () {
@@ -831,7 +831,7 @@ describe('date parsing', () => {
831831
const dateFormat = "MM/dd/yyyy";
832832

833833
const result = parseDate("1//2100", dateFormat);
834-
expect(result, null);
834+
expect(result).toBeNull();
835835
});
836836

837837
it('parses MMMM yyyy date format', function () {
@@ -859,7 +859,7 @@ describe('date parsing', () => {
859859
const wideNames = dateFormatNames(info, { type: "dayPeriods", nameType: "wide" });
860860
abbreviatedNames.am = wideNames.am;
861861
const result = parseDate("2016. 05. 27. 오전 11:00:00", "G", "ko");
862-
expect(isValidDateTime(result, 2016, 5, 27, 11, 0, 0, 0 ,0), result).toBe(true);
862+
expect(isValidDateTime(result, 2016, 5, 27, 11, 0, 0, 0 ,0)).toBe(true);
863863
});
864864

865865
it('should return null if only year is passed', function () {
@@ -915,7 +915,7 @@ describe('date parsing', () => {
915915

916916
it("returns null if string is not valid ISO8601", () => {
917917
const utcDate = new Date(Date.UTC(2000, 9, 10, 14, 30, 0));
918-
expect(parseDate("2000-10-1014:30Z", "yyyy-MM-ddTHH:mmX"), null);
918+
expect(parseDate("2000-10-1014:30Z", "yyyy-MM-ddTHH:mmX")).toBeNull();
919919
});
920920

921921
it("parses UTC milliseconds correctly", () => {

test/errors.js renamed to test/errors.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('Intl', () => {
1111

1212
const result = `${error.name}: ${error.message}`;
1313

14-
expect(intlError.formatMessage(), result);
14+
expect(intlError.formatMessage()).toBe(result);
1515
});
1616

1717
it('should replace single placeholder in the message', () => {
@@ -24,7 +24,7 @@ describe('Intl', () => {
2424

2525
const result = `${error.name}: Big error! p1 p2`;
2626

27-
expect(intlError.formatMessage("p1", "p2"), result);
27+
expect(intlError.formatMessage("p1", "p2")).toBe(result);
2828
});
2929

3030
it('should return instance with message', () => {

test/format.js renamed to test/format.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { toString, format } from '../src/format';
33

44
const likelySubtags = require("cldr-core/supplemental/likelySubtags.json");
55
const calendar = require("cldr-dates-full/main/bg/ca-gregorian.json");
6+
const numbers = require("cldr-numbers-full/main/bg/numbers.json");
7+
const currencies = require("cldr-numbers-full/main/bg/currencies.json");
8+
const currencyData = require("cldr-core/supplemental/currencyData.json");
69

7-
load(likelySubtags, calendar);
10+
load(likelySubtags, calendar, currencyData, numbers, currencies);
811

912
describe('toString', () => {
1013
function logCharCodes(value) {
File renamed without changes.

0 commit comments

Comments
 (0)