Skip to content

Commit

Permalink
adding typescript files (#41)
Browse files Browse the repository at this point in the history
* adding typescript tests
  • Loading branch information
warbhe-amit authored Aug 29, 2022
1 parent 99ff8d8 commit c5f7f4e
Show file tree
Hide file tree
Showing 11 changed files with 1,343 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions test/typescript/accessibility.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2021 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { test, expect } from '@jest/globals';
import { Accessibility } from '../../dist/lib/firebolt';


test('listen', () => {
return Accessibility.listen((event: string, data: object) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});


test('once', () => {
return Accessibility.once((event: string, data: object) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});


test('listen ClosedCaptionsSettings', () => {
return Accessibility.listen((event: 'closedCaptionsSettingsChanged', listener: { data: Accessibility.ClosedCaptionsSettings }) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});




test('once ClosedCaptionsSettings', () => {
return Accessibility.once((event: 'closedCaptionsSettingsChanged', listener: { data: Accessibility.ClosedCaptionsSettings }) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});

test('listen VoiceGuidanceSettings', () => {
return Accessibility.listen((event: 'closedCaptionsSettingsChanged', listener: { data: Accessibility.VoiceGuidanceSettings }) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});

test('once VoiceGuidanceSettings', () => {
return Accessibility.once((event: 'closedCaptionsSettingsChanged', listener: { data: Accessibility.VoiceGuidanceSettings }) => { }).then((res: number) => {
expect(res > 0).toBe(true);
});
});


test('clear()', () => {
const result: boolean = Accessibility.clear(2);
expect(result).toBeFalsy();
});




89 changes: 89 additions & 0 deletions test/typescript/advertising.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2021 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { test, expect } from "@jest/globals";
import { Advertising } from "../../dist/lib/firebolt";

test("policy()", () => {
return Advertising.policy().then((policy: Advertising.AdPolicy) => {
expect(policy.skipRestriction).toBe("adsUnwatched");
expect(policy.limitAdTracking).toBe(false);
});
});

test("config()", () => {
return Advertising.config({
coppa: true,
environment: "test",
authenticationEntity: "Test",
}).then((res: object) => {
expect(typeof res).toBe("object");
});
});

test("advertisingId()", () => {
return Advertising.advertisingId().then((res: object) => {
expect(typeof res).toBe("object");
});
});

test("deviceAttributes()", () => {
return Advertising.deviceAttributes().then((res: object) => {
expect(typeof res).toBe("object");
});
});

test("appBundleId()", () => {
return Advertising.appBundleId().then((res: string) => {
expect(res).toBe("operator.app");
expect(typeof res).toBe("string");
});
});

test("listen()", () => {
return Advertising.listen((event: string, data: object) => {}).then(
(res: number) => {
expect(res > 0).toBe(true);
}
);
});

test("once()", () => {
return Advertising.once((event: string, data: object) => {}).then(
(res: number) => {
expect(res > 0).toBe(true);
}
);
});

test("listen() specific Advertising event.", () => {
return Advertising.listen("policyChanged", () => {}).then((res: number) => {
expect(res > 0).toBe(true);
});
});

test("once() specific Advertising event.", () => {
return Advertising.once("policyChanged", () => {}).then((res: number) => {
expect(res > 0).toBe(true);
});
});

test("clear()", () => {
const result: boolean = Advertising.clear(2);
expect(result).toBeFalsy();
});
Loading

0 comments on commit c5f7f4e

Please sign in to comment.