Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
iphands committed Feb 13, 2018
1 parent 32385f9 commit 6d2236f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
53 changes: 53 additions & 0 deletions app/js/components/rule/ruleToggle/ruleToggle.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*global describe, it, require*/
'use strict';

const should = require('should');
const sinon = require('sinon');
const ruleToggle = require('./ruleToggle.directive');
const unit = require('../../../../../unit');

describe('ruleToggle', () => {
describe('ackAction()', () => {
it('should delete an ack', () => {
const scope = {
rule: {
ack_id: 1234
}
};

const ack = {
deleteAck: sinon.spy()
};

ruleToggle.pub.ackAction(scope, ack)();

ack.deleteAck.should.be.calledOnce();
ack.deleteAck.should.be.calledWith({ id: 1234 });
should(scope.rule.ack_id).equal(null);
});

it('create an ack', function (done) {
const scope = {
rule: {
ack_id: null
}
};

const ack = {
createAck: sinon.stub()
};

ack.createAck.resolves({id: 'fdsa'});

ruleToggle.pub.ackAction(scope, ack)();

ack.createAck.should.be.calledOnce();
ack.createAck.should.be.calledWith(scope.rule);

unit.utils.asyncHack(() => {
should(scope.rule.ack_id).equal('fdsa');
done();
});
});
});
});
11 changes: 11 additions & 0 deletions unit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*global require, module, setTimeout*/

require('should-sinon');

const utils = {};

utils.asyncHack = (fn) => {
setTimeout(fn, 1);
};

module.exports.utils = utils;

0 comments on commit 6d2236f

Please sign in to comment.