ext-storage-qiniu.test.js 1.5 KB
Newer Older
A
Anne_LXM 已提交
1
describe('pages/storage/ext-storage-qiniu.vue', () => {
A
Anne_LXM 已提交
2
	let page,platform;
A
Anne_LXM 已提交
3 4 5 6 7
	beforeAll(async () => {
		// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
		page = await program.navigateTo('/pages/storage/ext-storage-qiniu')
		await page.waitFor('view')
		await page.setData({'isTest':true})
A
Anne_LXM 已提交
8
		platform = process.env.UNI_PLATFORM
A
Anne_LXM 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
	})
	it('qiniu-storage-上传文件', async () => {
		expect.assertions(2);
		const res = await page.callMethod('uploadFile', {
			filePath: '../../static/logo.png',
			cloudPath: Date.now() + 'test-qiniu.png',
			isPrivate: false
		})
		console.log('res: ---1', res);
		expectText(res.fileID,'qiniu://')
		expectText(res.fileURL,'https://')
	})
	it('qiniu-私有文件-上传', async () => {
		expect.assertions(2);
		const res = await page.callMethod('uploadFile', {
			filePath: '../../static/play.png',
			// cloudPath: Date.now() + 'test-qiniu.png',
			isPrivate: true
		})
		console.log('res: ----2', res);
		expectText(res.fileID,'qiniu://')
		expectText(res.fileURL,'https://')
	})
	it('获取私有文件临时下载链接', async () => {
A
Anne_LXM 已提交
33
		if(platform === "mp-weixin" || process.env.UNI_PLATFORM.startsWith("app")){return;}
A
Anne_LXM 已提交
34 35 36 37 38 39 40 41 42 43 44
		expect.assertions(3);
		expectText(await page.data('privateFileID'),'qiniu://jest')
		const res = await page.callMethod('getTempFileURL')
		console.log('res: ----3', res);
		expectText(res,'&token')
		expectText(res,'https://')
	})
})
function expectText(value,expectValue){
	expect(value).toEqual(expect.stringContaining(expectValue));
}