Skip to content

Commit 5079ed0

Browse files
authored
Merge pull request #9 from WordPress/add/setup-jest
Test: Setup unit testing using Jest
2 parents 739883b + 05af700 commit 5079ed0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ node_modules/
33
/packages/*/build/
44
/packages/*/build-module/
55
/packages/*/build-browser/
6+
7+
coverage/

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"babel-preset-env": "^1.5.2",
77
"chalk": "^1.1.3",
88
"glob": "^7.1.2",
9+
"jest": "^20.0.4",
910
"lerna": "^2.0.0-rc.5",
1011
"mkdirp": "^0.5.1",
1112
"rimraf": "^2.6.1"
1213
},
1314
"scripts": {
1415
"build-clean": "rimraf ./packages/*/build ./packages/*/build-browser ./packages/*/build-module",
15-
"build": "node ./scripts/build.js"
16+
"build": "node ./scripts/build.js",
17+
"test": "jest",
18+
"watch": "jest --watch"
1619
}
1720
}

packages/url/src/test/index.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Internal Dependencies
3+
*/
4+
import { addQueryArgs } from '../';
5+
6+
describe( 'addQueryArgs', () => {
7+
test( 'should append args to an URL without query string', () => {
8+
const url = 'https://andalouses.com/beach';
9+
const args = { sun: 'true', sand: 'false' };
10+
11+
expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.com/beach?sun=true&sand=false' );
12+
} );
13+
14+
test( 'should append args to an URL with query string', () => {
15+
const url = 'https://andalouses.com/beach?night=false';
16+
const args = { sun: 'true', sand: 'false' };
17+
18+
expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.com/beach?night=false&sun=true&sand=false' );
19+
} );
20+
} );

0 commit comments

Comments
 (0)