-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some minor adjustments #12
base: develop
Are you sure you want to change the base?
Changes from 1 commit
87f26eb
cbfb73f
8632dee
f982c74
c834840
f3a201a
97dc8ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { Client } from './client'; | ||
import { Rebound } from '../rebound/rebound'; | ||
|
||
describe("Client:", () => { | ||
describe('Client:', () => { | ||
let client: any; | ||
let rebound: any; | ||
let rebound: Rebound; | ||
beforeEach(() => { | ||
client = new Client(); | ||
rebound = new Rebound(); | ||
|
||
rebound.setClient(client); | ||
}); | ||
|
||
describe("the basic use of this", () => { | ||
it("should have created a client", () => { | ||
describe('the basic use of this', () => { | ||
it('should have created a client', () => { | ||
expect(client).toBeDefined(); | ||
}); | ||
|
||
it("should not be able to set rebound after setting client", () => { | ||
client._rebound._randId = 'test' | ||
it('should not be able to set rebound after setting client', () => { | ||
client._rebound._randId = 'test'; | ||
client.setRebound(); | ||
expect(client._rebound._randId).toBe('test'); | ||
}); | ||
|
||
it("should be able to set an on event", () => { | ||
it('should be able to set an on event', () => { | ||
client.addEvents('focus'); | ||
|
||
client.on('focus', () => { | ||
|
@@ -37,15 +37,15 @@ describe("Client:", () => { | |
expect(client._events.focus()).toBe(100); | ||
}); | ||
|
||
it("should not be able to set an unauthorized event", () => { | ||
it('should not be able to set an unauthorized event', () => { | ||
client.on('notanevent', () => { | ||
return 100; | ||
}); | ||
|
||
expect(client._events.hasOwnProperty('notanevent')).toBe(false); | ||
}); | ||
|
||
it("should not be able to set an event after destroying client", () => { | ||
it('should not be able to set an event after destroying client', () => { | ||
expect(client._events).toBeDefined(); | ||
|
||
client.destroy(); | ||
|
@@ -59,15 +59,15 @@ describe("Client:", () => { | |
expect(client._events).toBe(undefined); | ||
}); | ||
|
||
it("should be able to add a single new possible event", () => { | ||
it('should be able to add a single new possible event', () => { | ||
expect(client._events.hasOwnProperty('testevent')).toBe(false); | ||
|
||
client.addEvents('testevent'); | ||
|
||
expect(client._events.hasOwnProperty('testevent')).toBe(true); | ||
}); | ||
|
||
it("should be able to add multiple new possible event", () => { | ||
it('should be able to add multiple new possible event', () => { | ||
expect(client._events.hasOwnProperty('testevent')).toBe(false); | ||
expect(client._events.hasOwnProperty('testevent2')).toBe(false); | ||
|
||
|
@@ -77,9 +77,9 @@ describe("Client:", () => { | |
expect(client._events.hasOwnProperty('testevent2')).toBe(true); | ||
}); | ||
|
||
it("should only be able to add strings as new possible event", () => { | ||
it('should only be able to add strings as new possible event', () => { | ||
let numOfKeysBefore = Object.keys(client._events).length; | ||
let eventTypes = [1, [], {}, 1.2, undefined, null, true]; | ||
let eventTypes = [1, [], {}, 1.2, undefined, undefined, true]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this null was here as a test case for one of the different types of data that could be thrown at it |
||
|
||
expect(client._events.hasOwnProperty('testevent')).toBe(false); | ||
|
||
|
@@ -99,11 +99,13 @@ describe("Client:", () => { | |
expect(numOfKeysBefore + 1).toBe(numOfKeysAfter); | ||
}); | ||
|
||
it("should not be able to overwrite a possible event", () => { | ||
it('should not be able to overwrite a possible event', () => { | ||
expect(client._events.hasOwnProperty('testevent')).toBe(false); | ||
|
||
client.addEvents('testevent'); | ||
client.on('testevent', function() {}); | ||
client.on('testevent', function() { | ||
console.log('testevent'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this so it does not yell at you for having an empty function? because this console.log is not required as it only checking to see if the property is actually there and not what the data is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep just to remove a error |
||
}); | ||
|
||
expect(client._events.hasOwnProperty('testevent')).toBe(true); | ||
expect(client._events.testevent).toBeDefined(); | ||
|
@@ -113,15 +115,15 @@ describe("Client:", () => { | |
expect(client._events.testevent).toBeDefined(); | ||
}); | ||
|
||
it("should not be able to add an empty string as a new possible event", () => { | ||
it('should not be able to add an empty string as a new possible event', () => { | ||
expect(client._events.hasOwnProperty('')).toBe(false); | ||
|
||
client.addEvents(''); | ||
|
||
expect(client._events.hasOwnProperty('')).toBe(false); | ||
}); | ||
|
||
it("should not be able to add a new possible event after destroying client", () => { | ||
it('should not be able to add a new possible event after destroying client', () => { | ||
expect(client._events).toBeDefined(); | ||
|
||
client.destroy(); | ||
|
@@ -130,7 +132,7 @@ describe("Client:", () => { | |
expect(client._events).toBe(undefined); | ||
}); | ||
|
||
it("should be able to dispatch an event", () => { | ||
it('should be able to dispatch an event', () => { | ||
client.addEvents('focus'); | ||
|
||
client.on('focus', () => { | ||
|
@@ -141,11 +143,11 @@ describe("Client:", () => { | |
client.dispatch('focus'); | ||
}); | ||
|
||
it("should not error when not able to dispatch an event", () => { | ||
it('should not error when not able to dispatch an event', () => { | ||
client.dispatch('focus', undefined, true); | ||
}); | ||
|
||
it("should not be able to dispatch an event after destroying client", () => { | ||
it('should not be able to dispatch an event after destroying client', () => { | ||
expect(client._events).toBeDefined(); | ||
|
||
client.destroy(); | ||
|
@@ -159,7 +161,7 @@ describe("Client:", () => { | |
expect(client._events).toBe(undefined); | ||
}); | ||
|
||
it("should not be able to dispatch an unauthorized event", () => { | ||
it('should not be able to dispatch an unauthorized event', () => { | ||
client.on('notanevent', () => { | ||
return 100; | ||
}); | ||
|
@@ -168,7 +170,7 @@ describe("Client:", () => { | |
client.dispatch('notanevent'); | ||
}); | ||
|
||
it("should be able to remove an event", () => { | ||
it('should be able to remove an event', () => { | ||
client.addEvents(['focus', 'blur']); | ||
|
||
client.on('blur', () => { | ||
|
@@ -188,13 +190,13 @@ describe("Client:", () => { | |
expect(client._events.focus).toBe(undefined); | ||
}); | ||
|
||
it("should not try to remove an event that doesnt exist", () => { | ||
it('should not try to remove an event that doesnt exist', () => { | ||
client.off('notanevent'); | ||
|
||
expect(client._events.hasOwnProperty('notanevent')).toBe(false); | ||
}); | ||
|
||
it("should be able to destroy all events", () => { | ||
it('should be able to destroy all events', () => { | ||
client.addEvents('focus'); | ||
|
||
client.on('focus', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
describe("This test", function() { | ||
it("will always pass", function() { | ||
describe('This test', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you add a comment to this so people know why this is here and that it should not be removed |
||
it('will always pass', function() { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { Client } from '../client/client'; | ||
|
||
export interface ReboundEvent { | ||
id?: string, | ||
event: string, | ||
value?: string | number | object | ||
id?: string; | ||
event: string; | ||
value?: string | number | object; | ||
} | ||
|
||
export interface ReboundType { | ||
[key: string]: (name: {} | string, data?: string) => void; | ||
} | ||
|
||
export interface ReboundConfig { | ||
client: Client, | ||
id?: string, | ||
autoConnect?: boolean | ||
} | ||
client: Client; | ||
id?: string; | ||
autoConnect?: boolean; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were you not able to remove this any too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do then the tests will fail because in typescript you should not be able to access them.