-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[_refactored] Scheduler tests to follow Starmap organization
Summary: We'd like the unit tests to follow the organization of the [Starmap](https://material-motion.gitbooks.io/material-motion-starmap/content/specifications/runtime/scheduler.html), to make it easy to cross-link between them. To that end, I've refactored these tests by: - Renaming `Scheduler.test` to `Scheduler-addPlan.test` - Collapsing all tests to top level `describe` call, combining `beforeEach` calls as needed Reviewers: featherless, O2 Material Motion Reviewed By: featherless, O2 Material Motion Subscribers: featherless Tags: #material_motion Differential Revision: http://codereview.cc/D1715
- Loading branch information
1 parent
857e05b
commit 311644a
Showing
2 changed files
with
124 additions
and
139 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
packages/runtime/src/__tests__/Scheduler-addPlan.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/** @license | ||
* Copyright 2016 The Material Motion Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { expect } from 'chai'; | ||
|
||
import { | ||
beforeEach, | ||
describe, | ||
it, | ||
} from 'mocha-sugar-free'; | ||
|
||
import { | ||
stub, | ||
} from 'sinon'; | ||
|
||
import Scheduler from '../Scheduler'; | ||
|
||
// chai really doesn't like being imported as an ES2015 module; will be fixed in v4 | ||
require('chai').use( | ||
require('sinon-chai') | ||
); | ||
|
||
describe('Scheduler.addPlan', | ||
() => { | ||
let scheduler; | ||
let addPlanSpy; | ||
let PerformerSpy; | ||
let planWithSpies; | ||
let target = {}; | ||
|
||
beforeEach( | ||
() => { | ||
scheduler = new Scheduler(); | ||
|
||
addPlanSpy = stub(); | ||
|
||
PerformerSpy = stub().returns( | ||
{ | ||
addPlan: addPlanSpy, | ||
} | ||
); | ||
|
||
planWithSpies = { | ||
_performerType: PerformerSpy, | ||
} | ||
} | ||
); | ||
|
||
it(`should require arguments`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan(); | ||
} | ||
).to.throw(`Scheduler.addPlan requires`); | ||
} | ||
); | ||
|
||
it(`should require a target`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan({ plan: planWithSpies }); | ||
} | ||
).to.throw(`requires a target`); | ||
} | ||
); | ||
|
||
it(`should require a plan`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan({ target }); | ||
} | ||
).to.throw(`requires a plan`); | ||
} | ||
); | ||
|
||
it(`should create a performer from plan._performerType`, | ||
() => { | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
|
||
expect(planWithSpies._performerType).to.be.calledWithNew; | ||
} | ||
); | ||
|
||
it(`should recycle performers for the same plan and target`, | ||
() => { | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
expect(PerformerSpy).to.have.been.calledOnce; | ||
} | ||
); | ||
|
||
it(`should create new performers for each target`, | ||
() => { | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
scheduler.addPlan({ plan: planWithSpies, target: {} }); | ||
expect(PerformerSpy).to.have.been.calledTwice; | ||
} | ||
); | ||
|
||
it(`should call performer.addPlan for each plan`, | ||
() => { | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
scheduler.addPlan({ plan: planWithSpies, target }); | ||
expect(addPlanSpy).to.have.been.calledTwice; | ||
} | ||
); | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.