Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

window-mock

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

window-mock - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

src/class-list-mock.spec.js

3

lib/class-list-mock.js

@@ -51,2 +51,3 @@ 'use strict';

exports.ClassListMock = ClassListMock;
exports['default'] = ClassListMock;
module.exports = exports['default'];

@@ -29,2 +29,3 @@ 'use strict';

exports.WindowApplicationCacheMock = WindowApplicationCacheMock;
exports['default'] = WindowApplicationCacheMock;
module.exports = exports['default'];

@@ -9,2 +9,4 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -14,4 +16,8 @@

var _windowNodeMock2 = _interopRequireDefault(_windowNodeMock);
var _windowFragmentMock = require('./window-fragment-mock');
var _windowFragmentMock2 = _interopRequireDefault(_windowFragmentMock);
var WindowDocumentMock = (function () {

@@ -22,3 +28,3 @@ function WindowDocumentMock() {

this._test = 'Document';
this.body = new _windowNodeMock.WindowNodeMock();
this.body = new _windowNodeMock2['default']();
}

@@ -29,3 +35,3 @@

value: function createDocumentFragment() {
return new _windowFragmentMock.WindowFragmentMock();
return new _windowFragmentMock2['default']();
}

@@ -35,3 +41,3 @@ }, {

value: function createElement() {
return new _windowNodeMock.WindowNodeMock();
return new _windowNodeMock2['default']();
}

@@ -41,3 +47,3 @@ }, {

value: function querySelector() {
return new _windowNodeMock.WindowNodeMock();
return new _windowNodeMock2['default']();
}

@@ -47,3 +53,3 @@ }, {

value: function querySelectorAll() {
return [new _windowNodeMock.WindowNodeMock()];
return [new _windowNodeMock2['default']()];
}

@@ -55,2 +61,3 @@ }]);

exports.WindowDocumentMock = WindowDocumentMock;
exports['default'] = WindowDocumentMock;
module.exports = exports['default'];

@@ -9,2 +9,4 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -16,2 +18,4 @@

var _windowNodeMock2 = _interopRequireDefault(_windowNodeMock);
var WindowFragmentMock = (function (_WindowNodeMock) {

@@ -28,4 +32,5 @@ _inherits(WindowFragmentMock, _WindowNodeMock);

return WindowFragmentMock;
})(_windowNodeMock.WindowNodeMock);
})(_windowNodeMock2['default']);
exports.WindowFragmentMock = WindowFragmentMock;
exports['default'] = WindowFragmentMock;
module.exports = exports['default'];

@@ -39,2 +39,3 @@ 'use strict';

exports.WindowLocalStorageMock = WindowLocalStorageMock;
exports['default'] = WindowLocalStorageMock;
module.exports = exports['default'];

@@ -16,2 +16,3 @@ 'use strict';

exports.WindowLocationMock = WindowLocationMock;
exports['default'] = WindowLocationMock;
module.exports = exports['default'];

@@ -11,2 +11,4 @@ // Fake browser for testing

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -16,10 +18,20 @@

