Skip to content

Commit

Permalink
jest import/export esm
Browse files Browse the repository at this point in the history
  • Loading branch information
kenu committed Apr 11, 2024
1 parent eb1da60 commit 9f176cc
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"type": "module",
"scripts": {
"test": "jest --verbose --coverage tests/test.test.js"
},
"dependencies": {
"axios": "^1.6.8",
"dayjs": "^1.11.10",
Expand All @@ -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"
}
}
3 changes: 3 additions & 0 deletions tests/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const add = (a, b) => a + b

export default add
5 changes: 5 additions & 0 deletions tests/add.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import add from './add'

test('adds 1 + 2 to equal 3', () => {
expect(add(1, 2)).toBe(3)
})
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -25,5 +25,6 @@ const Youtube = sequelize.define('Youtube', {

Channel.hasMany(Youtube)
Youtube.belongsTo(Channel)

await sequelize.sync()
;(async () => {
await sequelize.sync()
})()
6 changes: 3 additions & 3 deletions tests/test.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const youtube = require('./youtub')
import youtube from '../youtube.js'

describe('test', () => {
it('test', () => {
Expand All @@ -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'
)
})
})
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion tests/transcript.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetchTranscript = require('./transcript.js')
import fetchTranscript from '../web/transcript.js'

test('', async() => {
const videoId = '4Z8qAzlnue8'
Expand Down
2 changes: 1 addition & 1 deletion tests/youtub.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const youtube = google.youtube({
auth: process.env.YOUTUBE_API_KEY,
})

module.exports = youtube
// module.exports = youtube

0 comments on commit 9f176cc

Please sign in to comment.