Skip to content

Instantly share code, notes, and snippets.

@joeljackson
Created June 18, 2015 18:05
Show Gist options
  • Save joeljackson/64853d54be4d3342b358 to your computer and use it in GitHub Desktop.
Save joeljackson/64853d54be4d3342b358 to your computer and use it in GitHub Desktop.
describe('template_renderer.directive', () => {
let $compile,
$rootScope;
beforeEach(angular.mock.module('beauty'));
beforeEach(inject((_$compile_, _$rootScope_) => {
$compile = _$compile_;
$rootScope = _$rootScope_;
}));
describe('Compilation', () => {
let element;
let template = {};
beforeEach( () => {
let newScope = $rootScope.$new();
newScope.vm = {};
newScope.vm.template = template.result();
element = $compile(`<div data-template-renderer data-template="vm.template">`)(newScope);
newScope.$digest();
});
describe('Template with single row', () => {
setVar(template, () => {
return {
current_template: {
rows: [
{
row_type: "full_width",
locations:{
}
}
]
}
};
});
it("Should render out an appropriate number of smart rows", () => {
expect(element[0].querySelectorAll('div[data-smart-row]').length).toBe(1);
});
});
describe('Template with three rows', () => {
setVar( template, () => {
return {
current_template: {
rows: [
{
row_type: "full_width",
locations:{
}
},
{
row_type: "full_width",
locations:{
}
},
{
row_type: "full_width",
locations:{
}
}
]
}
};
});
it("Should render out an appropriate number of smart rows", () => {
expect(element[0].querySelectorAll('div[data-smart-row]').length).toBe(3);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment