Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit a4bb84e

Browse files
tcdavisexpbot
authored andcommitted
Upgrade tests for snack-sdk
fbshipit-source-id: 3218778
1 parent 8c4c953 commit a4bb84e

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/__tests__/SnackSession-test.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ describe('sendCodeAsync', () => {
169169
stopMockingDate();
170170
await timeout(50);
171171

172-
expect(session.pubnub.publish.mock.calls[0][0]).toMatchObject({
172+
let result = session.pubnub.publish.mock.calls[0][0];
173+
delete result.message.metadata;
174+
expect(result).toMatchObject({
173175
channel: SESSION_ID,
174176
message: {
175177
type: 'CODE',
176-
diff: { 'app.js': NEW_CODE_DIFF },
178+
diff: { 'App.js': NEW_CODE_DIFF },
177179
s3url: {},
178180
},
179181
});
@@ -194,13 +196,15 @@ describe('sendCodeAsync', () => {
194196
stopMockingDate();
195197
await timeout(50);
196198
fetchMock.restore();
197-
expect(session.pubnub.publish.mock.calls[0][0]).toMatchObject({
199+
let result = session.pubnub.publish.mock.calls[0][0];
200+
delete result.message.metadata;
201+
expect(result).toMatchObject({
198202
channel: SESSION_ID,
199203
message: {
200204
type: 'CODE',
201-
diff: { 'app.js': '' },
205+
diff: { 'App.js': '' },
202206
s3url: {
203-
'app.js':
207+
'App.js':
204208
'https://snack-code-uploads-staging.s3-us-west-1.amazonaws.com/~code/225764978e2bee1bcf2b1372048f7cd9',
205209
},
206210
},
@@ -226,16 +230,18 @@ describe('sendCodeAsync', () => {
226230
stopMockingDate();
227231
await timeout(50);
228232
fetchMock.restore();
229-
expect(session.pubnub.publish.mock.calls[1][0]).toMatchObject({
233+
let result = session.pubnub.publish.mock.calls[1][0];
234+
delete result.message.metadata;
235+
expect(result).toMatchObject({
230236
channel: SESSION_ID,
231237
message: {
232238
type: 'CODE',
233239
diff: {
234-
'app.js':
240+
'App.js':
235241
"Index: code\n===================================================================\n--- code \n+++ code \n@@ -11,0 +11,1 @@\n+ And we're modifying this huge block of text. \n",
236242
},
237243
s3url: {
238-
'app.js':
244+
'App.js':
239245
'https://snack-code-uploads-staging.s3-us-west-1.amazonaws.com/~code/225764978e2bee1bcf2b1372048f7cd9',
240246
},
241247
},
@@ -266,13 +272,15 @@ describe('sendCodeAsync', () => {
266272
stopMockingDate();
267273
await timeout(50);
268274
fetchMock.restore();
269-
expect(session.pubnub.publish.mock.calls[1][0]).toMatchObject({
275+
let result = session.pubnub.publish.mock.calls[1][0];
276+
delete result.message.metadata;
277+
expect(result).toMatchObject({
270278
channel: SESSION_ID,
271279
message: {
272280
type: 'CODE',
273-
diff: { 'app.js': '' },
281+
diff: { 'App.js': '' },
274282
s3url: {
275-
'app.js':
283+
'App.js':
276284
'https://snack-code-uploads-staging.s3-us-west-1.amazonaws.com/~code/dee64f147ae2e4f0a76c4837c0991f7d',
277285
},
278286
},
@@ -288,12 +296,14 @@ describe('sendCodeAsync', () => {
288296
setMockDate(1000);
289297
stopMockingDate();
290298
await timeout(50);
291-
expect(session.pubnub.publish.mock.calls[0][0]).toMatchObject({
299+
let result = session.pubnub.publish.mock.calls[0][0];
300+
delete result.message.metadata;
301+
expect(result).toMatchObject({
292302
channel: SESSION_ID,
293303
message: {
294304
type: 'CODE',
295305
s3url: {},
296-
diff: { 'app.js': NEW_CODE_3_DIFF },
306+
diff: { 'App.js': NEW_CODE_3_DIFF },
297307
},
298308
});
299309
});
@@ -419,7 +429,7 @@ describe('saveAsync', () => {
419429
method: 'POST',
420430
body: `{"manifest":{"sdkVersion":"25.0.0","dependencies":{"lodash":"1.0.0"}},"code":${JSON.stringify(
421431
INITIAL_CODE
422-
)},"dependencies":{"lodash":{"version":"1.0.0"}}}`,
432+
)},"dependencies":{"lodash":{"version":"1.0.0"}},"isDraft":false}`,
423433
headers: {
424434
'Content-Type': 'application/json',
425435
},
@@ -447,7 +457,7 @@ describe('saveAsync', () => {
447457
method: 'POST',
448458
body: `{"manifest":{"sdkVersion":"${defaultSDKVersion}","name":"testname1","description":"testdescription1","dependencies":{}},"code":${JSON.stringify(
449459
INITIAL_CODE
450-
)},"dependencies":{}}`,
460+
)},"dependencies":{},"isDraft":false}`,
451461
headers: {
452462
'Content-Type': 'application/json',
453463
},

0 commit comments

Comments
 (0)