@sockethub/platform-irc 4.0.0-alpha.3 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +0,0 @@
1
- modules.exports = [
2
- {
3
- "name":"irc credentials",
4
- "valid":true,
5
- "type":"credentials",
6
- "input":{
7
- "context":"irc",
8
- "type":"credentials",
9
- "actor":{
10
- "id":"sh-9K3Vk@irc.freenode.net",
11
- "type":"person",
12
- "name":"sh-9K3Vk",
13
- "image":{
14
- "height":250,
15
- "mediaType":"image/jpeg",
16
- "url":"http://example.org/image.jpg",
17
- "width":250
18
- },
19
- "url":"http://sockethub.org"
20
- },
21
- "object":{
22
- "type":"credentials",
23
- "nick":"sh-9K3Vk",
24
- "port":6667,
25
- "secure":false,
26
- "server":"irc.freenode.net"
27
- }
28
- },
29
- "output":"same"
30
- },
31
- {
32
- "name":"bad irc credentials: user/nick host/server",
33
- "valid":false,
34
- "type":"credentials",
35
- "input":{
36
- "context":"irc",
37
- "type":"credentials",
38
- "actor":{
39
- "id":"sh-9K3Vk@irc.freenode.net",
40
- "type":"person",
41
- "name":"sh-9K3Vk",
42
- "image":{
43
- "height":250,
44
- "mediaType":"image/jpeg",
45
- "url":"http://example.org/image.jpg",
46
- "width":250
47
- },
48
- "url":"http://sockethub.org"
49
- },
50
- "object":{
51
- "type":"credentials",
52
- "user":"sh-9K3Vk",
53
- "port":6667,
54
- "secure":false,
55
- "host":"irc.freenode.net"
56
- }
57
- },
58
- "error":
59
- "Error: /object: must NOT have additional properties"
60
- },
61
- ]
package/index.test.js DELETED
@@ -1,204 +0,0 @@
1
- const proxyquire = require('proxyquire');
2
- const chai = require('chai');
3
- const schemas = require('@sockethub/schemas').default;
4
- const expect = chai.expect;
5
-
6
- const IRCPlatform = require('./index');
7
-
8
- proxyquire.noPreserveCache();
9
- proxyquire.noCallThru();
10
-
11
- const actor = {
12
- type: 'person',
13
- id: 'testingham@irc.example.com',
14
- name:'testingham'
15
- };
16
-
17
- const newActor = {
18
- type: 'person',
19
- id: 'testler@irc.example.com',
20
- name:'testler'
21
- };
22
-
23
- const targetRoom = {
24
- type: 'room',
25
- id: 'irc.example.com/a-room',
26
- name: '#a-room'
27
- };
28
-
29
- const validCredentials = {
30
- context: 'irc',
31
- type: 'credentials',
32
- actor: actor,
33
- object: {
34
- type: 'credentials',
35
- nick: 'testingham',
36
- server: 'irc.example.com'
37
- }
38
- };
39
-
40
- let loadedSchema = false;
41
-
42
- describe('Initialize IRC Platform', () => {
43
- let platform;
44
- beforeEach(() => {
45
- platform = new IRCPlatform({
46
- debug: function () {},
47
- updateActor: function (obj) {}
48
- });
49
- platform.__connect = function (key, credentials, cb) {
50
- cb(null, {
51
- end: () => {},
52
- on: function () {},
53
- raw: () => {}
54
- });
55
- };
56
- if (!loadedSchema) {
57
- schemas.addPlatformSchema(platform.schema.credentials, `irc/credentials`);
58
- loadedSchema = true;
59
- }
60
- });
61
-
62
- it('lists required types enum', () => {
63
- expect(platform.schema.messages.properties.type.enum).to.eql([
64
- 'connect', 'update', 'join', 'leave', 'send', 'query', 'announce'
65
- ]);
66
- });
67
-
68
- it('returns a config object', () => {
69
- expect(platform.config).to.eql({
70
- persist: true,
71
- requireCredentials: ['connect', 'update'],
72
- initialized: false
73
- });
74
- });
75
-
76
- it('schema format validation', () => {
77
- expect(schemas.validatePlatformSchema(platform.schema)).to.equal("");
78
- });
79
-
80
- describe('credential schema', () => {
81
- it('valid credentials', () => {
82
- expect(schemas.validateCredentials(validCredentials)).to.equal("");
83
- });
84
-
85
- it('invalid credentials type', () => {
86
- expect(schemas.validateCredentials({
87
- context: 'irc',
88
- type: 'credentials',
89
- object: {
90
- host: 'example.com',
91
- port: '6667'
92
- }})).to.equal("/object: must have required property 'type'");
93
- });
94
-
95
- it('invalid credentials port', () => {
96
- expect(schemas.validateCredentials({
97
- context: 'irc',
98
- type: 'credentials',
99
- object: {
100
- type: 'credentials',
101
- host: 'example.com',
102
- port: '6667'
103
- }})).to.equal("/object/port: must be number");
104
- });
105
-
106
- it('invalid credentials additional prop', () => {
107
- expect(schemas.validateCredentials({
108
- context: 'irc',
109
- type: 'credentials',
110
- object: {
111
- type: 'credentials',
112
- host: 'example.com',
113
- port: 6667
114
- }})).to.equal("/object: must NOT have additional properties");
115
- });
116
- });
117
-
118
- describe('platform type methods', () => {
119
- beforeEach((done) => {
120
- platform.connect({
121
- context: 'irc',
122
- type: 'connect',
123
- actor: actor
124
- }, { object: { server: 'a server address' } }, done);
125
- });
126
-
127
- describe('after join', () => {
128
- beforeEach((done) => {
129
- platform.join({
130
- context: 'irc',
131
- type: 'join',
132
- actor: actor,
133
- target: targetRoom
134
- }, done);
135
- platform.__completeJob();
136
- });
137
-
138
- it('has join channel registered', () => {
139
- expect(platform.__channels.has('#a-room')).to.equal(true);
140
- });
141
-
142
- it('leave()', (done) => {
143
- platform.leave({
144
- context: 'irc',
145
- type: 'leave',
146
- actor: actor,
147
- target: targetRoom
148
- }, done);
149
- platform.__completeJob();
150
- });
151
-
152
- it('send()', (done) => {
153
- platform.send({
154
- context: 'irc',
155
- type: 'send',
156
- actor: actor,
157
- object: { content: 'har dee dar' },
158
- target: targetRoom
159
- }, done);
160
- platform.__completeJob();
161
- });
162
-
163
- it('update() topic', (done) => {
164
- platform.update({
165
- context: 'irc',
166
- type: 'update',
167
- actor: actor,
168
- object: { type: 'topic', content: 'important details' },
169
- target: targetRoom
170
- }, validCredentials, done);
171
- platform.__completeJob();
172
- });
173
-
174
- it('update() nick change', (done) => {
175
- platform.update({
176
- context: 'irc',
177
- type: 'update',
178
- actor: actor,
179
- object: { type: 'address' },
180
- target: newActor
181
- }, validCredentials, done);
182
- platform.__completeJob();
183
- });
184
-
185
- it('query()', (done) => {
186
- platform.query({
187
- context: 'irc',
188
- type: 'query',
189
- actor: actor,
190
- target: targetRoom,
191
- object: { type: 'attendance' },
192
- }, done);
193
- platform.__completeJob();
194
- });
195
-
196
- it('cleanup()', (done) => {
197
- platform.cleanup(() => {
198
- expect(platform.initialized).to.eql(false);
199
- done();
200
- });
201
- });
202
- });
203
- });
204
- });