Skip to content

Commit

Permalink
将 fixture 和 mock 放置到 teambition-sdk-testutil 包内
Browse files Browse the repository at this point in the history
...简化项目结构。
  • Loading branch information
chuan6 committed Aug 23, 2017
1 parent d833be5 commit 757001a
Show file tree
Hide file tree
Showing 40 changed files with 60 additions and 97 deletions.
3 changes: 1 addition & 2 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"exclude": [
"**/teambition-sdk-mock/**",
"**/teambition-sdk-fixture/**"
"**/teambition-sdk-testutil/**"
],
"include": [
"**/src/**"
Expand Down
2 changes: 2 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies:
- ~/.cache/yarn

test:
override:
- yarn test
pre:
- greenkeeper-lockfile-update
- lerna run build_cjs
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@
"snapper-consumer": "^1.3.6",
"source-map-support": "^0.4.16",
"teambition-sdk-core": "^0.8.13",
"teambition-sdk-fixture": "^0.8.13",
"teambition-sdk-mock": "^0.8.13",
"teambition-sdk-request": "^0.8.13",
"teambition-sdk-testutil": "^0.8.13",
"tman": "^1.7.1",
"ts-node": "^3.2.0",
"tslib": "^1.7.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
"sinon": "^2.3.8",
"sinon-chai": "^2.11.0",
"snapper-consumer": "^1.3.6",
"teambition-sdk-fixture": "^0.8.13",
"teambition-sdk-mock": "^0.8.13",
"teambition-sdk-testutil": "^0.8.13",
"tman": "^1.7.1",
"ts-node": "^3.2.0",
"tslib": "^1.7.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/teambition-sdk-core/test/mock/MockFetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Backend } from 'teambition-sdk-mock'
import { Backend } from 'teambition-sdk-testutil'
import { SDKFetch } from '../index'

function throwIfSlashPath(path: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/teambition-sdk-core/test/mock/MockSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as chai from 'chai'
import * as sinon from 'sinon'
import * as sinonChai from 'sinon-chai'
import { Backend, parseObject, reParseQuery } from 'teambition-sdk-mock'
import { Backend, parseObject, reParseQuery } from 'teambition-sdk-testutil'
import { describe, it, beforeEach } from 'tman'

const expect = chai.expect
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-core/test/net/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { Database, DataStoreType } from 'reactivedb'
import { expect, use } from 'chai'
import { spy } from 'sinon'
import * as SinonChai from 'sinon-chai'
import { Backend } from 'teambition-sdk-mock'
import { Backend, EventsFixture } from 'teambition-sdk-testutil'
import '../../src/schemas'
import { schemas, CacheStrategy } from '../../src/SDK'
import { Net, SDKFetch, forEach, uuid, Http, EventSchema, } from '..'
import { ApiResult } from '../../src/Net/Net'
import { EventsFixture } from 'teambition-sdk-fixture'

const { normalEvent, projectEvents } = EventsFixture

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestEvent } from 'teambition-sdk-mock'
import { RequestEvent } from 'teambition-sdk-testutil'
import { describe, beforeEach, it } from 'tman'
import { expect } from 'chai'

Expand Down
2 changes: 1 addition & 1 deletion packages/teambition-sdk-core/test/sockets/sockets.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SocketMock } from 'teambition-sdk-mock'
import { SocketMock } from 'teambition-sdk-testutil'
import { createSdk, SDK, SDKFetch } from '../'
import { restore } from '../utils'
import * as sinon from 'sinon'
Expand Down
2 changes: 1 addition & 1 deletion packages/teambition-sdk-core/test/utils/httpErrorSpec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as chai from 'chai'
import { Subject } from 'rxjs/Subject'
import { describe, it, beforeEach, afterEach } from 'tman'
import { Backend } from 'teambition-sdk-mock'
import { Backend } from 'teambition-sdk-testutil'

import { Http, HttpErrorMessage, SDKFetch } from '../index'

Expand Down
29 changes: 0 additions & 29 deletions packages/teambition-sdk-mock/package.json

This file was deleted.

28 changes: 0 additions & 28 deletions packages/teambition-sdk-mock/tsconfig.json

This file was deleted.

3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"sinon": "^2.3.8",
"sinon-chai": "^2.11.0",
"teambition-sdk-core": "^0.8.13",
"teambition-sdk-fixture": "^0.8.13",
"teambition-sdk-mock": "^0.8.13",
"teambition-sdk-testutil": "^0.8.13",
"tman": "^1.7.1",
"ts-node": "^3.2.0",
"tslib": "^1.7.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, beforeEach, it } from 'tman'
import { expect } from 'chai'
import * as Moment from 'moment'
import { EventsFixture } from 'teambition-sdk-fixture'
import { EventsFixture } from 'teambition-sdk-testutil'
import { EventGenerator } from '../../src/event/EventGenerator'
import { Utils } from 'teambition-sdk-core'

Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as moment from 'moment'
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SDK, EventSchema } from 'teambition-sdk-core'
import { EventsFixture } from 'teambition-sdk-fixture'
import { SocketMock } from 'teambition-sdk-mock'
import { EventsFixture, SocketMock } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { mock, restore, equals, looseDeepEqual, clone } from '../utils'

Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/file.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SDK, FileSchema } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { FilesFixture, SocketMock } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { FilesFixture } from 'teambition-sdk-fixture'
import { mock, restore, looseDeepEqual } from '../utils'

