Skip to content

Commit

Permalink
run prettier across the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanHirsch committed Jan 23, 2022
1 parent d2e2123 commit 00dbf0c
Show file tree
Hide file tree
Showing 137 changed files with 3,373 additions and 3,327 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
18 changes: 9 additions & 9 deletions __tests__/integration/customSequencer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const TestSequencer = require('@jest/test-sequencer').default;
const TestSequencer = require('@jest/test-sequencer').default
const path = require('path')

class CustomSequencer extends TestSequencer {
Expand All @@ -22,22 +22,22 @@ class CustomSequencer extends TestSequencer {
path.join(__dirname, testsPath, 'userNowPlayingItem.itest.ts'),
path.join(__dirname, testsPath, 'userHistoryItem.itest.ts'),
path.join(__dirname, testsPath, 'userQueueItem.itest.ts')
];
]

return tests.sort((testA, testB) => {
const indexA = orderPath.indexOf(testA.path);
const indexB = orderPath.indexOf(testB.path);
const indexA = orderPath.indexOf(testA.path)
const indexB = orderPath.indexOf(testB.path)

if (indexA === indexB) return 0; // do not swap when tests both not specify in order.
if (indexA === indexB) return 0 // do not swap when tests both not specify in order.

if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA < indexB ? -1 : 1;
if (indexA === -1) return 1
if (indexB === -1) return -1
return indexA < indexB ? -1 : 1
})
}
}

module.exports = CustomSequencer;
module.exports = CustomSequencer

// Thanks to WeiAnAn for this example:
// https://github.com/facebook/jest/issues/6194#issuecomment-521521514
47 changes: 25 additions & 22 deletions __tests__/integration/routes/v1/accountClaimToken.itest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const { expect: chaiExpect } = chai
chai.use(chaiHttp)

