-
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.
Summary: Closes #74 Reviewers: markwei, shyndman, featherless, O2 Material Motion Reviewed By: shyndman, featherless, O2 Material Motion Tags: #material_motion Differential Revision: http://codereview.cc/D1711
- Loading branch information
1 parent
3e6ec5d
commit 857e05b
Showing
4 changed files
with
146 additions
and
36 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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,139 @@ | ||
/** @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', | ||
() => { | ||
let scheduler; | ||
let plan; | ||
let target = {}; | ||
|
||
beforeEach( | ||
() => { | ||
scheduler = new Scheduler(); | ||
plan = {}; | ||
} | ||
); | ||
|
||
describe(`addPlan`, | ||
() => { | ||
it(`should require arguments`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan(); | ||
} | ||
).to.throw(`Scheduler.addPlan requires`); | ||
} | ||
); | ||
|
||
it(`should require a target`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan({ plan }); | ||
} | ||
).to.throw(`requires a target`); | ||
} | ||
); | ||
|
||
it(`should require a plan`, | ||
() => { | ||
expect( | ||
() => { | ||
scheduler.addPlan({ target }); | ||
} | ||
).to.throw(`requires a plan`); | ||
} | ||
); | ||
|
||
describe('performers', | ||
() => { | ||
let addPlanSpy; | ||
let PerformerSpy; | ||
let planWithSpies; | ||
|
||
beforeEach( | ||
() => { | ||
addPlanSpy = stub(); | ||
|
||
PerformerSpy = stub().returns( | ||
{ | ||
addPlan: addPlanSpy, | ||
} | ||
); | ||
|
||
planWithSpies = { | ||
_performerType: PerformerSpy, | ||
} | ||
} | ||
); | ||
|
||
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; | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); |