mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2026-01-06 05:29:34 -06:00
Use async/await for tests.
This commit is contained in:
@@ -5,59 +5,35 @@ import responses from './mocks/plexResponses';
|
||||
import { PlexSection, User, PlexLibrary } from '../../../../server/models';
|
||||
import truncate from '../../../truncate';
|
||||
|
||||
before(() => truncate('PlexSection'));
|
||||
// before(() => truncate('PlexSection'));
|
||||
describe('ImportData', () => {
|
||||
// beforeEach(() => {
|
||||
// User.create({
|
||||
// firstName: 'Mike',
|
||||
// lastName: 'Rode',
|
||||
// email: 'michaelrode44@gmail.com',
|
||||
// });
|
||||
// });
|
||||
before(() => {
|
||||
User.upsert(
|
||||
{
|
||||
firstName: 'Mike',
|
||||
lastName: 'Rode',
|
||||
email: 'michaelrode44@gmail.com',
|
||||
},
|
||||
{ where: { email: 'micahelrode44@gmail.com' } },
|
||||
);
|
||||
});
|
||||
describe('GET /plex/import/sections', async () => {
|
||||
it('should find and store sections in the database first', (done) => {
|
||||
it('should find and store sections in the database first', async () => {
|
||||
nock('https://plex.mjrflix.com')
|
||||
.get('/library/sections?X-Plex-Token=testPlexApiToken')
|
||||
.reply(200, responses.sectionsRaw, {
|
||||
'Content-Type': 'text/json',
|
||||
});
|
||||
|
||||
chai
|
||||
.request(app)
|
||||
.get('/plex/import/sections')
|
||||
.then((err, res) => {
|
||||
PlexSection.findAll().then((sections) => {
|
||||
sections.should.be.a('array');
|
||||
sections.should.have.length(2);
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should find and store sections in the database second', (done) => {
|
||||
nock('https://plex.mjrflix.com')
|
||||
.get('/library/sections?X-Plex-Token=testPlexApiToken')
|
||||
.reply(200, responses.sectionsRaw, {
|
||||
'Content-Type': 'text/json',
|
||||
});
|
||||
|
||||
chai
|
||||
.request(app)
|
||||
.get('/plex/import/sections')
|
||||
.then((err, res) => {
|
||||
PlexSection.findAll().then((sections) => {
|
||||
sections.should.be.a('array');
|
||||
sections.should.have.length(2);
|
||||
});
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
const response = await chai.request(app).get('/plex/import/sections');
|
||||
response.should.have.status(200);
|
||||
const sections = await PlexSection.findAll();
|
||||
sections.should.be.length(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get /plex/import/libraries', async () => {
|
||||
it('should sections', (done) => {
|
||||
it('should sections', async () => {
|
||||
nock('https://plex.mjrflix.com')
|
||||
.get(url => url.includes('/library/sections/3'))
|
||||
.reply(200, responses.getLibraryDataBySectionRaw, {
|
||||
@@ -73,16 +49,9 @@ describe('ImportData', () => {
|
||||
.reply(200, responses.sectionsRaw, {
|
||||
'Content-Type': 'text/json',
|
||||
});
|
||||
chai
|
||||
.request(app)
|
||||
.get('/plex/import/libraries')
|
||||
.then((err, res) => {
|
||||
PlexLibrary.findAll().then((media) => {
|
||||
media.should.be.a('array');
|
||||
// console.log('mikes-media', media);
|
||||
done();
|
||||
});
|
||||
});
|
||||
const response = await chai.request(app).get('/plex/import/libraries');
|
||||
const media = await PlexLibrary.findAll();
|
||||
media.should.be.length(56);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user