Skip to content

Commit

Permalink
Merge e34ab13 into 483345e
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Nov 12, 2018
2 parents 483345e + e34ab13 commit 70c480c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
10 changes: 6 additions & 4 deletions opal/static/js/opal/filters.js
Expand Up @@ -60,8 +60,9 @@ filters.filter('fromNow', function(toMomentFilter){
};
});

filters.filter('shortDate', function(toMomentFilter){
filters.filter('shortDate', function(toMomentFilter, $log){
return function(input){
$log.warn('shortDate will be removed in Opal 0.14.0')
if(!input){
return
}
Expand All @@ -83,9 +84,10 @@ filters.filter('shortDate', function(toMomentFilter){
}
});

filters.filter('shortDateTime', function(shortDateFilter, hhmmFilter){
filters.filter('shortDateTime', function(shortDateFilter, hhmmFilter, $log){
return function(input){
var datePart = shortDateFilter(input);
$log.warn('shortDateTime will be removed in Opal 0.14.0')
var datePart = shortDateFilter(input);
var timePart = hhmmFilter(input);

if(datePart && timePart){
Expand All @@ -97,7 +99,7 @@ filters.filter('shortDateTime', function(shortDateFilter, hhmmFilter){

filters.filter('shortTime', function(shortDateFilter, hhmmFilter){
return function(input){
var toChange;
var toChange;
if(_.isDate(input)){
toChange = moment(input);
}
Expand Down
27 changes: 26 additions & 1 deletion opal/static/js/test/filters.test.js
Expand Up @@ -154,6 +154,22 @@ describe('filters', function() {
});

describe('shortDate', function() {
var log;

beforeEach(function(){
inject(function($injector){
log = $injector.get('$log');
});

spyOn(log, 'warn');
});

it('should log a warning message', function() {
inject(function(shortDateFilter) {
shortDateFilter();
expect(log.warn).toHaveBeenCalledWith('shortDate will be removed in Opal 0.14.0');
});
});

it('should return undefined for no input',
inject(function(shortDateFilter) {
Expand Down Expand Up @@ -183,6 +199,7 @@ describe('filters', function() {
inject(function($injector){
shortTime = $injector.get('shortTimeFilter');
});

});

it('should display the time as hh:mm from string', function(){
Expand Down Expand Up @@ -295,14 +312,22 @@ describe('filters', function() {
});

describe('shortDateTime', function(){
var shortDateTime;
var shortDateTime, log;

beforeEach(function(){
inject(function($injector){
shortDateTime = $injector.get('shortDateTimeFilter');
log = $injector.get('$log');
});
spyOn(log, 'warn');
});

it('should log a warning message', function() {
shortDateTime()
expect(log.warn).toHaveBeenCalledWith('shortDateTime will be removed in Opal 0.14.0')
});


it('should return undefined if no input', function(){
expect(shortDateTime(null)).toBe(undefined);
});
Expand Down

0 comments on commit 70c480c

Please sign in to comment.