Skip to content

anttoon/mockdoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MockDoc - Mock document for tests

Usage

And('DOM is loaded', () => {
  global.document = new Mockdock();
  require('app.js');
});
let testValue;

When('DOM is loaded', () => {
  global.document = new Mockdock();
  global.document.body = new Mockdock();
  global.document.body.on('setAttribute', (value) => {
    testValue = value;
  });
});

Then('app is started', () => {
  require('app.js');
  testValue.should.equal('some-attribute');
})

Events

global.document.on('setAttribute', (value) => {}));

global.document.on('removeAttribute', (value) => {}));

global.document.on('DOMContentLoaded', () => {});

global.document.on('appendChild', (element) => {}));

global.document.domContentLoaded()

global.document.triggerEventListener(type)

Supported node functions

addEventListener(type, fn)

createElement(type)

getElementsByTagName(tag)

removeAttribute(attrName)

setAttribute(cmd, value)

hasAttribute(attrName)

getElementById(id)

querySelector(selectors)

querySelectorAll()

getAttribute(name)

appendChild(element)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published