本文整理汇总了TypeScript中deep-freeze.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript deep-freeze.default方法的具体用法?TypeScript deep-freeze.default怎么用?TypeScript deep-freeze.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deep-freeze
的用法示例。
在下文中一共展示了deep-freeze.default方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('makes sure it is immutable', () => {
const a = df({ a: 'a' });
const b = df({ b: 'b' });
const c = df({ c: 'c' });
expect(merge(a, b)).to.be.deep.equal({ a: 'a', b: 'b' });
expect(merge(a, b, c)).to.be.deep.equal({ a: 'a', b: 'b', c: 'c' });
});
示例2: it
it("toggle todo", () =>{
const stateBefore = {
isFetching: false,
isLoaded: false,
todos: [
{ id: 0, text: 'Learn Redux', completed: false },
{ id: 1, text: 'Learn Redux1', completed: false },
{ id: 2, text: 'Learn Redux2', completed: false }
]
};
const action = {
type: 'TOGGLE_TODO',
id: 1
};
const stateAfter = {
isFetching: false,
isLoaded: false,
todos: [
{ id: 0, text: 'Learn Redux', completed: false },
{ id: 1, text: 'Learn Redux1', completed: true },
{ id: 2, text: 'Learn Redux2', completed: false }
]
};
deepFreeze(stateBefore);
deepFreeze(action);
expect(todos(stateBefore, action)).toEqual(stateAfter);
});
示例3: it
it('should return next state when passing action type equals GET_SUMMARY_TRAINING_REQUEST_COMPLETED', () => {
// Arrange
const originalState: TrainingSummary[] = [];
const trainingSummary: TrainingSummary[] = [
{
id: '123',
end: new Date(),
isActive: false,
name: 'Training',
start: new Date(),
},
];
const action = {
type: studentActionEnums.GET_SUMMARY_TRAINING_REQUEST_COMPLETED,
payload: trainingSummary,
};
deepFreeze(action);
deepFreeze(originalState);
// Act
const nextState = trainingListReducer(originalState, action);
// Assert
expect(nextState).to.be.deep.equals(action.payload);
});
示例4: AdminStudentState
passing a GET_SUMMARY_STUDENT_REQUEST_COMPLETED`, () => {
// Arrange
const originalState = new AdminStudentState();
deepFreeze(originalState);
const students: StudentSummary[] = [
{
id: '2',
fullname: 'John Doe',
email: 'test@test.com',
isActive: true,
},
{
id: '3',
fullname: 'Mark Somez',
email: 'mark@test.com',
isActive: true,
},
];
const actionResult = {
type: adminActionEnums.GET_SUMMARY_STUDENT_REQUEST_COMPLETED,
payload: students,
};
// Act
const newState = adminStudentReducer(originalState, actionResult);
// Assert
expect(newState.studentSummaryList).to.eql(students);
});
示例5: it
it('should return a new state with the new field errors when passing a LOGIN_REQUEST_ERROR', () => {
// Arrange
const originalState: LoginState = new LoginState();
const loginError: FieldValidationResult = { ...new FieldValidationResult(), key: 'login' };
const passwordError: FieldValidationResult = { ...new FieldValidationResult(), key: 'password' };
const fieldErrors: FieldValidationResult[] = [loginError, passwordError];
const action = {
type: loginActionEnums.LOGIN_REQUEST_ERROR,
payload: fieldErrors,
};
deepFreeze(originalState);
const expectedState: LoginState = {
...originalState,
loginErrors: {
login: loginError,
password: passwordError,
},
};
// Act
const newState = loginReducer(originalState, action);
// Assert
expect(newState).to.be.deep.equals(expectedState);
});
示例6: it
it('should return empty array state when passing initialState equals [] and action equals {}', () => {
let initialState = [];
let action = {};
deepFreeze(initialState);
let finalState = reposReducer(initialState, action);
expect(finalState.length).to.be.equal(0);
});
示例7: it
it('should return empty array state when passing initialState equals [] and action equals {}', () => {
let initialState = [];
let action = {};
// Check that state is inmutable
deepFreeze(initialState);
let finalState = membersReducer(initialState, action);
expect(finalState.length).to.be.equal(0);
});
示例8: HttpState
'and action equals {}', () => {
let initialState = new HttpState();
initialState.httpCallsInProgress = false;
let action = {};
deepFreeze(initialState);
let finalState = httpReducer(initialState, action);
expect(finalState.httpCallsInProgress).to.be.false;
});
示例9: it
it('should return new MemberState with same values when passing initialState with MemberState.member.id equals 2 and action equals {}', () => {
let initialState = new MemberState();
initialState.member.id = 2;
let action = {};
deepFreeze(initialState);
let finalState = memberReducer(initialState, action);
expect(finalState.member.id).to.be.equal(2);
});