Skip to content
This repository was archived by the owner on Aug 10, 2025. It is now read-only.

Commit 697cd72

Browse files
authored
Merge pull request #3 from dmackca/feature/jest
add basic unit tests
2 parents 384fbd1 + 267e37f commit 697cd72

File tree

4 files changed

+2651
-41
lines changed

4 files changed

+2651
-41
lines changed

.github/workflows/node-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Node.js yarn CI
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [10.x, 12.x]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: Borales/actions-yarn@v2.1.0
21+
with:
22+
cmd: install # will run `yarn install` command
23+
- uses: Borales/actions-yarn@v2.1.0
24+
with:
25+
cmd: lint # will run `yarn build` command
26+
- uses: Borales/actions-yarn@v2.1.0
27+
with:
28+
cmd: build # will run `yarn build` command
29+
- uses: Borales/actions-yarn@v2.1.0
30+
with:
31+
cmd: test # will run `yarn test` command

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
},
1717
"scripts": {
1818
"build": "bili --input src/vue-filter-number-format.js --format esm-min --format cjs-min",
19-
"lint": "eslint ./src"
19+
"lint": "eslint ./src",
20+
"test": "jest"
2021
},
2122
"dependencies": {},
2223
"browserslist": [
@@ -29,7 +30,9 @@
2930
"eslint": "^6.2.1",
3031
"eslint-config-airbnb-base": "^14.0.0",
3132
"eslint-config-foundryspatial": "2.1.2",
32-
"eslint-plugin-import": "^2.18.2"
33+
"eslint-plugin-import": "^2.18.2",
34+
"jest": "^25.3.0",
35+
"numeral": "^2.0.6"
3336
},
3437
"peerDependencies": {
3538
"numeral": "^2.0.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const numeral = require('numeral');
2+
const numFormat = require('../../dist/vue-filter-number-format.min.js')(numeral);
3+
4+
test('Adds commas to big numbers', () => {
5+
expect(numFormat(69696969)).toBe('69,696,969');
6+
});
7+
8+
test('Returns a string, even if no commas added', () => {
9+
expect(numFormat(123)).toBe('123');
10+
expect(numFormat('456')).toBe('456');
11+
});
12+
13+
test('Accepts custom formats', () => {
14+
expect(numFormat(420, '0.000')).toBe('420.000');
15+
expect(numFormat(666, '0,0o')).toBe('666th');
16+
});

0 commit comments

Comments
 (0)