本文整理汇总了TypeScript中deep-freeze类的典型用法代码示例。如果您正苦于以下问题:TypeScript deep-freeze类的具体用法?TypeScript deep-freeze怎么用?TypeScript deep-freeze使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了deep-freeze类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return same state without mutate it when passing state and some action type', () => {
// Arrange
const state: MemberEntity = { id: 1, login: 'test login', avatar_url: 'test avatar_url' };
const action = { type: 'some type' };
deepFreeze(state);
// Act
const nextState = memberReducer(state, action);
// Assert
expect(nextState).toEqual(
{ id: 1, login: 'test login', avatar_url: 'test avatar_url' },
);
});
开发者ID:Lemoncode,项目名称:react-typescript-samples,代码行数:14,代码来源:member.spec.ts
示例2: it
it('should return same state when passing an action that is not expected', () => {
// Arrange
const originalState: LoginState = new LoginState();
const action = {
type: 'NOT_EXPECTED_ACTION_1',
};
deepFreeze(originalState);
// Act
const newState = loginReducer(originalState, action);
// Assert
expect(newState).to.be.equal(originalState);
});
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:14,代码来源:index.spec.ts
示例3: MemberState
'action equals { type: "MEMBER_UI_INPUT", fieldName: "id", value: 2 }', () => {
let initialState = new MemberState();
initialState.member.id = 1;
let action = {
type: "MEMBER_UI_INPUT",
fieldName: "id",
value: 2
};
deepFreeze(initialState);
let finalState = memberReducer(initialState, action);
expect(finalState.member.id).to.be.equal(2);
});
开发者ID:ardiadrianadri,项目名称:react-typescript-samples,代码行数:15,代码来源:memberReducer.spec.ts
示例4: it
it('should return the current state when action type is uknown', () => {
// Arrange
const state = undefined;
const expectedState = new TrainingTOC();
const action = {
type: 'UNKNOWN_ACTION',
};
deepFreeze(action);
// Act
const newState = trainingTOCReducer(state, action);
// Assert
expect(newState).to.be.deep.equals(expectedState);
});
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:15,代码来源:student.spec.ts
示例5: HttpState
'HttpState equals {numberOfCalls: 1, httpCallsInProgress: true} and action equals { type: "HTTP_GET_CALL_COMPLETED" }', () => {
let initialState = new HttpState();
initialState.numberOfCalls = 1;
initialState.httpCallsInProgress = true;
let action = {
type: "HTTP_GET_CALL_COMPLETED"
};
deepFreeze(initialState);
let finalState = httpReducer(initialState, action);
expect(finalState.numberOfCalls).to.be.equal(0);
expect(finalState.httpCallsInProgress).to.be.false;
});
开发者ID:Lemoncode,项目名称:OpenSouthCodeReact,代码行数:15,代码来源:httpReducer.spec.ts
示例6: MemberState
'action equals { type: "MEMBER_SAVE", errors: { isEntityValid: true } }', () => {
let initialState = new MemberState();
let action = {
type: "MEMBER_SAVE",
errors: {
isEntityValid: true
}
};
deepFreeze(initialState);
let finalState = MemberReducer(initialState, action);
expect(finalState.saveCompleted).to.be.true;
});
开发者ID:algil,项目名称:react-typescript-samples,代码行数:15,代码来源:memberReducer.spec.ts
示例7: MemberEntity
'action equals { type: "MEMBER_LOAD", member: new MemberEntity() }', () => {
let initialState = new MemberState();
initialState.isValid = false;
let member = new MemberEntity();
let action = {
type: "MEMBER_LOAD",
member: member
};
deepFreeze(initialState);
let finalState = memberReducer(initialState, action);
expect(finalState.isValid).to.be.true;
});
开发者ID:ardiadrianadri,项目名称:react-typescript-samples,代码行数:16,代码来源:memberReducer.spec.ts
示例8: it
it('should return new array with same items when passing initialState equals [repo1, repo2] and action equals {}', () => {
let repo1 = new RepoEntity();
let repo2 = new RepoEntity();
repo1.name = "test1";
repo2.name = "test2"
let initialState : Array<RepoEntity> = [repo1, repo2];
let action = {};
deepFreeze(initialState);
let finalState = reposReducer(initialState, action);
expect(finalState.length).to.be.equal(2);
expect(finalState[0].name).to.be.equal("test1");
expect(finalState[1].name).to.be.equal("test2");
});
开发者ID:Edu680,项目名称:react-typescript-samples,代码行数:17,代码来源:reposReducer.spec.ts
注:本文中的deep-freeze类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论