Skip to content

Commit

Permalink
Kick off v0.4 work
Browse files Browse the repository at this point in the history
- Remove old deprecated methods + `thallium/migrate` stuff
- Remove old deprecated modules
- Remove legacy prototypal test inheritance
- Remove `reflect.ownTimeout` and `reflect.ownSlow`
- Add `thallium/migrate/support`
- Update docs on new migrate workflow
  • Loading branch information
dead-claudia committed May 21, 2017
1 parent b6d42b0 commit db3cf15
Show file tree
Hide file tree
Showing 25 changed files with 7,655 additions and 10,651 deletions.
879 changes: 0 additions & 879 deletions assertions.js

This file was deleted.

14 changes: 0 additions & 14 deletions core.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/bundle.md
Expand Up @@ -81,4 +81,4 @@ t.use(function (t) {

You can also find the definitions for this module in `thallium.d.ts` next to the bundle, in case you're using TypeScript with this.

You can also use `thallium-migrate.js` in the root, which has most of the old API monkey-patched back in with deprecation warnings, to ease test migration. It also re-adds the old `assertions` and `create` functions to the exports.
You can also use `thallium-migrate.js` in the root, which has most of the old API monkey-patched back in with deprecation warnings, to ease test migration. It also exports `thallium/migrate/support` via `tl.support`.
17 changes: 3 additions & 14 deletions docs/api/reflect.md
Expand Up @@ -14,12 +14,10 @@ Also note that `reflect` instances are persistent and tied to the backing test i
- [`reflect.root`](#root)
- [`reflect.isRoot`](#isroot)
- [`reflect.isLocked`](#islocked)
- [`reflect.ownTimeout`](#owntimeout)
- [`reflect.timeout`](#timeout)
- [`reflect.ownSlow`](#ownslow)
- [`reflect.slow`](#slow)
- [`reflect.attempts`](#attempts)
- [`reflect.isfailable`](#isfailable)
- [`reflect.isFailable`](#isfailable)
- [`reflect` test hooks](#test-hooks)
- [Tests with `reflect.test("name", callback)` and `reflect.testSkip("name", callback)`](#tests)
- [Reporter management with `reflect.reporter(reporter, arg)`, `reflect.hasReporter(reporter)`, and `reflect.removeReporter(reporter)`](#reporters)
Expand Down Expand Up @@ -97,16 +95,7 @@ Get the own timeout, `0` if it's inherited, or `Infinity` if it was disabled.
reflect.timeout // getter
```

Get the currently active timeout, or the framework default of 2000 ms.

<a id="ownslow"></a>
## reflect.ownSlow

```js
reflect.ownSlow // getter
```

Get the own slow threshold, `0` if it's inherited, or `Infinity` if it was disabled.
Get the current test timeout, `Infinity` if it was disabled, or the framework default of 2000 ms.

<a id="slow"></a>
## reflect.slow
Expand All @@ -115,7 +104,7 @@ Get the own slow threshold, `0` if it's inherited, or `Infinity` if it was disab
reflect.slow // getter
```

Get the currently active slow threshold, or the framework default of 2000 ms.
Get the current slow threshold, `Infinity` if it was disabled, or the framework default of 2000 ms.

<a id="attempts"></a>
## reflect.attempts
Expand Down
7 changes: 0 additions & 7 deletions fixtures/mid-coffee/spec/basic.coffee
Expand Up @@ -106,13 +106,6 @@ t.test 'core (basic)', ->
tt.test 'test', ->
assert.match slice, []

t.test 'test()', ->
t.test 'returns a prototypal clone inside', ->
tt = create()
inner = undefined
tt.test 'test', -> inner = this
tt.run().then -> assert.equal Object.getPrototypeOf(inner), tt

t.test 'run()', ->
t.test 'runs child tests', ->
tt = create()
Expand Down
12 changes: 3 additions & 9 deletions fixtures/mid-coffee/spec/timeouts.coffee
Expand Up @@ -108,39 +108,33 @@ t.test 'core (timeouts) (FLAKE)', ->

t.test 'gets own timeout', ->
tt = create()
active = raw = undefined
active = undefined

tt.test 'test', ->
tt.timeout = 50
active = tt.call -> @timeout
raw = tt.call -> @ownTimeout

tt.run().then ->
assert.equal active, 50
assert.equal raw, 50

t.test 'gets inherited timeout', ->
tt = create()
active = raw = undefined
active = undefined

tt.test 'test', ->
tt.timeout = 50
tt.test 'inner', ->
active = tt.call -> @timeout
raw = tt.call -> @ownTimeout

tt.run().then ->
assert.equal active, 50
assert.equal raw, 0

t.test 'gets default timeout', ->
tt = create()
active = raw = undefined
active = undefined

tt.test 'test', ->
active = tt.call -> @timeout
raw = tt.call -> @ownTimeout

tt.run().then ->
assert.equal active, 2000
assert.equal raw, 0
29 changes: 16 additions & 13 deletions index.d.ts
Expand Up @@ -270,24 +270,12 @@ interface ReflectCommon {
*/
isLocked: boolean;

/**
* Get the own, not necessarily active, timeout. 0 means inherit the
* parent's, and `Infinity` means it's disabled.
*/
ownTimeout: number;

/**
* Get the active timeout in milliseconds, not necessarily own, or the
* framework default of 2000, if none was set.
*/
timeout: number;

/**
* Get the own, not necessarily active, slow threshold. 0 means inherit the
* parent's, and `Infinity` means it's disabled.
*/
ownSlow: number;

/**
* Get the active slow threshold in milliseconds, not necessarily own, or
* the framework default of 75, if none was set.
Expand Down Expand Up @@ -376,7 +364,7 @@ export interface ReflectRoot extends ReflectCommon {
isRoot: true;

/**
* Whether a particulare reporter was registered
* Whether a particular reporter was registered
*/
hasReporter(reporter: Reporter<any>): boolean;

Expand All @@ -394,6 +382,21 @@ export interface ReflectRoot extends ReflectCommon {
* Remove a reporter.
*/
removeReporter(reporter: Reporter<any>): void;

/**
* Get the test name.
*/
name: void;

/**
* Get the test index.
*/
index: void;

/**
* Get the parent test as a Reflect.
*/
parent: void;
}

export interface ReflectChild extends ReflectCommon {
Expand Down
10 changes: 5 additions & 5 deletions internal.js
Expand Up @@ -2,7 +2,7 @@

var Thallium = require("./lib/api/thallium")
var Reports = require("./lib/core/reports")
var Types = Reports.Types
var HookStage = Reports.HookStage

exports.root = function () {
return new Thallium()
Expand Down Expand Up @@ -78,19 +78,19 @@ exports.reports = {
*/
exports.hookErrors = {
beforeAll: function (func, value) {
return new Reports.HookError(Types.BeforeAll, func, value)
return new Reports.HookError(HookStage.BeforeAll, func, value)
},

beforeEach: function (func, value) {
return new Reports.HookError(Types.BeforeEach, func, value)
return new Reports.HookError(HookStage.BeforeEach, func, value)
},

afterEach: function (func, value) {
return new Reports.HookError(Types.AfterEach, func, value)
return new Reports.HookError(HookStage.AfterEach, func, value)
},

afterAll: function (func, value) {
return new Reports.HookError(Types.AfterAll, func, value)
return new Reports.HookError(HookStage.AfterAll, func, value)
},
}

Expand Down
19 changes: 0 additions & 19 deletions lib/api/common.js
Expand Up @@ -26,22 +26,3 @@ exports.hasHook = function (list, callback) {
if (list.length > 1) return list.indexOf(callback) >= 0
return list[0] === callback
}

// TODO: cache and remove these traversals for 0.4.
// Note that a timeout of 0 means to inherit the parent.
exports.getTimeout = function (test) {
while (!test.timeout && test.parent != null) {
test = test.parent
}

return test.timeout || 2000 // ms - default timeout
}

// Note that a slowness threshold of 0 means to inherit the parent.
exports.getSlow = function (test) {
while (!test.slow && test.parent != null) {
test = test.parent
}

return test.slow || 75 // ms - default slow threshold
}

0 comments on commit db3cf15

Please sign in to comment.