Skip to content

Commit

Permalink
Merge pull request #140 from gemini-testing/refactor/tests
Browse files Browse the repository at this point in the history
test: refactoring edits
  • Loading branch information
eGavr authored Apr 25, 2017
2 parents 881b0ed + d14ed26 commit 2034fe2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
3 changes: 1 addition & 2 deletions test/lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ describe('Browser', () => {
session.url = sandbox.stub().named('url').returns(session);
session.requestHandler = {defaultOptions: {}};

session.addCommand = () => {};
sandbox.stub(session, 'addCommand').callsFake((name, command) => {
session.addCommand = sinon.stub().callsFake((name, command) => {
session[name] = command;
sandbox.spy(session, name);
});
Expand Down
19 changes: 6 additions & 13 deletions test/lib/runner/mocha-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ describe('mocha-runner', () => {
sandbox.stub(MochaAdapter.prototype, 'attachTitleValidator').returnsThis();
sandbox.stub(MochaAdapter.prototype, 'applySkip').returnsThis();
sandbox.stub(MochaAdapter.prototype, 'loadFiles').returnsThis();
sandbox.stub(MochaAdapter.prototype, 'run').returnsThis();
sandbox.stub(MochaAdapter.prototype, 'run');

sandbox.spy(RetryMochaRunner, 'create');
sandbox.stub(RetryMochaRunner.prototype, 'run');
});

Expand Down Expand Up @@ -66,6 +65,8 @@ describe('mocha-runner', () => {
});

it('should wrap each mocha instance into a retry runner', () => {
sandbox.spy(RetryMochaRunner, 'create');

const config = stubConfig();

config.forBrowser.withArgs('some-bro').returns({retry: 10});
Expand Down Expand Up @@ -128,15 +129,12 @@ describe('mocha-runner', () => {
});

it('should create all mocha instances before run any of them', () => {
MochaAdapter.create.restore();
RetryMochaRunner.prototype.run.restore();

const order = [];
sandbox.stub(MochaAdapter, 'create').callsFake(() => {
MochaAdapter.create.callsFake(() => {
order.push('create');
return mkMochaAdapterStub_();
});
sandbox.stub(RetryMochaRunner.prototype, 'run').callsFake(() => order.push('run'));
RetryMochaRunner.prototype.run.callsFake(() => order.push('run'));

return run_(['some/file', 'other/file'])
.then(() => assert.deepEqual(order, ['create', 'create', 'run', 'run']));
Expand Down Expand Up @@ -164,8 +162,7 @@ describe('mocha-runner', () => {

describe('should passthrough events from a', () => {
const testPassthroughing = (event, from) => {
RetryMochaRunner.prototype.run.restore();
sandbox.stub(RetryMochaRunner.prototype, 'run').callsFake(() => from.emit(event, 'some-data'));
RetryMochaRunner.prototype.run.callsFake(() => from.emit(event, 'some-data'));

const mochaRunner = mochaRunnerInit();
const spy = sinon.spy();
Expand Down Expand Up @@ -217,7 +214,6 @@ describe('mocha-runner', () => {
events.forEach((event) => {
it(`${event}`, () => {
const retryMochaRunner = Object.create(RetryMochaRunner.prototype);
RetryMochaRunner.create.restore();
sandbox.stub(RetryMochaRunner, 'create').returns(retryMochaRunner);

return testPassthroughing(event, retryMochaRunner);
Expand Down Expand Up @@ -264,9 +260,6 @@ describe('mocha-runner', () => {
});

it('should return suite of mocha-adapter', () => {
MochaAdapter.create.restore();
sandbox.stub(MochaAdapter, 'create');

const mochaRunner = mochaRunnerInit();
const suiteStub = sandbox.stub();
MochaAdapter.create.returns(_.extend(Object.create(MochaAdapter.prototype), {suite: suiteStub}));
Expand Down

0 comments on commit 2034fe2

Please sign in to comment.