diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 0000000..1320b9a --- /dev/null +++ b/babel.config.json @@ -0,0 +1,3 @@ +{ + "presets": ["@babel/preset-env"] +} diff --git a/package.json b/package.json index 9b3bca0..17b9da7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,8 @@ { "type": "module", + "scripts": { + "test": "jest --verbose --coverage tests/test.test.js" + }, "dependencies": { "axios": "^1.6.8", "dayjs": "^1.11.10", @@ -9,5 +12,10 @@ "nodemailer": "^6.9.13", "sequelize": "^6.37.1", "youtube-transcript": "^1.1.0" + }, + "devDependencies": { + "@babel/core": "^7.24.4", + "@babel/preset-env": "^7.24.4", + "jest": "^29.7.0" } } diff --git a/tests/add.js b/tests/add.js new file mode 100644 index 0000000..1cdda07 --- /dev/null +++ b/tests/add.js @@ -0,0 +1,3 @@ +const add = (a, b) => a + b + +export default add diff --git a/tests/add.test.js b/tests/add.test.js new file mode 100644 index 0000000..405221e --- /dev/null +++ b/tests/add.test.js @@ -0,0 +1,5 @@ +import add from './add' + +test('adds 1 + 2 to equal 3', () => { + expect(add(1, 2)).toBe(3) +}) diff --git a/tests/sqluelize.join.test.js b/tests/sqluelize.join.sample.js similarity index 87% rename from tests/sqluelize.join.test.js rename to tests/sqluelize.join.sample.js index a027f42..bca7cfe 100644 --- a/tests/sqluelize.join.test.js +++ b/tests/sqluelize.join.sample.js @@ -1,4 +1,4 @@ -import { Sequelize, Model, DataTypes } from 'sequelize' +import { Sequelize, DataTypes } from 'sequelize' const sequelize = new Sequelize( process.env.YOUDB_NAME || 'youtubedb', process.env.YOUDB_USER || 'devuser', @@ -25,5 +25,6 @@ const Youtube = sequelize.define('Youtube', { Channel.hasMany(Youtube) Youtube.belongsTo(Channel) - -await sequelize.sync() +;(async () => { + await sequelize.sync() +})() diff --git a/tests/test.test.js b/tests/test.test.js index 2e72f26..64f0f20 100644 --- a/tests/test.test.js +++ b/tests/test.test.js @@ -1,4 +1,4 @@ -const youtube = require('./youtub') +import youtube from '../youtube.js' describe('test', () => { it('test', () => { @@ -22,7 +22,7 @@ describe('get channel info by id', () => { const channelInfo = await getChannelInfo(channelId) expect(channelInfo.title).toBe('프로그래머 김플 스튜디오') expect(channelInfo.thumbnail).toBe( - 'https://yt3.ggpht.com/SrCeLz3yIf5kVvXOZz8VzenrpyYOIolN9xAdyQI9X6G-_JhiGKqR0nRQ_OcaK5c5cYkyeA0OFQ=s800-c-k-c0x00ffffff-no-rj' + 'https://yt3.ggpht.com/SrCeLz3yIf5kVvXOZz8VzenrpyYOIolN9xAdyQI9X6G-_JhiGKqR0nRQ_OcaK5c5cYkyeA0OFQ=s240-c-k-c0x00ffffff-no-rj' ) }) }) @@ -31,7 +31,7 @@ async function getChannelInfo(channelId) { try { const response = await youtube.channels.list({ id: channelId, - part: 'snippet,contentDetails', // 필요한 정보를 지정합니다. + part: 'snippet,contentDetails', }) const items = response.data.items[0] const data = { diff --git a/tests/transcript.test.js b/tests/transcript.test.js index e3b6e34..eca5de2 100644 --- a/tests/transcript.test.js +++ b/tests/transcript.test.js @@ -1,4 +1,4 @@ -const fetchTranscript = require('./transcript.js') +import fetchTranscript from '../web/transcript.js' test('', async() => { const videoId = '4Z8qAzlnue8' diff --git a/tests/youtub.js b/tests/youtub.js index c7d5b49..2b7c80e 100644 --- a/tests/youtub.js +++ b/tests/youtub.js @@ -5,4 +5,4 @@ const youtube = google.youtube({ auth: process.env.YOUTUBE_API_KEY, }) -module.exports = youtube +// module.exports = youtube