jest-useragent-mock
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -6,10 +6,11 @@ 'use strict'; | ||
var origin = global.navigator.userAgent; | ||
var cleared = Symbol('clear'); | ||
var fakeUserAgent = null; | ||
Object.defineProperty(global.navigator, 'userAgent', { | ||
get: function _get() { | ||
return fakeUserAgent || origin; | ||
get: function get() { | ||
return fakeUserAgent === cleared ? origin : fakeUserAgent || ''; | ||
} | ||
}); | ||
var clear = function clear() { | ||
fakeUserAgent = ''; | ||
fakeUserAgent = cleared; | ||
}; | ||
@@ -16,0 +17,0 @@ var mockUserAgent = function mockUserAgent(agent) { |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var origin=global.navigator.userAgent,fakeUserAgent=null;Object.defineProperty(global.navigator,"userAgent",{get:function(){return fakeUserAgent||origin}});var clear=function(){fakeUserAgent=""},mockUserAgent=function(e){fakeUserAgent=e};exports.clear=clear,exports.mockUserAgent=mockUserAgent; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var origin=global.navigator.userAgent,cleared=Symbol("clear"),fakeUserAgent=null;Object.defineProperty(global.navigator,"userAgent",{get:function(){return fakeUserAgent===cleared?origin:fakeUserAgent||""}});var clear=function(){fakeUserAgent=cleared},mockUserAgent=function(e){fakeUserAgent=e};exports.clear=clear,exports.mockUserAgent=mockUserAgent; |
{ | ||
"name": "jest-useragent-mock", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Mock `navigator.userAgent` when run unit test cases with jest.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,2 +5,4 @@ # jest-useragent-mock | ||
[![Build Status](https://travis-ci.org/ariesjia/jest-useragent-mock.svg?branch=master)](https://travis-ci.org/ariesjia/jest-useragent-mock) | ||
[![license](https://badgen.net/badge/license/MIT/blue)](https://github.com/ariesjia/jest-useragent-mock/blob/master/LICENSE) | ||
[![coverage](https://badgen.net/codecov/c/github/ariesjia/jest-useragent-mock)](https://codecov.io/gh/ariesjia/jest-useragent-mock) | ||
@@ -7,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1162
44
87034
26