Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('Prelodr jQuery', t => {
jsdom.env('', [
require.resolve('../bower_components/jquery/dist/jquery.js')
], (err, window) => {
/* istanbul ignore if */
if (err) {
return;
}
const $ = window.jQuery;
global.window = window;
global.document = window.document;
$.fn.prelodr = function (options) {
let fn;
let prelodr;
request.expect(response => {
jsdom.env(response.text, (error, window) => {
const document = window.document;
// Check page title
assert.match(document.querySelector('title').textContent, /profile/i);
// Check error message
assert.match(document.querySelector('output[name="error"]').textContent, /valid email address/i);
// Check that the form data is set
const form = document.querySelector('form[action="/profile"]');
const emailField = form.querySelector('input[name="email"]');
assert.strictEqual(emailField.getAttribute('type'), 'email');
assert.strictEqual(emailField.getAttribute('value'), testEdits.adminEmail);
const passwordField = form.querySelector('input[name="password"]');
assert.strictEqual(passwordField.getAttribute('value'), null);
});
request.expect(response => {
jsdom.env(response.text, (error, window) => {
const document = window.document;
// Check page title
assert.match(document.querySelector('title').textContent, /login/i);
// Check error message
assert.match(document.querySelector('output[name="error"]').textContent, /incorrect email or password/i);
// Check that the form data is set
const form = document.querySelector('form[action="/login"]');
const emailField = form.querySelector('input[name="email"]');
assert.strictEqual(emailField.getAttribute('value'), testLoginData.email);
const passwordField = form.querySelector('input[name="password"]');
assert.strictEqual(passwordField.getAttribute('value'), null);
});
}).end(done);
request.expect(response => {
jsdom.env(response.text, (error, window) => {
const document = window.document;
// Check page title
assert.match(document.querySelector('title').textContent, /profile/i);
// Check that the edit details form is present
const form = document.querySelector('form[action="/profile"]');
assert.strictEqual(form.getAttribute('method'), 'post');
// Check edit details fields
const emailField = form.querySelector('input[name="email"]');
assert.strictEqual(emailField.getAttribute('type'), 'email');
assert.strictEqual(emailField.getAttribute('value'), 'admin@example.com');
const passwordField = form.querySelector('input[name="password"]');
assert.strictEqual(passwordField.getAttribute('type'), 'password');
it('should contain a view_state', (done) => {
const test = (err, window) => {
const con = connect(new window.MapdCon());
const views = con.getFrontendViews();
const view = con.getFrontendView(views[0].view_name);
expect(view.view_state.length).toBeGreaterThan(0);
done();
};
jsdom.env({ html, src: scripts, done: test });
});
it('should contain a valid view_name property', (done) => {
it('should get the server status', (done) => {
const test = (err, window) => {
const con = connect(new window.MapdCon());
const serverStatus = con.getServerStatus();
expect(serverStatus).toBeAn('object');
done();
};
jsdom.env({ html, src: scripts, done: test });
});
});
it('should delete a frontend view with name "test_view"', (done) => {
const test = (err, window) => {
const mapdcon = connect(new window.MapdCon());
const callback = () => {
const filtered = mapdcon.getFrontendViews().filter((view) => {
return view.view_name === 'test_view';
});
expect(filtered).toEqual([]);
done();
};
mapdcon.deleteFrontendView('test_view', callback);
};
jsdom.env({ html, src: scripts, done: test });
});
});
it('should set/get a port', (done) => {
const test = (err, window) => {
const con = new window.MapdCon();
con.port('3333');
expect(con.port()).toEqual(['3333']);
done();
};
jsdom.env({ html, src: scripts, done: test });
});
it('should set/get a username', (done) => {
it('should create a new frontend view with name "test_view"', (done) => {
const test = (err, window) => {
const viewState = randomString(10);
const imageHash = randomString(8, 'n');
const mapdcon = connect(new window.MapdCon())
.createFrontendView('test_view', viewState, imageHash);
const view = mapdcon.getFrontendView('test_view');
expect(view.view_state).toEqual(viewState);
expect(view.image_hash).toEqual(imageHash);
done();
};
jsdom.env({ html, src: scripts, done: test });
});
});
(done) => {
jsdom.env({
html,
src: loadScripts(),
done: (err, window) => { cb(done, window); }
});
}
);