diff --git a/types/sinon-chrome/index.d.ts b/types/sinon-chrome/index.d.ts index 67614ff6bc..d7fd948c63 100644 --- a/types/sinon-chrome/index.d.ts +++ b/types/sinon-chrome/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/vitalets/sinon-chrome // Definitions by: Tim Perry // CRIMX +// kobanyan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -37,6 +38,8 @@ declare namespace SinonChrome { */ export function reset(): void; + export function registerPlugin(plugin: SinonChrome.plugins.Plugin): void; + export var csi: Sinon.SinonSpy; export var loadTimes: Sinon.SinonSpy; } @@ -353,6 +356,23 @@ declare namespace SinonChrome.permissions { export var request: SinonChromeStub; } +declare namespace SinonChrome.plugins { + export interface Plugin {} + export interface Translation { + message: string; + placeholders?: object; + } + export interface Translations { + [key: string]: Translation; + } + export class I18nPlugin implements Plugin { + constructor(translations: Translations); + } + export class CookiePlugin implements Plugin { + constructor(state?: Array); + } +} + declare namespace SinonChrome.power { export var releaseKeepAwake: SinonChromeStub; export var requestKeepAwake: SinonChromeStub; diff --git a/types/sinon-chrome/sinon-chrome-tests.ts b/types/sinon-chrome/sinon-chrome-tests.ts index 58639b8a65..7ae8a3f862 100644 --- a/types/sinon-chrome/sinon-chrome-tests.ts +++ b/types/sinon-chrome/sinon-chrome-tests.ts @@ -32,3 +32,50 @@ var id: string = chromeStub.runtime.id; chromeStub.proxy.settings.set({value: { }, scope: 'regular'}); chromeStub.proxy.settings.onChange.trigger(); + +chromeStub.registerPlugin(new chromeStub.plugins.I18nPlugin({ + one: { + message: 'Hi!' + }, + two: { + message: 'Hi $first_name$ $last_name$!', + placeholders: { + first_name: { + content: '$1' + }, + last_name: { + content: '$2' + } + } + } +})); + +chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin()); + +chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin( + [ + { + domain: '.domain.com', + expirationDate: 1511612273, + hostOnly: false, + httpOnly: false, + name: 'COOKIE_NAME', + path: '/data', + secure: false, + session: false, + storeId: '0', + value: 'COOKIE_VALUE' + }, + { + domain: 'other-domain.com', + hostOnly: false, + httpOnly: false, + name: 'other-cookie', + path: '/', + secure: false, + session: true, + storeId: '0', + value: '123' + } + ] +));