2018-11-13 11:04:03 -02:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
|
|
|
import { Formatter } from "export/formatter";
|
2019-10-04 01:20:41 +01:00
|
|
|
import { UnderlineType } from "file/paragraph/run/underline";
|
|
|
|
import { ShadingType } from "file/table";
|
|
|
|
import { EMPTY_OBJECT } from "file/xml-components";
|
2018-11-13 11:04:03 -02:00
|
|
|
|
|
|
|
import { CharacterStyle } from "./character-style";
|
|
|
|
|
|
|
|
describe("CharacterStyle", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should set the style type to character and use the given style id", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({ id: "myStyleId" });
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should set the name of the style, if given", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
name: "Style Name",
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
2019-04-09 05:27:18 -04:00
|
|
|
{ "w:name": { _attr: { "w:val": "Style Name" } } },
|
2018-11-13 11:04:03 -02:00
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2019-10-10 21:03:38 +01:00
|
|
|
|
|
|
|
it("should add smallCaps", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
smallCaps: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:smallCaps": { _attr: { "w:val": true } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add allCaps", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
allCaps: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:caps": { _attr: { "w:val": true } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add strike", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
strike: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:strike": { _attr: { "w:val": true } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add double strike", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
doubleStrike: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:dstrike": { _attr: { "w:val": true } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add sub script", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
subScript: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [
|
|
|
|
{
|
|
|
|
"w:vertAlign": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": "subscript",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add font", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
font: "test font",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [
|
|
|
|
{
|
|
|
|
"w:rFonts": {
|
|
|
|
_attr: {
|
|
|
|
"w:ascii": "test font",
|
|
|
|
"w:cs": "test font",
|
|
|
|
"w:eastAsia": "test font",
|
|
|
|
"w:hAnsi": "test font",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add character spacing", () => {
|
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
characterSpacing: 100,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:spacing": { _attr: { "w:val": 100 } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 99,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("formatting methods: style attributes", () => {
|
|
|
|
it("#basedOn", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({ id: "myStyleId", basedOn: "otherId" });
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
{ "w:basedOn": { _attr: { "w:val": "otherId" } } },
|
2018-11-13 11:04:03 -02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("formatting methods: run properties", () => {
|
|
|
|
it("#size", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
size: 24,
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 24 } } }],
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#underline", () => {
|
|
|
|
it("should set underline to 'single' if no arguments are given", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
underline: {},
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }],
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should set the style if given", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
underline: {
|
|
|
|
type: UnderlineType.DOUBLE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }],
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should set the style and color if given", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
underline: {
|
|
|
|
type: UnderlineType.DOUBLE,
|
|
|
|
color: "005599",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }],
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#superScript", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
superScript: true,
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:vertAlign": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": "superscript",
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#color", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
color: "123456",
|
|
|
|
},
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }],
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#bold", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
bold: true,
|
|
|
|
},
|
|
|
|
});
|
2019-02-26 17:28:13 +01:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:b": { _attr: { "w:val": true } } }],
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#italics", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
italics: true,
|
|
|
|
},
|
|
|
|
});
|
2019-02-26 17:28:13 +01:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:rPr": [{ "w:i": { _attr: { "w:val": true } } }],
|
2019-02-26 17:28:13 +01:00
|
|
|
},
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#link", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({ id: "myStyleId", link: "MyLink" });
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
|
|
|
{
|
2019-04-10 13:47:38 -04:00
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
{ "w:link": { _attr: { "w:val": "MyLink" } } },
|
2018-11-13 11:04:03 -02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#semiHidden", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({ id: "myStyleId", semiHidden: true });
|
2018-11-13 11:04:03 -02:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-13 11:04:03 -02:00
|
|
|
},
|
2019-04-10 13:47:38 -04:00
|
|
|
{ "w:unhideWhenUsed": EMPTY_OBJECT },
|
|
|
|
{ "w:semiHidden": EMPTY_OBJECT },
|
2018-11-13 11:04:03 -02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2019-08-05 13:42:45 +03:00
|
|
|
|
|
|
|
it("#highlight", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
highlight: "005599",
|
|
|
|
},
|
|
|
|
});
|
2019-08-05 13:42:45 +03:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:highlight": { _attr: { "w:val": "005599" } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2019-08-05 13:42:45 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("#shadow", () => {
|
2019-10-04 01:20:41 +01:00
|
|
|
const style = new CharacterStyle({
|
|
|
|
id: "myStyleId",
|
|
|
|
run: {
|
|
|
|
shadow: {
|
|
|
|
type: ShadingType.PERCENT_10,
|
|
|
|
fill: "00FFFF",
|
|
|
|
color: "FF0000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2019-08-05 13:42:45 +03:00
|
|
|
const tree = new Formatter().format(style);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:style": [
|
|
|
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
|
|
|
{
|
|
|
|
"w:rPr": [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:uiPriority": {
|
|
|
|
_attr: {
|
2019-10-04 01:20:41 +01:00
|
|
|
"w:val": 99,
|
2019-08-05 13:42:45 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2018-11-13 11:04:03 -02:00
|
|
|
});
|
|
|
|
});
|