mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 03:47:07 +08:00
test: simplify tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sinon from "sinon";
|
||||
import timekeeper from "timekeeper";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
@@ -16,14 +17,8 @@ function createTestRenderer() {
|
||||
.withArgs(undefined, { id: assets[0].id, url: null })
|
||||
.returns(assets[0])
|
||||
),
|
||||
me: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(users[0])
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
me: sinon.stub().returns(users[0]),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
Mutation: {
|
||||
editComment: createSinonStub(
|
||||
|
||||
@@ -66,10 +66,7 @@ beforeEach(() => {
|
||||
)
|
||||
.returns(assetStub)
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -41,10 +41,7 @@ beforeEach(() => {
|
||||
.withArgs(undefined, { id: assetStub.id, url: null })
|
||||
.returns(assetStub)
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
import { createSinonStub } from "talk-framework/testHelpers";
|
||||
@@ -12,10 +13,7 @@ beforeEach(() => {
|
||||
Query: {
|
||||
comment: () => null,
|
||||
asset: () => null,
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -38,10 +38,7 @@ beforeEach(() => {
|
||||
.withArgs(undefined, { id: assetStub.id, url: null })
|
||||
.returns(assetStub)
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
import timekeeper from "timekeeper";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
@@ -11,11 +12,14 @@ let testRenderer: ReactTestRenderer;
|
||||
beforeEach(() => {
|
||||
const resolvers = {
|
||||
Query: {
|
||||
asset: createSinonStub(s => s.throws(), s => s.returns(assets[0])),
|
||||
me: createSinonStub(s => s.throws(), s => s.returns(users[0])),
|
||||
settings: createSinonStub(
|
||||
settings: sinon.stub().returns(settings),
|
||||
me: sinon.stub().returns(users[0]),
|
||||
asset: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
s =>
|
||||
s
|
||||
.withArgs(undefined, { id: assets[0].id, url: null })
|
||||
.returns(assets[0])
|
||||
),
|
||||
},
|
||||
Mutation: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
import timekeeper from "timekeeper";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
@@ -11,12 +12,15 @@ let testRenderer: ReactTestRenderer;
|
||||
beforeEach(() => {
|
||||
const resolvers = {
|
||||
Query: {
|
||||
settings: sinon.stub().returns(settings),
|
||||
me: sinon.stub().returns(users[0]),
|
||||
asset: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.returns(assetWithDeepestReplies)
|
||||
s =>
|
||||
s
|
||||
.withArgs(undefined, { id: assetWithDeepestReplies.id, url: null })
|
||||
.returns(assetWithDeepestReplies)
|
||||
),
|
||||
me: createSinonStub(s => s.throws(), s => s.returns(users[0])),
|
||||
settings: createSinonStub(s => s.returns(settings)),
|
||||
},
|
||||
Mutation: {
|
||||
createComment: createSinonStub(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
import timekeeper from "timekeeper";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
@@ -11,11 +12,14 @@ let testRenderer: ReactTestRenderer;
|
||||
beforeEach(() => {
|
||||
const resolvers = {
|
||||
Query: {
|
||||
asset: createSinonStub(s => s.throws(), s => s.returns(assets[0])),
|
||||
me: createSinonStub(s => s.throws(), s => s.returns(users[0])),
|
||||
settings: createSinonStub(
|
||||
settings: sinon.stub().returns(settings),
|
||||
me: sinon.stub().returns(users[0]),
|
||||
asset: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
s =>
|
||||
s
|
||||
.withArgs(undefined, { id: assets[0].id, url: null })
|
||||
.returns(assets[0])
|
||||
),
|
||||
},
|
||||
Mutation: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
import { createSinonStub } from "talk-framework/testHelpers";
|
||||
@@ -17,10 +18,7 @@ beforeEach(() => {
|
||||
.withArgs(undefined, { id: assetWithDeepReplies.id, url: null })
|
||||
.returns(assetWithDeepReplies)
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReactTestRenderer } from "react-test-renderer";
|
||||
import sinon from "sinon";
|
||||
|
||||
import { timeout } from "talk-common/utils";
|
||||
import { createSinonStub } from "talk-framework/testHelpers";
|
||||
@@ -17,10 +18,7 @@ beforeEach(() => {
|
||||
.withArgs(undefined, { id: assets[0].id, url: null })
|
||||
.returns(assets[0])
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
settings: sinon.stub().returns(settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ beforeEach(() => {
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
settings: sinon.stub().returns(settings),
|
||||
comment: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined, { id: commentStub.id }).returns(commentStub)
|
||||
@@ -76,10 +77,6 @@ beforeEach(() => {
|
||||
.withArgs(undefined, { id: assetStub.id, url: null })
|
||||
.returns(assetStub)
|
||||
),
|
||||
settings: createSinonStub(
|
||||
s => s.throws(),
|
||||
s => s.withArgs(undefined).returns(settings)
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user