Skip to content

Commit

Permalink
Began deprecated module test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Toliak committed May 22, 2021
1 parent 896f078 commit 303a541
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 13 deletions.
48 changes: 48 additions & 0 deletions tests/from_deprecated/MTA.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Tests backward compatibility
* With https://github.com/Subtixx/mtasa-typescript
*/

import { mtasa as server } from 'types/mtasa/server';
import { mtasa as client } from 'types/mtasa/client';

const exportsClient: LuaTable = client.exports;
const exports: LuaTable = server.exports;

const resourceClient: client.Resource = client.resource;
const resourceServer: server.Resource = server.resource;

const resourceRootClient: client.Element = client.resourceRoot;
const resourceRootServer: server.Element = server.resourceRoot;

const root: client.Element = client.root;
const rootClient: server.Element = server.root;

const guiRoot: client.Element = client.guiRoot;

const localPlayer: client.Player = client.localPlayer;

const sourceClient: client.Element = client.source;
const source: server.Element = server.source;

const eventNameClient: string = client.eventName;
const eventNameServer: string = server.eventName;

const clientSource: server.Player = server.client;

const sourceResourceRoot: server.Element = server.sourceResourceRoot;
const sourceResource: server.Resource = server.sourceResource;

const sourceTimerClient: client.Timer = client.sourceTimer;
const sourceTimerServer: server.Timer = server.sourceTimer;

client.addCommandHandler('command', () => null);
client.addCommandHandler('command', () => null, false);
server.addCommandHandler('command', () => null, true, false);
server.addCommandHandler('command', () => null, true);
server.addCommandHandler('command', () => null);

client.outputChatBox('message', 255, 255, 255, true);
client.outputChatBox('message');
server.outputChatBox('message', server.getRandomPlayer(), 255, 255, 255, true);
server.outputChatBox('message', server.getRandomPlayer());
45 changes: 45 additions & 0 deletions tests/from_deprecated/blip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Tests backward compatibility
* With https://github.com/Subtixx/mtasa-typescript
*/

import { mtasa } from 'types/mtasa/server';

let blip: mtasa.Blip = mtasa.createBlip(
10,
10,
10,
1,
1,
255,
255,
255,
255,
1,
100,
mtasa.root,
);

blip = mtasa.createBlipAttachedTo(
mtasa.getRandomPlayer(),
1,
1,
255,
255,
255,
255,
1,
100,
mtasa.root,
);

const color: [number, number, number, number] = mtasa.getBlipColor(blip);
const icon: number = mtasa.getBlipIcon(blip);
const size: number = mtasa.getBlipSize(blip);
const colorR: boolean = mtasa.setBlipColor(blip, 255, 255, 255, 10);
const iconR: boolean = mtasa.setBlipIcon(blip, 3);
const sizeR: boolean = mtasa.setBlipSize(blip, 3);
const ordering: number = mtasa.getBlipOrdering(blip);
const orderingR: boolean = mtasa.setBlipOrdering(blip, 0);
const visibleDistance: number = mtasa.getBlipVisibleDistance(blip);
const visibleDistanceR: boolean = mtasa.setBlipVisibleDistance(blip, 60);
1 change: 1 addition & 0 deletions types/mtasa/client/mtasa.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ export * from './oop/Element';
export * from './oop/XmlNode';
export * from './oop/Blip';
export * from './oop/RenderTarget';
export * from './variables';
13 changes: 2 additions & 11 deletions types/mtasa/client/variables.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Element } from './oop/Element';
import { Resource } from './oop/Resource';
import { Player } from './oop/Player';
import { Timer } from './oop/Timer';

/**
* A table of resource names containing all export functions
Expand Down Expand Up @@ -42,17 +43,7 @@ export const source: Element;
*/
export const eventName: string;

/**
* The root of the resource that called the event
*/
export const sourceResourceRoot: Element;

/**
* The resource that called the event
*/
export const sourceResource: Element;

/**
* Current timer in callback function.
*/
export const sourceTimer: Element;
export const sourceTimer: Timer;
1 change: 1 addition & 0 deletions types/mtasa/server/mtasa.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ export * from './oop/XML';
export * from './oop/Element';
export * from './oop/XmlNode';
export * from './oop/Blip';
export * from './variables';
5 changes: 3 additions & 2 deletions types/mtasa/server/variables.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Element } from './oop/Element';
import { Resource } from './oop/Resource';
import { Player } from './oop/Player';
import { Timer } from './oop/Timer';

/**
* A table of resource names containing all export functions
Expand Down Expand Up @@ -45,9 +46,9 @@ export const sourceResourceRoot: Element;
/**
* The resource that called the event
*/
export const sourceResource: Element;
export const sourceResource: Resource;

/**
* Current timer in callback function.
*/
export const sourceTimer: Element;
export const sourceTimer: Timer;

1 comment on commit 303a541

@Toliak
Copy link
Member Author

@Toliak Toliak commented on 303a541 May 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #18

Please sign in to comment.