var _windowApplicationCacheMock2 = _interopRequireDefault(_windowApplicationCacheMock);
var _windowNavigatorMock = require('./window-navigator-mock');
var _windowNavigatorMock2 = _interopRequireDefault(_windowNavigatorMock);
var _windowLocationMock = require('./window-location-mock');
var _windowLocationMock2 = _interopRequireDefault(_windowLocationMock);
var _windowLocalStorageMock = require('./window-local-storage-mock');
var _windowLocalStorageMock2 = _interopRequireDefault(_windowLocalStorageMock);
var _windowDocumentMock = require('./window-document-mock');
var _windowDocumentMock2 = _interopRequireDefault(_windowDocumentMock);
var WindowMock = (function () {

@@ -30,7 +42,7 @@ function WindowMock() {

this._test = 'Window';
this.applicationCache = new _windowApplicationCacheMock.WindowApplicationCacheMock();
this.navigator = new _windowNavigatorMock.WindowNavigatorMock();
this.location = new _windowLocationMock.WindowLocationMock();
this.localStorage = new _windowLocalStorageMock.WindowLocalStorageMock();
this.document = new _windowDocumentMock.WindowDocumentMock();
this.applicationCache = new _windowApplicationCacheMock2['default']();
this.navigator = new _windowNavigatorMock2['default']();
this.location = new _windowLocationMock2['default']();
this.localStorage = new _windowLocalStorageMock2['default']();
this.document = new _windowDocumentMock2['default']();
}

@@ -37,0 +49,0 @@

@@ -16,2 +16,3 @@ 'use strict';

exports.WindowNavigatorMock = WindowNavigatorMock;
exports['default'] = WindowNavigatorMock;
module.exports = exports['default'];

@@ -9,2 +9,4 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -14,2 +16,4 @@

var _classListMock2 = _interopRequireDefault(_classListMock);
var WindowNodeMock = (function () {

@@ -21,3 +25,3 @@ function WindowNodeMock() {

this.children = [];
this.classList = new _classListMock.ClassListMock();
this.classList = new _classListMock2['default']();
}

@@ -45,2 +49,3 @@

exports.WindowNodeMock = WindowNodeMock;
exports['default'] = WindowNodeMock;
module.exports = exports['default'];
{
"name": "window-mock",
"version": "0.0.5",
"description": "A light-weight window mock for Node/io.js testing",
"version": "0.0.6",
"description": "A light-weight window mock for Node/io.js unit-testing",
"main": "lib/window-mock.js",

@@ -6,0 +6,0 @@ "repository": {

@@ -1,2 +0,2 @@

export class ClassListMock {
export default class ClassListMock {

@@ -3,0 +3,0 @@ constructor() {

@@ -1,2 +0,2 @@

export class WindowApplicationCacheMock {
export default class WindowApplicationCacheMock {

@@ -3,0 +3,0 @@ constructor() {

@@ -1,5 +0,5 @@

import {WindowNodeMock} from './window-node-mock';
import {WindowFragmentMock} from './window-fragment-mock';
import WindowNodeMock from './window-node-mock';
import WindowFragmentMock from './window-fragment-mock';
export class WindowDocumentMock {
export default class WindowDocumentMock {

@@ -6,0 +6,0 @@ constructor() {

@@ -1,4 +0,4 @@

import {WindowNodeMock} from './window-node-mock';
import WindowNodeMock from './window-node-mock';
export class WindowFragmentMock extends WindowNodeMock {
export default class WindowFragmentMock extends WindowNodeMock {

@@ -5,0 +5,0 @@ constructor() {

@@ -1,2 +0,2 @@

export class WindowLocalStorageMock {
export default class WindowLocalStorageMock {

@@ -3,0 +3,0 @@ constructor() {

@@ -1,2 +0,2 @@

export class WindowLocationMock {
export default class WindowLocationMock {

@@ -3,0 +3,0 @@ constructor() {

// Fake browser for testing
import {WindowApplicationCacheMock} from './window-application-cache-mock';
import {WindowNavigatorMock} from './window-navigator-mock';
import {WindowLocationMock} from './window-location-mock';
import {WindowLocalStorageMock} from './window-local-storage-mock';
import {WindowDocumentMock} from './window-document-mock';
import WindowApplicationCacheMock from './window-application-cache-mock';
import WindowNavigatorMock from './window-navigator-mock';
import WindowLocationMock from './window-location-mock';
import WindowLocalStorageMock from './window-local-storage-mock';
import WindowDocumentMock from './window-document-mock';

@@ -9,0 +9,0 @@ export default class WindowMock {

@@ -5,5 +5,5 @@ import test from 'tape';

let windowMock = new WindowMock();
let mock = new WindowMock();
test(`${name}: Window`, (t) => {
test(`${name}: window`, (t) => {
let

@@ -13,29 +13,29 @@ tmp,

t.equal(windowMock._test, 'Window', 'should be a Window object');
t.equal(mock._test, 'Window', 'should be a Window object');
t.equal(typeof windowMock.applicationCache, 'object', 'applicationCache should be an object');
t.equal(typeof mock.applicationCache, 'object', 'applicationCache should be an object');
t.equal(typeof windowMock.navigator, 'object', 'navigator should be an object');
t.equal(typeof mock.navigator, 'object', 'navigator should be an object');
t.equal(typeof windowMock.location, 'object', 'location should be an object');
t.equal(typeof mock.location, 'object', 'location should be an object');
t.equal(typeof windowMock.localStorage, 'object', 'localStorage should be an object');
t.equal(typeof mock.localStorage, 'object', 'localStorage should be an object');
t.equal(typeof windowMock.document, 'object', 'document should be an object');
t.equal(typeof mock.document, 'object', 'document should be an object');
t.equal(typeof windowMock.setTimeout, 'function', 'setTimeout should be a function');
t.equal(typeof mock.setTimeout, 'function', 'setTimeout should be a function');
tmp = false;
windowMock.setTimeout(tmpFunc);
mock.setTimeout(tmpFunc);
t.equal(tmp, true, 'setTimeout should invoke callback');
t.equal(typeof windowMock.requestAnimationFrame, 'function', 'requestAnimationFrame should be a function');
t.equal(typeof mock.requestAnimationFrame, 'function', 'requestAnimationFrame should be a function');
tmp = false;
windowMock.requestAnimationFrame(tmpFunc);
mock.requestAnimationFrame(tmpFunc);
t.equal(tmp, true, 'requestAnimationFrame should invoke callback');
t.equal(typeof windowMock.btoa, 'function', 'btoa should be a function');
t.equal(typeof mock.btoa, 'function', 'btoa should be a function');
t.equal(windowMock.btoa('x'), 'x', 'btoa should return');
t.equal(mock.btoa('x'), 'x', 'btoa should return');
t.end();
});

@@ -1,2 +0,2 @@

export class WindowNavigatorMock {
export default class WindowNavigatorMock {

@@ -3,0 +3,0 @@ constructor() {

@@ -1,4 +0,4 @@

import {ClassListMock} from './class-list-mock';
import ClassListMock from './class-list-mock';
export class WindowNodeMock {
export default class WindowNodeMock {

@@ -5,0 +5,0 @@ constructor() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc