Skip to content

Commit

Permalink
Merge pull request #1 from jpbackman/fix-fullscreen-navigation-tests
Browse files Browse the repository at this point in the history
Fix fullscreen navigation tests
  • Loading branch information
junaidrsd committed Feb 12, 2015
2 parents c68cea5 + 2e391e7 commit ccc3e1f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 59 deletions.
4 changes: 2 additions & 2 deletions lib/app/views/element-fullscreen.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="navigation-section">
<a ng-hide="!previousSection" ui-sref="app.fullscreen({section: previousSection })" target="_blank">
<a ng-hide="!previousSection" ui-sref="app.fullscreen({section: previousSection })">
<i class="fa fa-arrow-left"></i>
</a>
<a ng-hide="!nextSection" ui-sref="app.fullscreen({section: nextSection })" target="_blank">
<a ng-hide="!nextSection" ui-sref="app.fullscreen({section: nextSection })">
<i class="fa fa-arrow-right"></i>
</a>
</div>
Expand Down
111 changes: 54 additions & 57 deletions test/angular/functional/element-fullscreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ describe('element-fullscreen template', function() {
var scope,
template,
html,
templateText,
content,
Styleguide;

Expand Down Expand Up @@ -35,89 +34,87 @@ describe('element-fullscreen template', function() {
inject(function($compile) {
html = $compile(template)(scope);
scope.$digest();
templateText = html.prop('outerHTML');
content = angular.element(html.html()).html();
var shadowDom = angular.element(html[2]);
content = angular.element(shadowDom[0]).find('div').html();
});
}

function expectDirectiveWithoutValue(directive) {
var regex = new RegExp('\\s+' + directive + '(\\s+|\\>)[^=]', 'g');
expect(template).to.match(regex);
}
describe('component markup', function() {

it('should be wrapped in shadow-dom element', function() {
expect(templateText).to.match(/^<shadow-dom/);
expect(templateText).to.match(/<\/shadow-dom>$/);
});
it('should be wrapped in shadow-dom element', function() {
expect(template).to.match(/<shadow-dom>[\s\S]*<\/shadow-dom>/);
});

describe('should have directive', function() {
describe('should have directive', function() {

it('dynamic-compile without value', function() {
expectDirectiveWithoutValue('dynamic-compile');
});
it('dynamic-compile without value', function() {
expect(template).to.match(/<div[\s\S]+dynamic-compile\S/);
});

it('ng-bind-html', function() {
expect(template).to.match(/\s+ng-bind-html="/);
});
it('ng-bind-html', function() {
expect(template).to.match(/<div[\s\S]+ng-bind-html="/);
});

});
});

describe('directive ng-bind-html', function() {
describe('directive ng-bind-html', function() {

it('should filter scope.markup through addWrapper and unsafe', function() {
var dir = 'ng-bind-html="',
it('should filter scope.markup through addWrapper and unsafe', function() {
var dir = 'ng-bind-html="',
start = template.indexOf(dir) + dir.length,
value = template.substring(start, template.indexOf('"', start));
expect(value).to.match(/markup\s*\|\s*addWrapper\s*\|\s*unsafe\s*/);
expect(value).to.match(/markup\s*\|\s*addWrapper\s*\|\s*unsafe\s*/);
});

});

});
describe('when commonClass is not defined', function() {

describe('when commonClass is not defined', function() {
describe('template contents should be', function() {

describe('template contents should be', function() {
it('an empty string if scope.markup is not set', function() {
expect(content).to.eql('');
});

it('an empty string if scope.markup is not set', function() {
expect(content).to.eql('');
});
it('text from scope.markup', function() {
scope.markup = 'hello';
compileTemplate();
expect(content).to.eql('hello');
});

it('text from scope.markup', function() {
scope.markup = 'hello';
compileTemplate();
expect(content).to.eql('hello');
});
it('html from scope.markup', function() {
var expected = '<p>hello!</p>';
scope.markup = expected;
compileTemplate();
expect(content).to.eql(expected);
});

it('html from scope.markup', function() {
var expected = '<p>hello!</p>';
scope.markup = expected;
compileTemplate();
expect(content).to.eql(expected);
});

});

});
describe('when commonClass is defined', function() {

describe('when commonClass is defined', function() {
beforeEach(function() {
Styleguide.config = {
data: {
commonClass: 'foobar'
}
};
});

beforeEach(function() {
Styleguide.config = {
data: {
commonClass: 'foobar'
}
};
});
it('should wrap scope.markup html in <sg-common-class-wrapper> element', function() {
scope.markup = '<p>hello!</p>';
compileTemplate();
expect(content).to.contain('<p>hello!</p></sg-common-class-wrapper>');
});

it('should wrap scope.markup html in <sg-common-class-wrapper> element', function() {
scope.markup = '<p>hello!</p>';
compileTemplate();
expect(content).to.contain('<p>hello!</p></sg-common-class-wrapper>');
});
it('wrapper element should have class defined in commonClass', function() {
scope.markup = '<p>hello!</p>';
compileTemplate();
expect(content).to.contain('<sg-common-class-wrapper class="foobar"><p>hello!</p>');
});

it('wrapper element should have class defined in commonClass', function() {
scope.markup = '<p>hello!</p>';
compileTemplate();
expect(content).to.contain('<sg-common-class-wrapper class="foobar"><p>hello!</p>');
});

});
Expand Down

0 comments on commit ccc3e1f

Please sign in to comment.