50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
var _utils = require("../utils");
|
|
|
|
var _ = require(".");
|
|
|
|
describe('image func test', function () {
|
|
var domain = 'http://otxza7yo2.bkt.clouddn.com';
|
|
var key = 'test.png';
|
|
test('imageView2', function () {
|
|
var m = {
|
|
fop: 'imageView2',
|
|
mode: 2,
|
|
h: 450,
|
|
q: 100
|
|
};
|
|
var url = (0, _.imageView2)(m, key, domain);
|
|
expect(url).toBe('http://otxza7yo2.bkt.clouddn.com/' + key + '?' + 'imageView2/' + encodeURIComponent(m.mode) + '/h' + '/' + encodeURIComponent(m.h) + '/q' + '/' + encodeURIComponent(m.q));
|
|
});
|
|
test('imageMogr2', function () {
|
|
var m = {
|
|
thumbnail: 1,
|
|
strip: true,
|
|
gravity: 1,
|
|
crop: 1,
|
|
quality: 1,
|
|
rotate: 1,
|
|
format: 1,
|
|
blur: 1
|
|
};
|
|
var url = (0, _.imageMogr2)(m, key, domain);
|
|
expect(url).toBe('http://otxza7yo2.bkt.clouddn.com/' + key + '?imageMogr2/' + 'thumbnail/1/strip/gravity/1/quality/1/crop/1/rotate/1/format/1/blur/1');
|
|
});
|
|
test('watermark', function () {
|
|
var m = {
|
|
fop: 'watermark',
|
|
mode: 1,
|
|
image: 'http://www.b1.qiniudn.com/images/logo-2.png',
|
|
dissolve: 100,
|
|
dx: 100,
|
|
dy: 100
|
|
};
|
|
var url = (0, _.watermark)(m, key, domain);
|
|
expect(url).toBe('http://otxza7yo2.bkt.clouddn.com/' + key + '?' + 'watermark/' + m.mode + '/image/' + (0, _utils.urlSafeBase64Encode)(m.image) + '/dissolve/100/dx/100/dy/100');
|
|
m.mode = 3;
|
|
expect(function () {
|
|
(0, _.watermark)(m, key, domain);
|
|
}).toThrow('mode is wrong');
|
|
});
|
|
}); |