describe('AccountClaimToken endpoints', () => {

describe('get by id', () => {
test('when an unclaimed id is provided', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.get(`${v1Path}/claim-account/6fc489b1-46b1-4f89-8734-e2f3725da3d8`)
.end((err, res) => {
chaiExpect(res).to.have.status(200);
chaiExpect(res).to.have.status(200)

chaiExpect(res.body.id).to.equal('6fc489b1-46b1-4f89-8734-e2f3725da3d8')
chaiExpect(res.body.claimed).to.equal(false)
Expand All @@ -23,10 +23,11 @@ describe('AccountClaimToken endpoints', () => {
})

test('when a claimed id is provided', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.get(`${v1Path}/claim-account/faae1a5f-260a-40d7-89d5-fb1c48d75735`)
.end((err, res) => {
chaiExpect(res).to.have.status(400);
chaiExpect(res).to.have.status(400)

chaiExpect(res.body.message).to.equal('This token has already been claimed.')
chaiExpect(Object.keys(res.body).length).to.equal(1)
Expand All @@ -35,39 +36,40 @@ describe('AccountClaimToken endpoints', () => {
})
})
})

describe('redeem by id', () => {

describe('redeem by id', () => {
const sendBody1 = {
"id": "6fc489b1-46b1-4f89-8734-e2f3725da3d8",
"email": "[email protected]"
id: '6fc489b1-46b1-4f89-8734-e2f3725da3d8',
email: '[email protected]'
}
const sendBody2 = {
"id": "faae1a5f-260a-40d7-89d5-fb1c48d75735",
"email": "[email protected]"
id: 'faae1a5f-260a-40d7-89d5-fb1c48d75735',
email: '[email protected]'
}
const sendBody3 = {
"id": "6fc489bz-46b1-4f89-8734-e2f3725da3d8",
"email": "[email protected]"
id: '6fc489bz-46b1-4f89-8734-e2f3725da3d8',
email: '[email protected]'
}

test('valid redeem', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/claim-account`)
.send(sendBody1)
.end((err, res) => {
chaiExpect(res).to.have.status(200);
chaiExpect(res).to.have.status(200)

done()
})
})

test('claimed redeem', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/claim-account`)
.send(sendBody2)
.end((err, res) => {
chaiExpect(res).to.have.status(400);
chaiExpect(res).to.have.status(400)

chaiExpect(res.body.message).to.equal('This offer has already been claimed.')
chaiExpect(Object.keys(res.body).length).to.equal(1)
Expand All @@ -77,19 +79,20 @@ describe('AccountClaimToken endpoints', () => {
})

test('invalid redeem', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/claim-account`)
.send(sendBody3)
.end((err, res) => {
chaiExpect(res).to.have.status(500);
chaiExpect(res).to.have.status(500)

chaiExpect(res.body.message).to.equal('invalid input syntax for type uuid: \"6fc489bz-46b1-4f89-8734-e2f3725da3d8\"')
chaiExpect(res.body.message).to.equal(
'invalid input syntax for type uuid: "6fc489bz-46b1-4f89-8734-e2f3725da3d8"'
)
chaiExpect(Object.keys(res.body).length).to.equal(1)

done()
})
})

})

})
59 changes: 32 additions & 27 deletions __tests__/integration/routes/v1/addByRSSPodcastFeedUrl.itest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,44 @@ const { expect: chaiExpect } = chai
chai.use(chaiHttp)

describe('AddByRSSPodcastFeedUrl endpoints', () => {

describe('Add', () => {
const sendBody = {
"addByRSSPodcastFeedUrl" : "http://rss.art19.com/the-daily"
}
test('Unauthorized', async (done) => {
chai.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/add`)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(401);
addByRSSPodcastFeedUrl: 'http://rss.art19.com/the-daily'
}
test('Unauthorized', async (done) => {
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/add`)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(401)

done()
})
})
done()
})
})
test('Invalid Account', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/add`)
.set('Cookie', testUsers.premiumExpired.authCookie)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(401);
chaiExpect(res.body.message).to.equal("Premium Membership Required");
chaiExpect(res.body.code).to.equal(123);
chaiExpect(res).to.have.status(401)
chaiExpect(res.body.message).to.equal('Premium Membership Required')
chaiExpect(res.body.code).to.equal(123)
chaiExpect(Object.keys(res.body).length).to.equal(2)

done()
})
})
test('Premium Valid', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/add`)
.set('Cookie', testUsers.premium.authCookie)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(200);
chaiExpect(res).to.have.status(200)
chaiExpect(res.body[0]).to.equal('http://feed.thisamericanlife.org/talpodcast')
chaiExpect(res.body[1]).to.equal('https://feeds.npr.org/344098539/podcast.xml')
chaiExpect(res.body[2]).to.equal('https://feeds.npr.org/381444908/podcast.xml')
Expand All @@ -53,39 +55,42 @@ describe('AddByRSSPodcastFeedUrl endpoints', () => {
})
describe('Remove', () => {
const sendBody = {
"addByRSSPodcastFeedUrl": "https://feeds.npr.org/381444908/podcast.xml"
addByRSSPodcastFeedUrl: 'https://feeds.npr.org/381444908/podcast.xml'
}
test('Unauthorized', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/remove`)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(401);
chaiExpect(res).to.have.status(401)

done()
})
})
test('Invalid Account', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/remove`)
.set('Cookie', testUsers.premiumExpired.authCookie)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(401);
chaiExpect(res.body.message).to.equal("Premium Membership Required");
chaiExpect(res.body.code).to.equal(123);
chaiExpect(res).to.have.status(401)
chaiExpect(res.body.message).to.equal('Premium Membership Required')
chaiExpect(res.body.code).to.equal(123)
chaiExpect(Object.keys(res.body).length).to.equal(2)

done()
})
})
test('Premium Valid', async (done) => {
chai.request(global.app)
chai
.request(global.app)
.post(`${v1Path}/add-by-rss-podcast-feed-url/remove`)
.set('Cookie', testUsers.premium.authCookie)
.send(sendBody)
.end((err, res) => {
chaiExpect(res).to.have.status(200);
chaiExpect(res).to.have.status(200)
chaiExpect(res.body[0]).to.equal('http://feed.thisamericanlife.org/talpodcast')
chaiExpect(res.body[1]).to.equal('https://feeds.npr.org/344098539/podcast.xml')
chaiExpect(res.body[2]).to.equal('http://rss.art19.com/the-daily')
Expand Down
30 changes: 14 additions & 16 deletions __tests__/integration/routes/v1/appStorePurchase.itest.ts

Large diffs are not rendered by default.

Loading

0 comments on commit 00dbf0c

Please sign in to comment.