本文整理汇总了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' },
);
});
示例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);
});
示例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);
});
示例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);
});
示例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;
});
示例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;
});
示例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;
});
示例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");
});