update CheckBox and tests to handle optional alias field
This commit is contained in:
@ -4,7 +4,7 @@ import { CheckBox } from ".";
|
|||||||
|
|
||||||
describe("CheckBox", () => {
|
describe("CheckBox", () => {
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should create a CheckBoxUtil with proper root and default values", () => {
|
it("should create a CheckBox with proper root and default values (no alias, no custom state)", () => {
|
||||||
const checkBox = new CheckBox();
|
const checkBox = new CheckBox();
|
||||||
|
|
||||||
const tree = new Formatter().format(checkBox);
|
const tree = new Formatter().format(checkBox);
|
||||||
@ -13,13 +13,6 @@ describe("CheckBox", () => {
|
|||||||
"w:sdt": [
|
"w:sdt": [
|
||||||
{
|
{
|
||||||
"w:sdtPr": [
|
"w:sdtPr": [
|
||||||
{
|
|
||||||
"w:alias": {
|
|
||||||
_attr: {
|
|
||||||
"w:val": "Checkbox",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"w14:checkbox": [
|
"w14:checkbox": [
|
||||||
{
|
{
|
||||||
@ -73,7 +66,7 @@ describe("CheckBox", () => {
|
|||||||
["2713", "Segoe UI Symbol", "2713", "Segoe UI Symbol"],
|
["2713", "Segoe UI Symbol", "2713", "Segoe UI Symbol"],
|
||||||
[undefined, undefined, "2612", "MS Gothic"],
|
[undefined, undefined, "2612", "MS Gothic"],
|
||||||
])("should create a CheckBoxUtil with proper root and custom values", (inputChar, inputFont, actualChar, actualFont) => {
|
])("should create a CheckBoxUtil with proper root and custom values", (inputChar, inputFont, actualChar, actualFont) => {
|
||||||
const checkBox = new CheckBox({
|
const checkBox = new CheckBox("Custom Checkbox", {
|
||||||
checked: true,
|
checked: true,
|
||||||
checkedState: {
|
checkedState: {
|
||||||
value: inputChar,
|
value: inputChar,
|
||||||
@ -94,7 +87,7 @@ describe("CheckBox", () => {
|
|||||||
{
|
{
|
||||||
"w:alias": {
|
"w:alias": {
|
||||||
_attr: {
|
_attr: {
|
||||||
"w:val": "Checkbox",
|
"w:val": "Custom Checkbox",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -147,8 +140,8 @@ describe("CheckBox", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a CheckBoxUtil with proper root and custom values", () => {
|
it("should create a CheckBoxUtil with proper root, custom state, and no alias", () => {
|
||||||
const checkBox = new CheckBox({
|
const checkBox = new CheckBox(undefined, {
|
||||||
checked: false,
|
checked: false,
|
||||||
checkedState: {
|
checkedState: {
|
||||||
value: "2713",
|
value: "2713",
|
||||||
@ -166,13 +159,6 @@ describe("CheckBox", () => {
|
|||||||
"w:sdt": [
|
"w:sdt": [
|
||||||
{
|
{
|
||||||
"w:sdtPr": [
|
"w:sdtPr": [
|
||||||
{
|
|
||||||
"w:alias": {
|
|
||||||
_attr: {
|
|
||||||
"w:val": "Checkbox",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"w14:checkbox": [
|
"w14:checkbox": [
|
||||||
{
|
{
|
||||||
|
@ -9,10 +9,10 @@ export class CheckBox extends XmlComponent {
|
|||||||
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
|
private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610";
|
||||||
private readonly DEFAULT_CHECKED_SYMBOL: string = "2612";
|
private readonly DEFAULT_CHECKED_SYMBOL: string = "2612";
|
||||||
private readonly DEFAULT_FONT: string = "MS Gothic";
|
private readonly DEFAULT_FONT: string = "MS Gothic";
|
||||||
public constructor(options?: ICheckboxSymbolOptions) {
|
public constructor(alias?: string, options?: ICheckboxSymbolOptions) {
|
||||||
super("w:sdt");
|
super("w:sdt");
|
||||||
|
|
||||||
const properties = new StructuredDocumentTagProperties("Checkbox");
|
const properties = new StructuredDocumentTagProperties(alias);
|
||||||
properties.addChildElement(new CheckBoxUtil(options));
|
properties.addChildElement(new CheckBoxUtil(options));
|
||||||
this.root.push(properties);
|
this.root.push(properties);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user