• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript deep-freeze-node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中deep-freeze-node的典型用法代码示例。如果您正苦于以下问题:TypeScript deep-freeze-node类的具体用法?TypeScript deep-freeze-node怎么用?TypeScript deep-freeze-node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了deep-freeze-node类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: deepFreeze

import * as deepFreeze from 'deep-freeze-node'
import * as shieldsPanelState from '../../../brave_extension/extension/brave_extension/state/shieldsPanelState'
import { State } from '../../../brave_extension/extension/brave_extension/types/state/shieldsPannelState'

const state: State = deepFreeze({
  currentWindowId: 1,
  tabs: {
    2: {
      id: 2,
      ads: 'block',
      trackers: 'block',
      httpUpgradableResources: 'block',
      javascript: 'block',
      fingerprinting: 'block',
      cookies: 'block'
    },
    3: {
      id: 3
    },
    4: {
      id: 4
    }
  },
  windows: {
    1: 2,
    2: 3
  }
})

describe('shieldsPanelState test', () => {
  describe('getActiveTabId', () => {
    it('Obtains the active tab ID based on the current window', () => {
开发者ID:Snuupy,项目名称:brave-core,代码行数:32,代码来源:shieldsPanelState_test.ts


示例2: describe

 describe('WINDOW_FOCUS_CHANGED', () => {
   const windowId = 1
   const tabId = 2
   let updateFocusedWindowSpy: jest.SpyInstance
   let requestShieldPanelDataSpy: jest.SpyInstance
   const state = deepFreeze({
     ...initialState.shieldsPanel,
     windows: {
       1: tabId
     },
     tabs: {
       [tabId]: { url: 'https://brave.com' }
     }
   })
   beforeEach(() => {
     updateFocusedWindowSpy = jest.spyOn(shieldsPanelState, 'updateFocusedWindow')
     requestShieldPanelDataSpy = jest.spyOn(shieldsAPI, 'requestShieldPanelData')
   })
   afterEach(() => {
     updateFocusedWindowSpy.mockRestore()
     requestShieldPanelDataSpy.mockRestore()
   })
   it('calls shieldsPanelState.updateFocusedWindow', () => {
     shieldsPanelReducer(state, { type: windowTypes.WINDOW_FOCUS_CHANGED, windowId: windowId })
     expect(updateFocusedWindowSpy).toBeCalledTimes(1)
     expect(updateFocusedWindowSpy.mock.calls[0][1]).toBe(windowId)
   })
   it('calls shieldsPanelState.requestShieldPanelDataSpy ', () => {
     shieldsPanelReducer(state, { type: windowTypes.WINDOW_FOCUS_CHANGED, windowId: windowId })
     expect(requestShieldPanelDataSpy).toBeCalledWith(tabId)
   })
 })
开发者ID:Snuupy,项目名称:brave-core,代码行数:32,代码来源:shieldsPanelReducer_test.ts


示例3: beforeEach

 beforeEach(() => {
   updateFocusedWindowSpy = jest.spyOn(shieldsPanelState, 'updateFocusedWindow')
   requestShieldPanelDataSpy = jest.spyOn(shieldsAPI, 'requestShieldPanelData')
   const state = deepFreeze({
     ...initialState.shieldsPanel,
     windows: {
       1: tabId
     },
     tabs: {
       [tabId]: { url: 'https://brave.com' }
     }
   })
   shieldsPanelReducer(state, {
     type: windowTypes.WINDOW_FOCUS_CHANGED,
     windowId: windowId
   })
 })
开发者ID:Snuupy,项目名称:brave-core,代码行数:17,代码来源:cosmeticFilterReducer_test.ts


示例4: it

    it('increases different tab counts separately', () => {
      let nextState = deepFreeze(shieldsPanelReducer(state, {
        type: types.RESOURCE_BLOCKED,
        details: {
          blockType: 'ads',
          tabId: 2,
          subresource: 'https://test.brave.com'
        }
      }))
      expect(nextState).toEqual({
        currentWindowId: 1,
        tabs: {
          2: {
            adsBlocked: 1,
            trackersBlocked: 0,
            httpsRedirected: 0,
            javascriptBlocked: 0,
            fingerprintingBlocked: 0,
            origin: 'https://brave.com',
            hostname: 'brave.com',
            controlsOpen: true,
            braveShields: 'allow',
            httpUpgradableResources: 'block',
            id: 2,
            javascript: 'block',
            trackers: 'block',
            ads: 'block',
            fingerprinting: 'block',
            cookies: 'block',
            noScriptInfo: {},
            trackersBlockedResources: [],
            adsBlockedResources: [
              'https://test.brave.com'
            ],
            fingerprintingBlockedResources: [],
            httpsRedirectedResources: [],
            javascriptBlockedResources: []
          }
        },
        windows: {
          1: 2
        }
      })

      nextState = shieldsPanelReducer(nextState, {
        type: types.RESOURCE_BLOCKED,
        details: {
          blockType: 'ads',
          tabId: 3,
          subresource: 'https://test.brave.com'
        }
      })

      expect(nextState).toEqual({
        currentWindowId: 1,
        tabs: {
          2: {
            origin: 'https://brave.com',
            hostname: 'brave.com',
            adsBlocked: 1,
            trackersBlocked: 0,
            httpsRedirected: 0,
            javascriptBlocked: 0,
            fingerprintingBlocked: 0,
            controlsOpen: true,
            braveShields: 'allow',
            httpUpgradableResources: 'block',
            id: 2,
            javascript: 'block',
            trackers: 'block',
            ads: 'block',
            fingerprinting: 'block',
            cookies: 'block',
            noScriptInfo: {},
            trackersBlockedResources: [],
            adsBlockedResources: [ 'https://test.brave.com' ],
            fingerprintingBlockedResources: [],
            httpsRedirectedResources: [],
            javascriptBlockedResources: []
          },
          3: {
            adsBlocked: 1,
            trackersBlocked: 0,
            httpsRedirected: 0,
            javascriptBlocked: 0,
            fingerprintingBlocked: 0,
            noScriptInfo: {},
            trackersBlockedResources: [],
            adsBlockedResources: [ 'https://test.brave.com' ],
            fingerprintingBlockedResources: [],
            httpsRedirectedResources: [],
            javascriptBlockedResources: []
          }
        },
        windows: {
          1: 2
        }
      })
    })
开发者ID:Snuupy,项目名称:brave-core,代码行数:99,代码来源:shieldsPanelReducer_test.ts


示例5: ChromeEvent

    },
    extension: {
      inIncognitoContext: new ChromeEvent()
    },
    topSites: {
      get: function () {
        return
      }
    },
    bookmarks: {
      search: function () {
        return
      }
    }
  }
}

export const initialState = deepFreeze({
  cosmeticFilter: {
    currentWindowId: -1,
    tabs: {},
    windows: {}
  },
  runtime: {},
  shieldsPanel: {
    currentWindowId: -1,
    tabs: {},
    windows: {}
  }
})
开发者ID:Snuupy,项目名称:brave-core,代码行数:30,代码来源:testData.ts


示例6: it

describe('cosmeticFilterReducer', () => {
  it('should handle initial state', () => {
    expect(shieldsPanelReducer(undefined, actions.blockAdsTrackers('allow')))
      .toEqual(initialState.cosmeticFilter)
  })
  describe('ON_COMMITTED', () => {
    const tabId = 1
    let spy: jest.SpyInstance
    let resetNoScriptInfoSpy: jest.SpyInstance
    let resetBlockingResourcesSpy: jest.SpyInstance
    beforeEach(() => {
      spy = jest.spyOn(shieldsPanelState, 'resetBlockingStats')
      resetNoScriptInfoSpy = jest.spyOn(shieldsPanelState, 'resetNoScriptInfo')
      resetBlockingResourcesSpy = jest.spyOn(shieldsPanelState, 'resetBlockingResources')
    })
    afterEach(() => {
      spy.mockRestore()
      resetNoScriptInfoSpy.mockRestore()
      resetBlockingResourcesSpy.mockRestore()
    })
    it('calls resetBlockingStats when isMainFrame is true', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: true
      })
      expect(spy).toBeCalledTimes(1)
      expect(spy.mock.calls[0][1]).toBe(tabId)
    })
    it('does not call resetBlockingStats when isMainFrame is false', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: false
      })
      expect(spy).not.toBeCalled()
    })
    it('calls resetNoScriptInfo when isMainFrame is true', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: true
      })
      expect(resetNoScriptInfoSpy).toBeCalledTimes(1)
      expect(resetNoScriptInfoSpy.mock.calls[0][1]).toBe(tabId)
      expect(resetNoScriptInfoSpy.mock.calls[0][2]).toBe('https://www.brave.com')
    })
    it('does not call resetNoScriptInfo when isMainFrame is false', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: false
      })
      expect(resetNoScriptInfoSpy).not.toBeCalled()
    })
    it('calls resetBlockingResources when isMainFrame is true', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: true
      })
      expect(spy).toBeCalledTimes(1)
      expect(spy.mock.calls[0][1]).toBe(tabId)
    })
    it('does not call resetBlockingResources when isMainFrame is false', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: webNavigationTypes.ON_COMMITTED,
        tabId: tabId,
        url: 'https://www.brave.com',
        isMainFrame: false
      })
      expect(spy).not.toBeCalled()
    })
  })
  describe('WINDOW_REMOVED', () => {
    const windowId = 1
    let spy: jest.SpyInstance
    beforeEach(() => {
      spy = jest.spyOn(shieldsPanelState, 'removeWindowInfo')
    })
    afterEach(() => {
      spy.mockRestore()
    })
    it('calls shieldsPanelState.removeWindowInfo', () => {
      shieldsPanelReducer(initialState.shieldsPanel, {
        type: windowTypes.WINDOW_REMOVED,
        windowId
      })
      expect(spy).toBeCalledTimes(1)
      expect(spy.mock.calls[0][1]).toBe(windowId)
    })
  })
  describe('WINDOW_FOCUS_CHANGED', () => {
    const windowId = 1
    const tabId = 2
//.........这里部分代码省略.........
开发者ID:Snuupy,项目名称:brave-core,代码行数:101,代码来源:cosmeticFilterReducer_test.ts



注:本文中的deep-freeze-node类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript deepmerge类代码示例发布时间:2022-05-28
下一篇:
TypeScript deep-freeze类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap