Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
RegionalSettings implementation, #649
Browse files Browse the repository at this point in the history
  • Loading branch information
koltyakov committed Nov 29, 2017
1 parent e4ca948 commit 9520e8f
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
98 changes: 98 additions & 0 deletions src/sharepoint/regionalsettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { SharePointQueryable, SharePointQueryableInstance, SharePointQueryableCollection } from "./sharepointqueryable";

/**
* Describes regional settings ODada object
*/
export class RegionalSettings extends SharePointQueryableInstance {

/**
* Creates a new instance of the RegionalSettings class
*
* @param baseUrl The url or SharePointQueryable which forms the parent of this regional settings collection
*/

constructor(baseUrl: string | SharePointQueryable, path = "regionalsettings") {
super(baseUrl, path);
}

/**
* Gets installed languages
*/
public get installedLanguages(): InstalledLanguages {
return new InstalledLanguages(this);
}

/**
* Gets time zone
*/
public get timeZone(): TimeZone {
return new TimeZone(this);
}

/**
* Gets time zones
*/
public get timeZones(): TimeZones {
return new TimeZones(this);
}

}

export interface RegionalSettingsProps {
AdjustHijriDays: number;
AlternateCalendarType: number;
AM: string;
CalendarType: number;
Collation: number;
CollationLCID: number;
DateFormat: number;
DateSeparator: string;
DecimalSeparator: string;
DigitGrouping: string;
FirstDayOfWeek: number;
FirstWeekOfYear: number;
IsEastAsia: boolean;
IsRightToLeft: boolean;
IsUIRightToLeft: boolean;
ListSeparator: string;
LocaleId: number;
NegativeSign: string;
NegNumberMode: number;
PM: string;
PositiveSign: string;
ShowWeeks: boolean;
ThousandSeparator: string;
Time24: boolean;
TimeMarkerPosition: number;
TimeSeparator: string;
WorkDayEndHour: number;
WorkDays: number;
WorkDayStartHour: number;
}

/**
* Describes TimeZone ODada object
*/
export class TimeZone extends SharePointQueryableInstance {
constructor(baseUrl: string | SharePointQueryable, path = "timezone") {
super(baseUrl, path);
}
}

/**
* Describes installed languages ODada queriable collection
*/
export class InstalledLanguages extends SharePointQueryableInstance {
constructor(baseUrl: string | SharePointQueryable, path = "installedlanguages") {
super(baseUrl, path);
}
}

/**
* Describes time zones queriable collection
*/
export class TimeZones extends SharePointQueryableCollection {
constructor(baseUrl: string | SharePointQueryable, path = "timezones") {
super(baseUrl, path);
}
}
8 changes: 8 additions & 0 deletions src/sharepoint/webs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Fields } from "./fields";
import { Navigation } from "./navigation";
import { SiteGroups, SiteGroup } from "./sitegroups";
import { ContentTypes } from "./contenttypes";
import { RegionalSettings } from "./regionalsettings";
import { Folders, Folder } from "./folders";
import { RoleDefinitions } from "./roles";
import { File } from "./files";
Expand Down Expand Up @@ -218,6 +219,13 @@ export class Web extends SharePointQueryableShareableWeb {
return new List(this, "siteuserinfolist");
}

/**
* Gets regional settings
*
*/
public get regionalSettings(): RegionalSettings {
return new RegionalSettings(this);
}

/**
* Gets the current user
Expand Down
40 changes: 40 additions & 0 deletions tests/sharepoint/regionalsettings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { expect } from "chai";
import { RegionalSettings } from "../../src/sharepoint/regionalsettings";
import { toMatchEndRegex } from "../testutils";

describe("RegionalSettings", () => {

let regionalsettings: RegionalSettings;

beforeEach(() => {
regionalsettings = new RegionalSettings("_api/web");
});

it("Should be an object", () => {
expect(regionalsettings).to.be.a("object");
});

describe("url", () => {
it("Should return _api/web/regionalsettings", () => {
expect(regionalsettings.toUrl()).to.match(toMatchEndRegex("_api/web/regionalsettings"));
});
});

describe("installedLanguages", () => {
it("Should return _api/web/regionalsettings/installedlanguages", () => {
expect(regionalsettings.installedLanguages.toUrl()).to.match(toMatchEndRegex("_api/web/regionalsettings/installedlanguages"));
});
});

describe("timeZone", () => {
it("Should return _api/web/regionalsettings/timezone", () => {
expect(regionalsettings.timeZone.toUrl()).to.match(toMatchEndRegex("_api/web/regionalsettings/timezone"));
});
});

describe("timeZones", () => {
it("Should return _api/web/regionalsettings/timezones", () => {
expect(regionalsettings.timeZones.toUrl()).to.match(toMatchEndRegex("_api/web/regionalsettings/timezones"));
});
});
});
6 changes: 6 additions & 0 deletions tests/sharepoint/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ describe("Web", () => {
});
});

describe("regionalSettings", () => {
it("should return _api/web/regionalsettings", () => {
expect(web.regionalSettings.toUrl()).to.match(toMatchEndRegex("_api/web/regionalsettings"));
});
});

describe("siteUserInfoList", () => {
it("should return _api/web/siteUserInfoList", () => {
expect(web.siteUserInfoList.toUrl()).to.match(toMatchEndRegex("_api/web/siteuserinfolist"));
Expand Down

0 comments on commit 9520e8f

Please sign in to comment.