Testing data from a UI-Router state
describe("named views", function () {
var state;
beforeEach(function () {
// Create our pseudo state
state = {
data: {
pageTitle: "Merchants"
},
views: {
"": {
data: {
pageTitle: "Harry Biscuit - {{ titleVar() }}"
}
},
"locations": {
}
}
};
// Stub how UI-Router would define the named views
$state.$current.views = {
"@": {
data: {
pageTitle: "Harry Biscuit - {{ titleVar() }}"
}
},
"locations@merchants": {
}
};
// Stub in the state name
$state.$current.self = {
name: "merchants"
};
$state.$current.locals["@merchants"] = {
titleVar: function () {
return "HARRUMBLE!"
}
};
});
it("should interpolate a named view title", function () {
compileTitle("<title state-title></title>", state);
expect(element.text()).to.be.equal("Harry Biscuit - HARRUMBLE!");
});
});