describe('FileApi Spec', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/like.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import { expect } from 'chai'
import { describe, it, beforeEach, afterEach } from 'tman'
import { SDK, LikeSchema } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { LikeFixture as like, SocketMock } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { LikeFixture as like } from 'teambition-sdk-fixture'
import { mock, restore } from '../utils'

describe('LikeApi Spec: ', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/my.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { describe, it, beforeEach, afterEach } from 'tman'
import { expect } from 'chai'
import { SDK, EventSchema, TaskSchema } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { MyFixture, SocketMock } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { EventGenerator, isRecurrence } from '../../src/event'
import { MyFixture } from 'teambition-sdk-fixture'
import { mock, restore } from '../utils'

function normIfRecurrentEvent(myRecent: any[]): any[] {
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/post.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SDK, PostSchema } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { PostsFixture, SocketMock } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { PostsFixture } from 'teambition-sdk-fixture'
import { mock, restore, equals } from '../utils'
import { shuffle } from 'lodash'

Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/task.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SDK, TaskSchema } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { SocketMock, TasksFixture } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { TasksFixture } from 'teambition-sdk-fixture'
import { mock, restore, looseDeepEqual } from '../utils'

describe('TaskApi Spec', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/teambition-sdk-request/test/apis/user.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { SDK, UserMe } from 'teambition-sdk-core'
import { SocketMock } from 'teambition-sdk-mock'
import { SocketMock, UserFixture as userMe } from 'teambition-sdk-testutil'
import { createSdk } from '../index'
import { UserFixture as userMe } from 'teambition-sdk-fixture'
import { mock, restore } from '../utils'

describe('UserApi Spec', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/teambition-sdk-request/test/asyncLoadRDB.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { Subscription } from 'rxjs'
import { SocketMock } from 'teambition-sdk-mock'
import { SDK, TaskSchema, PostSchema, LikeSchema } from 'teambition-sdk-core'
import {
SocketMock,
LikeFixture as like,
MyFixture,
PostsFixture,
TasksFixture,
UserFixture as userMe,
} from 'teambition-sdk-fixture'
} from 'teambition-sdk-testutil'

import { mock, restore, equals } from './utils'
import { createSdkWithoutRDB, loadRDB, normIfRecurrentEvent, EventGenerator } from './index'
Expand Down
2 changes: 1 addition & 1 deletion packages/teambition-sdk-request/test/mock/MockFetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SDKFetch } from 'teambition-sdk-core'
import { Backend } from 'teambition-sdk-mock'
import { Backend } from 'teambition-sdk-testutil'

function throwIfSlashPath(path: string) {
if (path.charAt(0) === '/') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"name": "teambition-sdk-fixture",
"name": "teambition-sdk-testutil",
"version": "0.8.13",
"description": "Front-End SDK (Fixture) for Teambition",
"description": "Front-End SDK (TestUtil) for Teambition",
"main": "./dist/cjs/index.js",
"typings": "./dist/cjs/index.d.ts",
"scripts": {
Expand All @@ -15,12 +15,17 @@
"keywords": [
"teambition",
"sdk",
"teambition-sdk"
"teambition-sdk",
"mock",
"fixture"
],
"author": "[email protected]",
"license": "MIT",
"bugs": {
"url": "https://github.com/teambition/teambition-sdk/issues"
},
"homepage": "https://github.com/teambition/teambition-sdk#readme"
"homepage": "https://github.com/teambition/teambition-sdk#readme",
"peerDependencies": {
"core-js": "^2.4.1"
}
}
2 changes: 2 additions & 0 deletions packages/teambition-sdk-testutil/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './mock'
export * from './fixture'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist/cjs",
"sourceMap": true,
"inlineSources": true,
"target": "ES5",

"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
],

"inlineSources": true,
"inlineSourceMap": true,
"declaration": true,
"diagnostics": true,
"pretty": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,

"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",

"lib": [
"es5",
"es2015.iterable",
"es2015.collection",
"es2015.promise",
"es2015.core",
"dom"
],
"importHelpers": true,
"noEmitHelpers": true
},
"files": [
"src/index.ts"
]
}

0 comments on commit 757001a

Please sign in to comment.