Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
Renames defaultValue to initialValue throughout. (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscox committed Jan 12, 2017
1 parent 2a3c263 commit bf4c7bf
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 61 deletions.
4 changes: 2 additions & 2 deletions src/core/__tests__/BooleanVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ chai.use(sinonChai);
describe("BooleanVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: boolean = true;
const initialValue: boolean = true;
let callbackSpy: sinon.SinonSpy;
let variable: BooleanVariable;

beforeEach(() => {
callbackSpy = sinon.spy();
variable = remixer.addBooleanVariable(key, defaultValue, callbackSpy);
variable = remixer.addBooleanVariable(key, initialValue, callbackSpy);
});

it("should create a new variable", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/__tests__/ColorVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chai.use(sinonChai);
describe("ColorVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: string = "#4285F4";
const initialValue: string = "#4285F4";
const limitedToValues: string[] = ["#4285F4", "#0F9D58", "#DB4437"];
let callbackSpy: sinon.SinonSpy;
let variable: ColorVariable;
Expand All @@ -22,7 +22,7 @@ describe("ColorVariable", () => {
callbackSpy = sinon.spy();
variable = remixer.addColorVariable(
key,
defaultValue,
initialValue,
limitedToValues,
callbackSpy,
);
Expand Down
4 changes: 2 additions & 2 deletions src/core/__tests__/NumberVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chai.use(sinonChai);
describe("NumberVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: number = 20;
const initialValue: number = 20;
const limitedToValues: number[] = [10, 20, 30, 40];
let callbackSpy: sinon.SinonSpy;
let variable: NumberVariable;
Expand All @@ -22,7 +22,7 @@ describe("NumberVariable", () => {
callbackSpy = sinon.spy();
variable = remixer.addNumberVariable(
key,
defaultValue,
initialValue,
limitedToValues,
callbackSpy,
);
Expand Down
4 changes: 2 additions & 2 deletions src/core/__tests__/RangeVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chai.use(sinonChai);
describe("RangeVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: number = 1;
const initialValue: number = 1;
const minValue: number = 0;
const maxValue: number = 1;
const increment: number = 0.1;
Expand All @@ -24,7 +24,7 @@ describe("RangeVariable", () => {
callbackSpy = sinon.spy();
variable = remixer.addRangeVariable(
key,
defaultValue,
initialValue,
minValue,
maxValue,
increment,
Expand Down
4 changes: 2 additions & 2 deletions src/core/__tests__/StringVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chai.use(sinonChai);
describe("StringVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: string = "B";
const initialValue: string = "B";
const limitedToValues: string[] = ["A", "B", "C", "D"];
let callbackSpy: sinon.SinonSpy;
let variable: StringVariable;
Expand All @@ -22,7 +22,7 @@ describe("StringVariable", () => {
callbackSpy = sinon.spy();
variable = remixer.addStringVariable(
key,
defaultValue,
initialValue,
limitedToValues,
callbackSpy,
);
Expand Down
11 changes: 5 additions & 6 deletions src/core/variables/BooleanVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IVariableCallback, IVariableParams, Variable } from "./Variable";
* @extends IVariableParams
*/
interface IBooleanVariableParams extends IVariableParams {
defaultValue: boolean;
initialValue: boolean;
selectedValue: boolean;
}

Expand All @@ -40,16 +40,16 @@ export class BooleanVariable extends Variable implements IBooleanVariableParams
* Creates an instance of a BooleanVariable.
* @constructor
* @param {string} key A unique key for the Variable.
* @param {boolean} defaultValue The default value.
* @param {boolean} initialValue The initial selected value.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {BooleanVariable}
*/
constructor(
key: string,
defaultValue: boolean,
initialValue: boolean,
callback?: IVariableCallback,
) {
super(key, DataType.BOOLEAN, defaultValue, callback);
super(key, DataType.BOOLEAN, initialValue, callback);
this.controlType = ControlType.SWITCH;
}

Expand All @@ -58,7 +58,7 @@ export class BooleanVariable extends Variable implements IBooleanVariableParams
* @return {BooleanVariable} Returns the cloned variable.
*/
clone() {
let cloned = new BooleanVariable(this.key, this.defaultValue, null);
let cloned = new BooleanVariable(this.key, this.initialValue, null);
cloned.title = this.title;
cloned._callbacks = this._callbacks.slice();
return cloned;
Expand All @@ -71,7 +71,6 @@ export class BooleanVariable extends Variable implements IBooleanVariableParams
*/
serialize(): ISerializableData {
let data = super.serialize();
data.defaultValue = this.defaultValue;
data.selectedValue = this.selectedValue;
return data;
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/variables/ColorVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IVariableCallback, IVariableListParams, Variable } from "./Variable";
* @extends IVariableListParams
*/
interface IColorVariableParams extends IVariableListParams {
defaultValue: string;
initialValue: string;
selectedValue: string;
limitedToValues?: string[];
}
Expand All @@ -43,18 +43,18 @@ export class ColorVariable extends Variable implements IColorVariableParams {
* Creates an instance of a ColorVariable.
* @constructor
* @param {string} key A unique key for the Variable.
* @param {string} defaultValue The default value.
* @param {string} initialValue The initial selected value.
* @param {string[]} limitedToValues The array of allowed values.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {ColorVariable}
*/
constructor(
key: string,
defaultValue: string,
initialValue: string,
limitedToValues?: string[],
callback?: IVariableCallback,
) {
super(key, DataType.COLOR, defaultValue, callback);
super(key, DataType.COLOR, initialValue, callback);
this.limitedToValues = limitedToValues ? limitedToValues : [];
this.controlType = (this.limitedToValues.length > 0) ?
ControlType.COLOR_LIST : ControlType.COLOR_INPUT;
Expand All @@ -77,7 +77,7 @@ export class ColorVariable extends Variable implements IColorVariableParams {
clone() {
let cloned = new ColorVariable(
this.key,
this.defaultValue,
this.initialValue,
this.limitedToValues,
);
cloned.title = this.title;
Expand Down
10 changes: 5 additions & 5 deletions src/core/variables/NumberVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IVariableCallback, IVariableListParams, Variable } from "./Variable";
* @extends IVariableListParams
*/
interface INumberVariableParams extends IVariableListParams {
defaultValue: number;
initialValue: number;
selectedValue: number;
limitedToValues?: number[];
}
Expand All @@ -41,18 +41,18 @@ export class NumberVariable extends Variable implements INumberVariableParams {
* Creates an instance of a ColorVariable.
* @constructor
* @param {string} key A unique key for the Variable.
* @param {number} defaultValue The default value.
* @param {number} initialValue The initial selected value.
* @param {number[]} limitedToValues The array of allowed values.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {NumberVariable}
*/
constructor(
key: string,
defaultValue: number,
initialValue: number,
limitedToValues?: number[],
callback?: IVariableCallback,
) {
super(key, DataType.NUMBER, defaultValue, callback);
super(key, DataType.NUMBER, initialValue, callback);
this.limitedToValues = limitedToValues ? limitedToValues : [];
if (this.limitedToValues.length === 0) {
this.controlType = ControlType.TEXT_INPUT;
Expand Down Expand Up @@ -80,7 +80,7 @@ export class NumberVariable extends Variable implements INumberVariableParams {
clone() {
let cloned = new NumberVariable(
this.key,
this.defaultValue,
this.initialValue,
this.limitedToValues,
);
cloned.title = this.title;
Expand Down
10 changes: 5 additions & 5 deletions src/core/variables/RangeVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { IVariableCallback, IVariableParams, Variable } from "./Variable";
* @extends IVariableParams
*/
export interface IRangeVariableParams extends IVariableParams {
defaultValue: number;
initialValue: number;
selectedValue: number;
minValue: number;
maxValue: number;
Expand All @@ -45,21 +45,21 @@ export class RangeVariable extends Variable implements IRangeVariableParams {
* Creates an instance of a RangeVariable.
* @constructor
* @param {string} key A unique key for the Variable.
* @param {number} defaultValue The default value.
* @param {number} initialValue The initial selected value.
* @param {number} minValue The minimum value allowed.
* @param {number} maxValue The maximum value allowed.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {RangeVariable}
*/
constructor(
key: string,
defaultValue: number,
initialValue: number,
minValue: number,
maxValue: number,
increment: number,
callback?: IVariableCallback,
) {
super(key, DataType.NUMBER, defaultValue, callback);
super(key, DataType.NUMBER, initialValue, callback);
this.minValue = minValue;
this.maxValue = maxValue;
this.increment = increment;
Expand All @@ -82,7 +82,7 @@ export class RangeVariable extends Variable implements IRangeVariableParams {
clone() {
let cloned = new RangeVariable(
this.key,
this.defaultValue,
this.initialValue,
this.minValue,
this.maxValue,
this.increment,
Expand Down
10 changes: 5 additions & 5 deletions src/core/variables/StringVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IVariableCallback, IVariableListParams, Variable } from "./Variable";
* @extends IVariableListParams
*/
interface IStringVariableParams extends IVariableListParams {
defaultValue: string;
initialValue: string;
selectedValue: string;
limitedToValues?: string[];
}
Expand All @@ -41,18 +41,18 @@ export class StringVariable extends Variable implements IStringVariableParams {
* Creates an instance of a StringVariable.
* @constructor
* @param {string} key [A unique key for the Variable.
* @param {string} defaultValue The default value.
* @param {string} initialValue The initial selected value.
* @param {string[]} limitedToValues The array of allowed values.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {StringVariable}
*/
constructor(
key: string,
defaultValue: string,
initialValue: string,
limitedToValues?: string[],
callback?: IVariableCallback,
) {
super(key, DataType.STRING, defaultValue, callback);
super(key, DataType.STRING, initialValue, callback);
this.limitedToValues = limitedToValues ? limitedToValues : [];
if (this.limitedToValues.length === 0) {
this.controlType = ControlType.TEXT_INPUT;
Expand Down Expand Up @@ -80,7 +80,7 @@ export class StringVariable extends Variable implements IStringVariableParams {
clone() {
let cloned = new StringVariable(
this.key,
this.defaultValue,
this.initialValue,
this.limitedToValues,
);
cloned.title = this.title;
Expand Down
16 changes: 8 additions & 8 deletions src/core/variables/Variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface IVariableParams {
constraintType: string;
controlType: string;
dataType: string;
defaultValue: any;
initialValue: any;
selectedValue: any;
callbacks?: IVariableCallback[];
}
Expand Down Expand Up @@ -71,21 +71,21 @@ export class Variable implements IVariableParams {
* Creates an instance of a Variable.
* @param {string} key A unique key for the Variable.
* @param {string} dataType The data type of this Variable.
* @param {any} defaultValue The default value.
* @param {any} initialValue The initial selected value.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {Variable}
*/
constructor(
key: string,
dataType: string,
defaultValue: any,
initialValue: any,
callback?: IVariableCallback,
) {
this.key = this.sanitizeKey(key);
this.title = key;
this.dataType = dataType;
this.defaultValue = defaultValue;
this._selectedValue = defaultValue;
this.initialValue = initialValue;
this._selectedValue = initialValue;
if (callback) {
this._callbacks.push(callback);
}
Expand All @@ -100,7 +100,7 @@ export class Variable implements IVariableParams {
let cloned = new Variable(
this.key,
this.dataType,
this.defaultValue,
this.initialValue,
null,
);
cloned.title = this.title;
Expand Down Expand Up @@ -145,7 +145,7 @@ export class Variable implements IVariableParams {
* The defalut value for this Variable.
* @type {any}
*/
defaultValue: any;
initialValue: any;

/**
* Whether this Variable has been initialized.
Expand Down Expand Up @@ -221,7 +221,7 @@ export class Variable implements IVariableParams {
* Restores the Variable to its default value.
*/
restore(): void {
this.selectedValue = this.defaultValue;
this.selectedValue = this.initialValue;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/LocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface ISerializableData {
controlType: string;
dataType: string;
title: string;
defaultValue: any;
initialValue: any;
selectedValue: any;
limitedToValues?: any[];
minValue?: number;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/__tests__/ColorSwatchControl_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const expect = chai.expect;

describe("ColorSwatchControl", () => {
const key: string = "test_variable";
const defaultValue: string = "#4285F4";
const initialValue: string = "#4285F4";
const limitedToValues: string[] = ["#4285F4", "#0F9D58", "#DB4437"];
let variable: Variable;

beforeEach(() => {
variable = remixer.addColorVariable(key, defaultValue, limitedToValues);
variable = remixer.addColorVariable(key, initialValue, limitedToValues);
this.component = TestUtils.renderIntoDocument(
<ColorSwatchControl
variable={variable}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/__tests__/DropdownControl_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const expect = chai.expect;

describe("DropdownControl", () => {
const key: string = "test_variable";
const defaultValue: string = "a";
const initialValue: string = "a";
const limitedToValues: string[] = ["a", "b", "c"];
let variable: Variable;

beforeEach(() => {
variable = remixer.addStringVariable(key, defaultValue, limitedToValues);
variable = remixer.addStringVariable(key, initialValue, limitedToValues);
this.component = TestUtils.renderIntoDocument(
<DropdownControl
variable={variable}
Expand Down
Loading

0 comments on commit bf4c7bf

Please sign in to comment.