import { assert, describe, expect, it } from 'vitest' import Wechat from '../lib/wechat' import { Article } from '../models/article' import { Media } from '../models/media' describe('Wechat Article API', function () { it('expect work with and barckground-image', async () => { const wechat = new Wechat(process.env.APP_ID || '', process.env.APP_SECRET || '') await Article.init({ wechat }) await Media.init({ wechat, modelName: 'media' }) const content = ` ` const media = await Media.create({ src: 'https://shanyue.tech/wechat.jpeg', type: 'image' }) const data = await Article.create({ thumbMediaId: media.media_id, title: 'Hello, world', author: 'shanyue', showCoverPic: 0, content }) expect(data.media_id).length.to.gt(10) }) it('expect automatic inspection of the content type', async () => { const wechat = new Wechat(process.env.APP_ID || '', process.env.APP_SECRET || '') await Article.init({ wechat }) await Media.init({ wechat, modelName: 'media' }) const content = ` ` const media = await Media.create({ src: 'https://shanyue.tech/wechat.jpeg', type: 'image' }) const data = await Article.create({ thumbMediaId: media.media_id, title: 'expect automatic inspection of the content type', author: 'shanyue', showCoverPic: 0, content }) expect(data.media_id).length.to.gt(10) }) it('expect work with unsported image type (svg、webp)', async () => { const wechat = new Wechat(process.env.APP_ID || '', process.env.APP_SECRET || '') await Article.init({ wechat }) await Media.init({ wechat, modelName: 'media' }) const content = ` ` const media = await Media.create({ src: 'https://shanyue.tech/wechat.jpeg', type: 'image' }) const data = await Article.create({ thumbMediaId: media.media_id, title: 'Hello, world', author: 'shanyue', showCoverPic: 0, content }) expect(data.media_id).length.to.gt(10) }) })