Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit514715e

Browse files
committed
(test): add initial test harness
- add 1 simple test that just runs the persist function and ensures it doesn't persist anything if an action hasn't been used- change test script to use jest, and move prev test to test:pub - (ci): change CI to run test and test:pub- (deps): add @types/jest to devDeps - also add reference in spec so that the types are loaded properly - not sure why the reference is needed, but it would error without - and plain `import`ing jest or @types/jest would also error
1 parentefb1cf6 commit514715e

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

‎.travis.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
language:node_js
22
# default is the very old 0.10.48; match local version instead
33
node_js:'8.9'
4+
5+
script:npm test
6+
after_script:npm run test:pub

‎package-lock.json‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"scripts": {
3030
"start":"tsdx watch",
3131
"build":"tsdx build",
32-
"test":"npm run build && npm pack",
32+
"test":"tsdx test",
33+
"test:pub":"npm run build && npm pack",
3334
"pub":"npm run build && npm publish",
3435
"changelog":"changelog-maker"
3536
},
@@ -39,6 +40,7 @@
3940
"dependencies": {},
4041
"devDependencies": {
4142
"@agilgur5/changelog-maker":"^3.0.0",
43+
"@types/jest":"^24.0.23",
4244
"mobx":"^5.11.0",
4345
"mobx-state-tree":"^3.14.0",
4446
"tsdx":"^0.7.2",

‎test/fixtures.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import{types}from'mobx-state-tree'
2+
3+
exportconstUserStore=types.model('UserStore',{
4+
name:'John Doe',
5+
age:32
6+
})

‎test/index.spec.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference types="@types/jest" />
2+
3+
import{persist}from'../src/index'
4+
import{UserStore}from'./fixtures'
5+
6+
describe('initialization',()=>{
7+
beforeEach(()=>window.localStorage.clear())
8+
9+
it('should persist nothing if no actions are used',async()=>{
10+
constuser=UserStore.create()
11+
awaitpersist('user',user)
12+
13+
expect(window.localStorage.getItem('user')).toBe(null)
14+
})
15+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp