Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
unit
  • Loading branch information
SimenB committed Feb 23, 2022
commit 3095aadf15258b6f11aec7e87509d80f8f775b85
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import JSDomEnvironment from '../';

describe('JSDomEnvironment', () => {
it('should configure setTimeout/setInterval to use the browser api', () => {
const env = new JSDomEnvironment({
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
});
const env = new JSDomEnvironment(
{
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
},
{console, docblockPragmas: {}, testPath: __filename},
);

env.fakeTimers!.useFakeTimers();

Expand All @@ -26,23 +29,29 @@ describe('JSDomEnvironment', () => {
});

it('has modern fake timers implementation', () => {
const env = new JSDomEnvironment({
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
});
const env = new JSDomEnvironment(
{
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
},
{console, docblockPragmas: {}, testPath: __filename},
);

expect(env.fakeTimersModern).toBeDefined();
});

it('should respect userAgent option', () => {
const env = new JSDomEnvironment({
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig({
testEnvironmentOptions: {
userAgent: 'foo',
},
}),
});
const env = new JSDomEnvironment(
{
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig({
testEnvironmentOptions: {
userAgent: 'foo',
},
}),
},
{console, docblockPragmas: {}, testPath: __filename},
);

expect(env.dom.window.navigator.userAgent).toEqual('foo');
});
Expand All @@ -60,10 +69,13 @@ describe('JSDomEnvironment', () => {
* will be called, so please make sure the global.document is still available at this point.
*/
it('should not set the global.document to null too early', () => {
const env = new JSDomEnvironment({
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
});
const env = new JSDomEnvironment(
{
globalConfig: makeGlobalConfig(),
projectConfig: makeProjectConfig(),
},
{console, docblockPragmas: {}, testPath: __filename},
);

const originalCloseFn = env.global.close.bind(env.global);
env.global.close = () => {
Expand Down