Skip to content

Commit

Permalink
add tests for min-height and max-height
Browse files Browse the repository at this point in the history
  • Loading branch information
outsideris committed Jan 15, 2016
1 parent 655a26f commit bf5e011
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/angular-summernote.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ angular.module('summernote', [])
var currentElement,
summernoteConfig = $scope.summernoteConfig || {};

if (angular.isDefined($attrs.height)) { summernoteConfig.height = $attrs.height; }
if (angular.isDefined($attrs.minHeight)) { summernoteConfig.minHeight = $attrs.minHeight; }
if (angular.isDefined($attrs.maxHeight)) { summernoteConfig.maxHeight = $attrs.maxHeight; }
if (angular.isDefined($attrs.height)) { summernoteConfig.height = +$attrs.height; }
if (angular.isDefined($attrs.minHeight)) { summernoteConfig.minHeight = +$attrs.minHeight; }
if (angular.isDefined($attrs.maxHeight)) { summernoteConfig.maxHeight = +$attrs.maxHeight; }
if (angular.isDefined($attrs.placeholder)) { summernoteConfig.placeholder = $attrs.placeholder; }
if (angular.isDefined($attrs.focus)) { summernoteConfig.focus = true; }
if (angular.isDefined($attrs.airmode)) { summernoteConfig.airMode = true; }
Expand Down
34 changes: 34 additions & 0 deletions test/angular-summernote.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ describe('Summernote directive', function() {
});
});

describe('"min-height" option', function() {
it('should be 300 if it specified', function () {
var element = $compile('<summernote min-height="300"></summernote>')($rootScope);
$rootScope.$digest();

expect(element.next().find('.note-editable').css('min-height')).to.be.equal('300px');
});
});

describe('"max-height" option', function() {
it('should be 500 if it specified', function () {
var element = $compile('<summernote max-height="500"></summernote>')($rootScope);
$rootScope.$digest();

expect(element.next().find('.note-editable').css('max-height')).to.be.equal('500px');
});
});

describe('"placeholder" option', function() {
it('should placeholder', function () {
var element = $compile('<summernote placeholder="This is a placeholder"></summernote>')($rootScope);
Expand Down Expand Up @@ -125,6 +143,8 @@ describe('Summernote directive', function() {
scope = $rootScope.$new();
scope.summernoteConfig = {
height: 300,
minHeight: 200,
maxHeight: 500,
focus: true,
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
Expand All @@ -143,6 +163,20 @@ describe('Summernote directive', function() {
expect(element.next().find('.note-editable').outerHeight()).to.be.equal(300);
});

it('"minHeight" should be 300', function() {
var element = $compile('<summernote config="summernoteConfig"></summernote>')(scope);
$rootScope.$digest();

expect(element.next().find('.note-editable').css('min-height')).to.be.equal('200px');
});

it('"maxHeight" should be 300', function() {
var element = $compile('<summernote config="summernoteConfig"></summernote>')(scope);
$rootScope.$digest();

expect(element.next().find('.note-editable').css('max-height')).to.be.equal('500px');
});

it('toolbar should be customized', function() {
var element = $compile('<summernote config="summernoteConfig"></summernote>')(scope);
$rootScope.$digest();
Expand Down

0 comments on commit bf5e011

Please sign in to comment.