File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed
Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ export class Octokit {
6262 requestDefaults . mediaType . previews = options . previews ;
6363 }
6464
65+ if ( options . timeZone ) {
66+ requestDefaults . headers [ "time-zone" ] = options . timeZone ;
67+ }
68+
6569 if ( options . auth ) {
6670 if ( typeof options . auth === "string" ) {
6771 requestDefaults . headers . authorization = withAuthorizationPrefix (
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Octokit } from ".";
66export type OctokitOptions = {
77 auth ?: string | AutenticationHook ;
88 request ?: OctokitRequestOptions ;
9+ timeZone ?: string ;
910 [ option : string ] : any ;
1011} ;
1112
Original file line number Diff line number Diff line change @@ -63,6 +63,33 @@ describe("Octokit.defaults", () => {
6363 } ) ;
6464 } ) ;
6565
66+ it ( "Octokit.defaults({timeZone})" , ( ) => {
67+ const mock = fetchMock . sandbox ( ) . getOnce (
68+ "https://api.github.com/" ,
69+ { ok : true } ,
70+ {
71+ headers : {
72+ accept : "application/vnd.github.v3+json" ,
73+ "user-agent" : userAgent ,
74+ "time-zone" : "Europe/Amsterdam"
75+ }
76+ }
77+ ) ;
78+
79+ const OctokitWithDefaults = Octokit . defaults ( {
80+ timeZone : "Europe/Amsterdam" ,
81+ request : {
82+ fetch : mock
83+ }
84+ } ) ;
85+
86+ const octokit = new OctokitWithDefaults ( ) ;
87+
88+ return octokit . request ( "GET /" ) . then ( response => {
89+ expect ( response . data ) . toStrictEqual ( { ok : true } ) ;
90+ } ) ;
91+ } ) ;
92+
6693 it ( "Octokit.defaults({auth})" , async ( ) => {
6794 const mock = fetchMock . sandbox ( ) . getOnce (
6895 "https://api.github.com/app" ,
Original file line number Diff line number Diff line change @@ -75,6 +75,31 @@ describe("octokit.request()", () => {
7575 } ) ;
7676 } ) ;
7777
78+ it ( "custom time zone" , ( ) => {
79+ const mock = fetchMock . sandbox ( ) . getOnce (
80+ "https://api.github.com/" ,
81+ { ok : true } ,
82+ {
83+ headers : {
84+ accept : "application/vnd.github.v3+json" ,
85+ "user-agent" : userAgent ,
86+ "time-zone" : "Europe/Amsterdam"
87+ }
88+ }
89+ ) ;
90+
91+ const octokit = new Octokit ( {
92+ timeZone : "Europe/Amsterdam" ,
93+ request : {
94+ fetch : mock
95+ }
96+ } ) ;
97+
98+ return octokit . request ( "GET /" ) . then ( response => {
99+ expect ( response . data ) . toStrictEqual ( { ok : true } ) ;
100+ } ) ;
101+ } ) ;
102+
78103 it ( "previews" , async ( ) => {
79104 const mock = fetchMock
80105 . sandbox ( )
You can’t perform that action at this time.
0 commit comments