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

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
iphands committed Feb 13, 2018
1 parent 6d2236f commit 848e6ff
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
13 changes: 9 additions & 4 deletions app/js/components/rule/ruleToggle/ruleToggle.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

const componentsModule = require('../../');
const pub = {};
const priv = {
text: {
UNIGNORE_RULE: 'Unignore Rule',
IGNORE_RULE: 'Ignore Rule'
}
};

pub.ackAction = ($scope, Ack) => {
return () => {
Expand All @@ -18,11 +24,10 @@ pub.ackAction = ($scope, Ack) => {
};

pub.init = ($scope, gettextCatalog) => {
$scope.text = gettextCatalog.getString('Ignore Rule');
$scope.text = gettextCatalog.getString(priv.text.IGNORE_RULE);
if ($scope.rule && $scope.rule.ack_id) {
$scope.text = gettextCatalog.getString('Unignore Rule');
$scope.text = gettextCatalog.getString(priv.text.UNIGNORE_RULE);
}

};

/**
Expand All @@ -48,7 +53,7 @@ function ruleToggle() {
}

componentsModule.directive('ruleToggle', ruleToggle);

if (componentsModule.testMode) {
module.exports.pub = pub;
module.exports.priv = priv;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ const ruleToggle = require('./ruleToggle.directive');
const unit = require('../../../../../unit');

describe('ruleToggle', () => {
describe('init()', () => {
const gettextCatalog = {
getString: (str) => { return str; }
};

it('should Ignore Rule', () => {
const scope = {};
ruleToggle.pub.init(scope, gettextCatalog);
scope.text.should.equal(ruleToggle.priv.text.IGNORE_RULE);
});

it('should Unignore Rule', () => {
const scope = {
rule: {
ack_id: 1235
}
};

ruleToggle.pub.init(scope, gettextCatalog);
scope.text.should.equal(ruleToggle.priv.text.UNIGNORE_RULE);
});
});

describe('ackAction()', () => {
it('should delete an ack', () => {
const scope = {
Expand Down
16 changes: 11 additions & 5 deletions gulp/tasks/unit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/*global require, __dirname*/
'use strict';

var gulp = require('gulp');
var config = require('../config');
var Server = require('karma').Server;
var path = require('path');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const config = require('../config');
const Server = require('karma').Server;
const path = require('path');

gulp.task('unit', ['views'], function (done) {
gulp.task('unit', function () {
gulp.src('app/js/**/*.unit.js', { read: false })
.pipe(mocha());
});

gulp.task('unit-browser', ['views'], function (done) {
new Server({
configFile: path.normalize(path.join(__dirname, '..', '..', config.test.karma)),
singleRun: true
Expand Down
4 changes: 4 additions & 0 deletions gulp/tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ gulp.task('watch', [ 'browserSync', 'server'], function () {
});
});

gulp.task('unit:watch', [], function () {
gulp.watch('app/js/**/*js', ['unit']);
});

gulp.task('smoke:watch', [], function () {
gulp.watch(config.views.watch.concat(exclude), ['smoke:run']);
gulp.watch('./smoketest/*js', ['smoke:run']);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"gulp-jscs": "~4.1.x",
"gulp-jscs-stylish": "~1.4.x",
"gulp-jshint": "^2.0.4",
"gulp-mocha": "^5.0.0",
"gulp-notify": "~3.2.x",
"gulp-plumber": "~1.2.x",
"gulp-protractor": "~4.1.x",
Expand Down

0 comments on commit 848e6ff

Please sign in to comment.