forked from openlp/openlp
Fix all the tests
This commit is contained in:
parent
83cd5c1a88
commit
3b87327682
@ -205,16 +205,6 @@ function _createStyle(selector, rules) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _quote(text) {
|
|
||||||
return '"' + text + '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
function _increaseSize(size) {
|
|
||||||
var number = size.match(/[\d]+/g);
|
|
||||||
var newNumber = parseInt(number) + 2;
|
|
||||||
return size.replace(number, newNumber.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An audio player with a play list
|
* An audio player with a play list
|
||||||
*/
|
*/
|
||||||
@ -486,7 +476,7 @@ var Display = {
|
|||||||
// create styles for the alerts from the settings
|
// create styles for the alerts from the settings
|
||||||
_createStyle("#alert-background.settings", {
|
_createStyle("#alert-background.settings", {
|
||||||
backgroundColor: settings["backgroundColor"],
|
backgroundColor: settings["backgroundColor"],
|
||||||
fontFamily: _quote(settings["fontFace"]),
|
fontFamily: "'" + settings["fontFace"] + "'",
|
||||||
fontSize: settings["fontSize"].toString() + "pt",
|
fontSize: settings["fontSize"].toString() + "pt",
|
||||||
color: settings["fontColor"]
|
color: settings["fontColor"]
|
||||||
});
|
});
|
||||||
@ -534,7 +524,6 @@ var Display = {
|
|||||||
*/
|
*/
|
||||||
addAlertToQueue: function (text, settings) {
|
addAlertToQueue: function (text, settings) {
|
||||||
Display._alerts.push({text: text, settings: settings});
|
Display._alerts.push({text: text, settings: settings});
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* The alertTransitionEndEvent called after a transition has ended
|
* The alertTransitionEndEvent called after a transition has ended
|
||||||
@ -591,6 +580,10 @@ var Display = {
|
|||||||
Display._alertState = AlertState.DisplayingFromQueue;
|
Display._alertState = AlertState.DisplayingFromQueue;
|
||||||
Display.showAlert(alertObject.text, alertObject.settings);
|
Display.showAlert(alertObject.text, alertObject.settings);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// For the tests
|
||||||
|
return null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Add a slide. If the slide exists but the HTML is different, update the slide.
|
* Add a slide. If the slide exists but the HTML is different, update the slide.
|
||||||
|
@ -157,24 +157,24 @@ describe("The Display object", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.alert", function () {
|
describe("Display.alert", function () {
|
||||||
var alertBackground, alertText, settings;
|
var alertContainer, alertBackground, alertText, settings, text;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
alertContainer = document.createElement("div");
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
alertContainer.setAttribute("class", "alert-container");
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
document.body.appendChild(alertContainer);
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
alertBackground = document.createElement("div");
|
|
||||||
alertBackground.setAttribute("id", "alert-background");
|
|
||||||
alertContainer.appendChild(alertBackground);
|
|
||||||
alertText = document.createElement("span");
|
|
||||||
alertText.setAttribute("id","alert-text");
|
|
||||||
alertBackground.appendChild(alertText);
|
|
||||||
settings = {
|
settings = {
|
||||||
"location": 1, "fontFace": "Segoe UI, Tahoma, Geneva, Verdana, sans-serif",
|
"location": 1,
|
||||||
"fontSize": 40, "fontColor": "#ffffff", "backgroundColor": "#660000",
|
"fontFace": "sans-serif",
|
||||||
"timeout": 5, "repeat": 1, "scroll": true
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
};
|
};
|
||||||
|
text = "Display.alert";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return null if called without any text", function () {
|
it("should return null if called without any text", function () {
|
||||||
@ -184,13 +184,12 @@ describe("Display.alert", function () {
|
|||||||
it("should set the correct alert text", function () {
|
it("should set the correct alert text", function () {
|
||||||
spyOn(Display, "showAlert");
|
spyOn(Display, "showAlert");
|
||||||
|
|
||||||
Display.alert("OPEN-LP-3.0 Alert Test", settings);
|
Display.alert(text, settings);
|
||||||
|
|
||||||
expect(Display.showAlert).toHaveBeenCalled();
|
expect(Display.showAlert).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call the addAlertToQueue method if an alert is displaying", function () {
|
it("should call the addAlertToQueue method if an alert is displaying", function () {
|
||||||
var text = "Testing alert queue";
|
|
||||||
spyOn(Display, "addAlertToQueue");
|
spyOn(Display, "addAlertToQueue");
|
||||||
Display._alerts = [];
|
Display._alerts = [];
|
||||||
Display._alertState = AlertState.Displaying;
|
Display._alertState = AlertState.Displaying;
|
||||||
@ -198,78 +197,117 @@ describe("Display.alert", function () {
|
|||||||
Display.alert(text, settings);
|
Display.alert(text, settings);
|
||||||
|
|
||||||
expect(Display.addAlertToQueue).toHaveBeenCalledWith(text, settings);
|
expect(Display.addAlertToQueue).toHaveBeenCalledWith(text, settings);
|
||||||
expect(Display._alerts[0]).toBe({"alert": text, "settings": settings});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.showAlertBackground", function () {
|
describe("Display.showAlert", function () {
|
||||||
|
var alertContainer, alertBackground, alertText, settings;
|
||||||
|
|
||||||
var alertBackground, bg_color;
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
bg_color = "rgb(102, 0, 0)";
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
alertBackground = document.createElement("div");
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
alertBackground.setAttribute("id", "alert-background");
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
document.body.appendChild(alertBackground);
|
settings = {
|
||||||
|
"location": 1,
|
||||||
|
"fontFace": "sans-serif",
|
||||||
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the correct transition state", function () {
|
it("should create a stylesheet for the settings", function () {
|
||||||
Display.showAlertBackground(bg_color);
|
spyOn(window, "_createStyle");
|
||||||
expect(Display._transitionState).toEqual(TransitionState.EntranceTransition);
|
Display.showAlert("Test Display.showAlert - stylesheet", settings);
|
||||||
|
|
||||||
|
expect(_createStyle).toHaveBeenCalledWith("#alert-background.settings", {
|
||||||
|
backgroundColor: settings["backgroundColor"],
|
||||||
|
fontFamily: "'" + settings["fontFace"] + "'",
|
||||||
|
fontSize: settings["fontSize"] + 'pt',
|
||||||
|
color: settings["fontColor"]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should apply the styles correctly when showAlertBackground is called", function () {
|
it("should set the alert state to AlertState.Displaying", function () {
|
||||||
Display.showAlertBackground(bg_color);
|
Display.showAlert("Test Display.showAlert - state", settings);
|
||||||
|
|
||||||
expect(alertBackground.style.backgroundColor).toEqual(bg_color);
|
expect(Display._alertState).toEqual(AlertState.Displaying);
|
||||||
expect(alertBackground.className).toEqual("bg-default show-bg");
|
});
|
||||||
|
|
||||||
|
it("should remove the 'hide' classes and add the 'show' classes", function () {
|
||||||
|
Display.showAlert("Test Display.showAlert - classes", settings);
|
||||||
|
|
||||||
|
expect($("#alert-background")[0].classList.contains("hide")).toEqual(false);
|
||||||
|
expect($("#alert-background")[0].classList.contains("show")).toEqual(true);
|
||||||
|
//expect($("#alert-text")[0].classList.contains("hide")).toEqual(false);
|
||||||
|
//expect($("#alert-text")[0].classList.contains("show")).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.hideAlertBackground", function () {
|
describe("Display.hideAlert", function () {
|
||||||
var alertBackground;
|
var alertContainer, alertBackground, alertText, settings;
|
||||||
beforeEach( function() {
|
|
||||||
|
beforeEach(function () {
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
alertBackground = document.createElement("div");
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
alertBackground.setAttribute("id", "alert-background");
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
alertBackground.setAttribute("class", "bg-default show-bg");
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
document.body.appendChild(alertBackground);
|
settings = {
|
||||||
|
"location": 1,
|
||||||
|
"fontFace": "sans-serif",
|
||||||
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reset the background to default once an alert has been displayed", function() {
|
it("should set the alert state to AlertState.NotDisplaying", function () {
|
||||||
Display.hideAlertBackground();
|
Display.showAlert("test", settings);
|
||||||
|
|
||||||
|
Display.hideAlert();
|
||||||
|
|
||||||
expect(Display._transitionState).toEqual(TransitionState.ExitTransition);
|
|
||||||
expect(Display._alertState).toEqual(AlertState.NotDisplaying);
|
expect(Display._alertState).toEqual(AlertState.NotDisplaying);
|
||||||
expect(alertBackground.className).toEqual("bg-default");
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Display.setAlertText", function() {
|
it("should hide the alert divs when called", function() {
|
||||||
var alertText;
|
Display.showAlert("test", settings);
|
||||||
beforeEach( function() {
|
|
||||||
document.body.innerHTML = "";
|
|
||||||
alertText = document.createElement("span");
|
|
||||||
alertText.setAttribute("id", "alert");
|
|
||||||
document.body.appendChild(alertText);
|
|
||||||
});
|
|
||||||
it("should set the alert text correctly", function () {
|
|
||||||
Display.setAlertText("OpenLP Alert Text", "#ffffff", "Tahoma", 40);
|
|
||||||
|
|
||||||
expect(alertText.textContent).toEqual("OpenLP Alert Text");
|
Display.hideAlert();
|
||||||
expect(alertText.style.color).toEqual("rgb(255, 255, 255)");
|
|
||||||
expect(alertText.style.fontFamily).toEqual("Tahoma");
|
expect(alertBackground.classList.contains("hide")).toEqual(true);
|
||||||
expect(alertText.style.fontSize).toEqual("40pt");
|
expect(alertBackground.classList.contains("show")).toEqual(false);
|
||||||
|
expect(alertText.classList.contains("hide")).toEqual(true);
|
||||||
|
expect(alertText.classList.contains("show")).toEqual(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.setAlertLocation", function() {
|
describe("Display.setAlertLocation", function() {
|
||||||
beforeEach(function() {
|
var alertContainer, alertBackground, alertText, settings;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
alertContainer = document.createElement("div");
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
alertContainer.setAttribute("class", "alert-container");
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
document.body.appendChild(alertContainer);
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
|
settings = {
|
||||||
|
"location": 1,
|
||||||
|
"fontFace": "sans-serif",
|
||||||
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the correct class when location is top of the page", function () {
|
it("should set the correct class when location is top of the page", function () {
|
||||||
Display.setAlertLocation(0);
|
Display.setAlertLocation(0);
|
||||||
|
|
||||||
@ -289,99 +327,57 @@ describe("Display.setAlertLocation", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.showAlertText", function () {
|
|
||||||
var alertText, settings;
|
|
||||||
beforeEach(function () {
|
|
||||||
document.body.innerHTML = "";
|
|
||||||
alertText = document.createElement("span");
|
|
||||||
alertText.setAttribute("id", "alert");
|
|
||||||
document.body.appendChild(alertText);
|
|
||||||
settings = {
|
|
||||||
"location": 2, "fontFace": "Tahoma", "fontSize": 40,
|
|
||||||
"fontColor": "rgb(255, 255, 255)", "backgroundColor": "rgb(102, 0, 0)",
|
|
||||||
"timeout": 0.01, "repeat": 1, "scroll": true
|
|
||||||
};
|
|
||||||
Display._transitionState = TransitionState.EntranceTransition;
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should set the correct animation when text is set to scroll)", function () {
|
|
||||||
Display.showAlertText(settings);
|
|
||||||
|
|
||||||
expect(alertText.style.animation).toEqual("alert-scrolling-text " + settings.timeout + "s linear 0.6s 1 normal");
|
|
||||||
expect(Display._animationState).toEqual(AnimationState.ScrollingText);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should set the correct styles when text is not scrolling", function (done) {
|
|
||||||
settings.scroll = false;
|
|
||||||
Display._transitionState = TransitionState.EntranceTransition;
|
|
||||||
spyOn(Display, "hideAlertText");
|
|
||||||
Display.showAlertText(settings);
|
|
||||||
|
|
||||||
// expect(alertText.style.animation).toEqual("");
|
|
||||||
expect(Display._animationState).toEqual(AnimationState.NonScrollingText);
|
|
||||||
expect(alertText.classList.contains('show-text')).toBe(true);
|
|
||||||
setTimeout (function () {
|
|
||||||
expect(Display._animationState).toEqual(AnimationState.NoAnimation);
|
|
||||||
expect(Display.hideAlertText).toHaveBeenCalled();
|
|
||||||
done();
|
|
||||||
}, settings.timeout * 1000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Display.hideAlertText", function() {
|
|
||||||
var alertBackground, alertText, keyframeStyle;
|
|
||||||
beforeEach(function () {
|
|
||||||
document.body.innerHTML = "";
|
|
||||||
alertBackground = document.createElement("div");
|
|
||||||
alertBackground.setAttribute("id", "alert-background");
|
|
||||||
alertBackground.setAttribute("class", "bg-default show-bg");
|
|
||||||
document.body.appendChild(alertBackground);
|
|
||||||
alertText = document.createElement("span");
|
|
||||||
alertText.setAttribute("id", "alert");
|
|
||||||
alertText.style.opacity = 1;
|
|
||||||
alertText.style.animation = "alert-scrolling-text 5s linear 0s 1 bg-default";
|
|
||||||
alertBackground.appendChild(alertText);
|
|
||||||
Display._animationState = AnimationState.ScrollingText;
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should reset the text styles and animation state after the text has scrolled", function() {
|
|
||||||
spyOn(Display, "hideAlertBackground");
|
|
||||||
Display.hideAlertText();
|
|
||||||
|
|
||||||
expect(alertText.style.animation).toEqual("");
|
|
||||||
expect(Display._animationState).toEqual(AnimationState.NoAnimation);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should call the hideAlertBackground method", function() {
|
|
||||||
spyOn(Display, "hideAlertBackground");
|
|
||||||
Display.hideAlertText();
|
|
||||||
|
|
||||||
|
|
||||||
expect(Display.hideAlertBackground).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Display.addAlertToQueue", function () {
|
describe("Display.addAlertToQueue", function () {
|
||||||
|
var alertContainer, alertBackground, alertText, settings;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
|
settings = {
|
||||||
|
"location": 1,
|
||||||
|
"fontFace": "sans-serif",
|
||||||
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
it("should add an alert to the queue if one is displaying already", function() {
|
it("should add an alert to the queue if one is displaying already", function() {
|
||||||
Display._alerts = [];
|
Display._alerts = [];
|
||||||
Display._alertState = AlertState.Displaying;
|
Display._alertState = AlertState.Displaying;
|
||||||
settings = '{ \
|
|
||||||
"location": 1, "fontFace": "Segoe UI, Tahoma, Geneva, Verdana, sans-serif", \
|
|
||||||
"fontSize": 40, "fontColor": "#ffffff", "backgroundColor": "#660000", \
|
|
||||||
"timeout": 5, "repeat": 1, "scrolling_text": true \
|
|
||||||
}';
|
|
||||||
var alertObject = {text: "Testing alert queue", settings: settings};
|
var alertObject = {text: "Testing alert queue", settings: settings};
|
||||||
var queuedAlert = JSON.stringify(alertObject);
|
|
||||||
|
|
||||||
Display.addAlertToQueue("Testing alert queue", settings);
|
Display.addAlertToQueue("Testing alert queue", settings);
|
||||||
|
|
||||||
expect(Display._alerts.length).toEqual(1);
|
expect(Display._alerts.length).toEqual(1);
|
||||||
expect(Display._alerts[0]).toEqual(queuedAlert);
|
expect(Display._alerts[0]).toEqual(alertObject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.showNextAlert", function () {
|
describe("Display.showNextAlert", function () {
|
||||||
Display.showNextAlert();
|
var alertContainer, alertBackground, alertText, settings;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
alertContainer = _createDiv({"class": "alert-container"});
|
||||||
|
alertBackground = _createDiv({"id": "alert-background", "class": "hide"});
|
||||||
|
alertText = _createDiv({"id": "alert-text", "class": "hide"});
|
||||||
|
settings = {
|
||||||
|
"location": 1,
|
||||||
|
"fontFace": "sans-serif",
|
||||||
|
"fontSize": 40,
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"backgroundColor": "#660000",
|
||||||
|
"timeout": 5,
|
||||||
|
"repeat": 1,
|
||||||
|
"scroll": true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
it("should return null if there are no alerts in the queue", function () {
|
it("should return null if there are no alerts in the queue", function () {
|
||||||
Display._alerts = [];
|
Display._alerts = [];
|
||||||
@ -391,64 +387,56 @@ describe("Display.showNextAlert", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should call the alert function correctly if there is an alert in the queue", function () {
|
it("should call the alert function correctly if there is an alert in the queue", function () {
|
||||||
var settings = {
|
Display._alerts.push({text: "Queued Alert", settings: settings});
|
||||||
"location": 2, "fontFace": "Tahoma", "fontSize": 40,
|
spyOn(Display, "showAlert");
|
||||||
"fontColor": "rgb(255, 255, 255)", "backgroundColor": "rgb(102, 0, 0)",
|
|
||||||
"timeout": 5, "repeat": 1, "scrolling_text": true
|
|
||||||
};
|
|
||||||
var alertObject = {text: "Queued Alert", settings: settings};
|
|
||||||
Display._alerts.push(JSON.stringify(alertObject));
|
|
||||||
spyOn(Display, "alert");
|
|
||||||
Display.showNextAlert();
|
Display.showNextAlert();
|
||||||
|
|
||||||
expect(Display.alert).toHaveBeenCalled();
|
expect(Display.showAlert).toHaveBeenCalled();
|
||||||
expect(Display.alert).toHaveBeenCalledWith("Queued Alert",alertObject.settings);
|
expect(Display.showAlert).toHaveBeenCalledWith("Queued Alert", settings);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.alertTransitionEndEvent", function() {
|
describe("Display.alertTransitionEndEvent", function() {
|
||||||
beforeEach( function() {
|
var e = { stopPropagation: function () { } };
|
||||||
|
|
||||||
|
it("should call event.stopPropagation()", function () {
|
||||||
|
spyOn(e, "stopPropagation");
|
||||||
|
|
||||||
|
Display.alertTransitionEndEvent(e);
|
||||||
|
|
||||||
|
expect(e.stopPropagation).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the correct state and call showAlertText after the alert entrance transition", function() {
|
it("should set the correct state after EntranceTransition", function() {
|
||||||
var fake_settings = {test: "fake_settings"};
|
|
||||||
var e = jasmine.createSpyObj('e', ['stopPropagation']);
|
|
||||||
Display._alertSettings = fake_settings;
|
|
||||||
spyOn(Display, "showAlertText");
|
|
||||||
Display._transitionState = TransitionState.EntranceTransition;
|
Display._transitionState = TransitionState.EntranceTransition;
|
||||||
Display.alertTransitionEndEvent();
|
|
||||||
|
Display.alertTransitionEndEvent(e);
|
||||||
|
|
||||||
expect(Display._transitionState).toEqual(TransitionState.NoTransition);
|
expect(Display._transitionState).toEqual(TransitionState.NoTransition);
|
||||||
expect(Display.showAlertText).toHaveBeenCalledWith(fake_settings);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the correct state after the alert exit transition", function() {
|
it("should set the correct state after ExitTransition, call hideAlert() and showNextAlert()", function() {
|
||||||
|
spyOn(Display, "hideAlert");
|
||||||
spyOn(Display, "showNextAlert");
|
spyOn(Display, "showNextAlert");
|
||||||
Display._transitionState = TransitionState.ExitTransition;
|
Display._transitionState = TransitionState.ExitTransition;
|
||||||
Display.alertTransitionEndEvent();
|
|
||||||
|
Display.alertTransitionEndEvent(e);
|
||||||
|
|
||||||
expect(Display._transitionState).toEqual(TransitionState.NoTransition);
|
expect(Display._transitionState).toEqual(TransitionState.NoTransition);
|
||||||
|
expect(Display.hideAlert).toHaveBeenCalled();
|
||||||
|
expect(Display.showNextAlert).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.alertAnimationEndEvent", function () {
|
describe("Display.alertAnimationEndEvent", function () {
|
||||||
it("should call the hideAlertText method", function() {
|
var e = { stopPropagation: function () { } };
|
||||||
spyOn(Display, "hideAlertText");
|
|
||||||
|
|
||||||
Display.alertAnimationEndEvent();
|
it("should call the hideAlert method", function() {
|
||||||
|
spyOn(Display, "hideAlert");
|
||||||
|
|
||||||
expect(Display.hideAlertText).toHaveBeenCalled();
|
Display.alertAnimationEndEvent(e);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Display.clearAlertSettings", function () {
|
expect(Display.hideAlert).toHaveBeenCalled();
|
||||||
it("should clear the alert settings once an alert has been displayed", function () {
|
|
||||||
var fake_settings = {test: "fake_settings"};
|
|
||||||
Display._alertSettings = fake_settings;
|
|
||||||
Display.clearAlertSettings();
|
|
||||||
|
|
||||||
expect(Display._alertSettings).toEqual({});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user