| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import {Options} from '../../src/ts/util/Options';
- describe('Options', () => {
- test('Options toolbar', () => {
- const options = new Options({
- toolbar: ['br', 'fullscreen', {
- hotkey: "⌘-a",
- name: "preview",
- }]
- });
- expect(options.merge()).toMatchObject({
- toolbar: [{
- name: "br",
- }, {
- hotkey: "⌘-'",
- name: "fullscreen",
- tipPosition: "nw",
- }, {
- hotkey: "⌘-a",
- name: "preview",
- tipPosition: "nw",
- }],
- })
- });
- test('Options upload', () => {
- const options = new Options({
- upload: {
- accept: '.jpg'
- }
- });
- expect(options.merge()).toMatchObject({
- upload: {
- filename: expect.anything(),
- linkToImgUrl: "",
- max: 10 * 1024 * 1024,
- url: "",
- accept: '.jpg'
- },
- })
- })
- test('Options classes', () => {
- const options = new Options({
- classes: {
- preview: "content-reset",
- },
- });
- expect(options.merge()).toMatchObject({
- classes: {
- preview: "content-reset",
- },
- })
- });
- test('Options preview', () => {
- const options = new Options({
- preview: {
- url: 'https://hacpai.com/md',
- mode: 'both',
- },
- });
- expect(options.merge()).toMatchObject({
- preview: {
- url: 'https://hacpai.com/md',
- delay: 1000,
- mode: 'both',
- },
- })
- });
- test('Options preview hljs', () => {
- const options = new Options({
- preview: {
- mode: 'both',
- hljs: {
- style: 'github'
- }
- },
- });
- expect(options.merge().preview).toEqual({
- delay: 1000,
- mode: 'both',
- hljs: {
- style: 'github',
- enable: true,
- }
- })
- });
- test('Options hint', () => {
- const options = new Options({
- hint: {
- emojiTail: '前往设置',
- emoji: {
- "+1": "👍",
- },
- },
- });
- expect(options.merge()).toMatchObject({
- hint: {
- delay: 200,
- emojiTail: '前往设置',
- emoji: {
- "+1": "👍",
- },
- emojiPath: "https://cdn.jsdelivr.net/npm/vditor/src/assets/emoji",
- },
- })
- });
- test('Options resize', () => {
- const options = new Options({
- resize: {
- enable: true,
- },
- })
- expect(options.merge()).toMatchObject({
- resize: {
- enable: true,
- position: "bottom",
- },
- })
- });
- })
|