Skip to content

Commit ec8a01c

Browse files
committed
Refactoring tests
This makes tests use the tdd instead of the bdd style.
1 parent 896cc5a commit ec8a01c

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

src/component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path="../typings/react/react.d.ts"/>
2-
31
import Mixin = require("././mixin");
42
import react = require("react");
53

src/create_class.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path="../typings/react/react.d.ts"/>
21
import extractPrototype = require("./extract_prototype");
32
import Component = require("./component");
43
import react = require("react");

src/create_mixin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path="../typings/react/react.d.ts"/>
21
import extractPrototype = require("./extract_prototype");
32
import Mixin = require("./mixin");
43
import react = require("react");

src/mixin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path="../typings/react/react.d.ts"/>
21
import NotImplementedError = require("./not_implemented_error");
32
import react = require("react");
43

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ import TypedReact = require("../src/index");
44

55
var assert = chai.assert;
66

7-
describe("Component", () => {
7+
suite("Component", () => {
88
var component: TypedReact.Component<any, any>;
99

10-
beforeEach(() => {
10+
suiteSetup(() => {
1111
component = new TypedReact.Component<any, any>();
1212
});
1313

14-
it("should not have refs", () => {
14+
test("should not have refs", () => {
1515
assert.isUndefined(component.refs);
1616
});
1717

18-
it("should not have props", () => {
18+
test("should not have props", () => {
1919
assert.isUndefined(component.props);
2020
});
2121

22-
it("should not have state", () => {
22+
test("should not have state", () => {
2323
assert.isUndefined(component.state);
2424
});
2525

2626
var testNotImplemented = (methodName: string, fn: () => void): void => {
27-
it("should throw for " + methodName, () => {
27+
test("should throw for " + methodName, () => {
2828
assert.throws(fn, TypedReact.NotImplementedError, methodName + " should be implemented by React");
2929
});
3030
};
@@ -57,7 +57,7 @@ describe("Component", () => {
5757
component.replaceProps(null);
5858
});
5959

60-
it("should return null from render", () => {
60+
test("should return null from render", () => {
6161
assert.isNull(component.render());
6262
});
6363
});
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,32 @@ class MixinTest extends FactoryTest implements HelperMixin {
5252
}
5353
}
5454

55-
describe("createFactory", () => {
55+
suite("createFactory", () => {
5656
var clazz: React.ComponentClass<FactoryProps>;
5757
var factory: React.Factory<FactoryProps>;
5858
var element: React.ReactElement<FactoryProps>;
5959
var name = "test";
6060

61-
beforeEach(() => {
61+
suiteSetup(() => {
6262
clazz = TypedReact.createClass(FactoryTest);
6363
factory = React.createFactory<FactoryProps>(clazz);
6464
element = factory({
6565
name: name
6666
});
6767
});
6868

69-
it("should produce a valid element", () => {
69+
test("should produce a valid element", () => {
7070
assert.isTrue(React.isValidElement(element));
7171
assert.equal(element.props.name, name);
7272
});
7373

74-
it("should keep class properties", () => {
74+
test("should keep class properties", () => {
7575
assert.equal(React.renderToStaticMarkup(factory({
7676
name: "Asana"
7777
})), "<h1>Greetings, Asana</h1>");
7878
});
7979

80-
it("should keep componentWillMount code", () => {
80+
test("should keep componentWillMount code", () => {
8181
var willMountClazz = TypedReact.createClass(ComponentWillMountTest);
8282
var willMountFactory = React.createFactory(willMountClazz);
8383
var wasCalled = false;
@@ -90,15 +90,15 @@ describe("createFactory", () => {
9090
assert.isTrue(wasCalled);
9191
});
9292

93-
it("should keep inherited methods and props", () => {
93+
test("should keep inherited methods and props", () => {
9494
var inheritedClazz = TypedReact.createClass(InheritanceTest);
9595
var inheritedFactory = React.createFactory(inheritedClazz);
9696
assert.equal(React.renderToStaticMarkup(inheritedFactory({
9797
name: "Asana"
9898
})), "<h1>Greetings, Asana</h1>");
9999
});
100100

101-
it("should handle life cycle mixins", () => {
101+
test("should handle life cycle mixins", () => {
102102
var willMountClazz = TypedReact.createClass(ComponentWillMountTest, [
103103
TypedReact.createMixin(LifeCycleMixin)
104104
]);
@@ -113,7 +113,7 @@ describe("createFactory", () => {
113113
assert.equal(callCount, 2);
114114
});
115115

116-
it("should handle normal mixins", () => {
116+
test("should handle normal mixins", () => {
117117
var mixinClazz = TypedReact.createClass(MixinTest, [
118118
TypedReact.createMixin(HelperMixin)
119119
]);
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import TypedReact = require("../src/index");
44

55
var assert = chai.assert;
66

7-
describe("NotImplementedError", () => {
7+
suite("NotImplementedError", () => {
88
var err: TypedReact.NotImplementedError;
99
var methodName = "chai";
1010

11-
beforeEach(() => {
11+
suiteSetup(() => {
1212
err = new TypedReact.NotImplementedError(methodName);
1313
});
1414

15-
it("should have a name", () => {
15+
test("should have a name", () => {
1616
assert.equal(err.name, "NotImplementedError");
1717
});
1818

19-
it("should have a message", () => {
19+
test("should have a message", () => {
2020
assert.equal(err.message, methodName + " should be implemented by React");
2121
});
2222
});

0 commit comments

Comments
 (0)