,
document.getElementById('test-mount')
);
/* jshint ignore:end */
window.simulateChange('#test-mount input', 'lorem@ipsum.com');
window.simulateSubmit('#test-mount form');
});
it("from banned IP", function(done) {
$.mockjax({
url: '/test-api/request-password-reset/',
status: 403,
responseText: {
'ban': {
'expires_on': null,
'message': {
'plain': 'Your ip is banned for spamming.',
'html': 'Your ip is banned for spamming.
',
}
}
}
});
window.simulateChange('#test-mount input', 'lorem@ipsum.com');
window.simulateSubmit('#test-mount form');
window.onElement('.page-error-banned .lead', function() {
assert.equal(
$('.page .message-body .lead p').text().trim(),
"Your ip is banned for spamming.",
"displayed error banned page with ban message.");
done();
});
});
it("handles success", function(done) { // jshint ignore:line
$.mockjax({
url: '/test-api/request-password-reset/',
status: 200,
responseText: {
'username': 'Bob',
'email': 'bob@boberson.com'
}
});
/* jshint ignore:start */
let callback = function(apiResponse) {
assert.deepEqual(apiResponse, {
'username': 'Bob',
'email': 'bob@boberson.com'
}, "callback function was called on ajax success");
done();
};
ReactDOM.render(
,
document.getElementById('test-mount')
);
/* jshint ignore:end */
window.simulateChange('#test-mount input', 'lorem@ipsum.com');
window.simulateSubmit('#test-mount form');
});
});
describe("Reset Link Sent", function() {
afterEach(function() {
window.emptyTestContainers();
});
it("renders message", function(done) { // jshint ignore:line
/* jshint ignore:start */
let callback = function() {
assert.ok(true, "callback function was called on button press");
done();
};
ReactDOM.render(
,
document.getElementById('test-mount')
);
/* jshint ignore:end */
let element = $('#test-mount .well-done');
assert.ok(element.length, "component renders");
assert.equal(element.find('p').text().trim(),
"Reset password link was sent to bob@boberson.com",
"component renders valid message");
window.simulateClick('#test-mount .btn-primary');
});
});
describe("Account Inactive Page", function() {
beforeEach(function() {
misago._context = {
'REQUEST_ACTIVATION_URL': '/activate-thy-account/'
};
});
afterEach(function() {
window.emptyTestContainers();
});
it("renders page for user-activated user", function() {
/* jshint ignore:start */
ReactDOM.render(
,
document.getElementById('test-mount')
);
/* jshint ignore:end */
let element = $('#test-mount .page-forgotten-password-inactive');
assert.ok(element.length, "component renders");
assert.equal(
$('#test-mount .page .message-body p:eq(1)').text().trim(),
"Lorem ipsum dolor met.",
"displayed error inactive page with backend message.");
assert.equal($('#test-mount a').attr('href'), '/activate-thy-account/',
"activate account link is displayed on inactive error page");
});
it("renders page for admin-activated user", function() {
/* jshint ignore:start */
ReactDOM.render(
,
document.getElementById('test-mount')
);
/* jshint ignore:end */
let element = $('#test-mount .page-forgotten-password-inactive');
assert.ok(element.length, "component renders");
assert.equal(
$('#test-mount .page .message-body p:eq(1)').text().trim(),
"Lorem ipsum dolor met admin.",
"displayed error inactive page with backend message.");
assert.ok(!$('#test-mount a').length,
"activate account link is not displayed on admin-activated error page");
});
});