How to use the jsdom.jsdom.env function in jsdom

To help you get started, we’ve selected a few jsdom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joseluisq / prelodr / test / prelodr.spec.js View on Github external
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;
github pa11y / sidekick / test / integration / front-end / post-profile.js View on Github external
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);
					});
github pa11y / sidekick / test / integration / front-end / post-login.js View on Github external
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);
github pa11y / sidekick / test / integration / front-end / get-profile.js View on Github external
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');
github omnisci / mapd-connector / test / getFrontendView.spec.js View on Github external
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) => {
github omnisci / mapd-connector / test / connection.spec.js View on Github external
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 });
    });
  });
github omnisci / mapd-connector / test / deleteFrontendView.spec.js View on Github external
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 });
  });
});
github omnisci / mapd-connector / test / getters-setters.spec.js View on Github external
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) => {
github omnisci / mapd-connector / test / createFrontendView.spec.js View on Github external
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 });
  });
});
github omnisci / mapd-connector / test-functional / utils / utils.js View on Github external
(done) => {
    jsdom.env({
      html,
      src: loadScripts(),
      done: (err, window) => { cb(done, window); }
    });
  }
);