本文整理汇总了TypeScript中deep-freeze.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should return a new instance with the correct state", () => {
let initialState: Array<Wine> = [new Wine(), new Wine(), new Wine()];
initialState[0]._id = "fakeid1";
initialState[1]._id = "fakeid2";
initialState[2]._id = "fakeid3";
deepfreeze(initialState);
let changedState: Array<Wine> = winesReducer(initialState, {
type: DATA_WINES_REMOVE,
payload: {_id: initialState[0]._id}
});
expect(changedState).not.toBe(initialState);
expect(changedState.length).toBe(2);
expect(_.filter(changedState, (wine: Wine) => wine._id === initialState[0]._id).length).toBe(0)
});
示例2: it
it("should return the same state", () => {
let initialState: AuthenticationDataState = {
isAuthenticated: true,
jwtToken: "token",
account: {
firstName: "firstName",
lastName: "lastName",
login: "login"
}
};
deepfreeze(initialState);
let changedState: AuthenticationDataState = authenticationReducer(initialState, {type: null});
expect(changedState).toBe(initialState);
});
示例3: UpdateRate
it("should return a new instance with the correct state", () => {
let initialState: Array<Wine> = [new Wine(), new Wine(), new Wine()];
initialState[0]._id = "fakeid1";
initialState[1]._id = "fakeid2";
initialState[2]._id = "fakeid3";
let newRating: number = 5;
deepfreeze(initialState);
let changedState: Array<Wine> = winesReducer(initialState,
new UpdateRate("fakeid1", newRating)
);
expect(changedState).not.toBe(initialState);
expect(changedState[0]).not.toBe(initialState[0]);
expect(changedState[0].myRating).toBe(newRating);
});
示例4: it
it("should return a new instance with the correct state", () => {
let initialState: Array<Wine> = [new Wine(), new Wine(), new Wine()];
initialState[0]._id = "fakeid1";
initialState[1]._id = "fakeid2";
initialState[2]._id = "fakeid3";
let newInStock: number = 5;
deepfreeze(initialState);
let changedState: Array<Wine> = winesReducer(initialState, {
type: DATA_WINES_UPDATE_STOCK,
payload: {_id: initialState[0]._id, inStock: newInStock}
});
expect(changedState).not.toBe(initialState);
expect(changedState[0]).not.toBe(initialState[0]);
expect(changedState[0].inStock).toBe(newInStock);
});
示例5: it
it("should return a new instance with the correct state", () => {
let initialState: AuthenticationDataState = {
isAuthenticated: false,
jwtToken: "",
account: null
};
let payload: any = {token: "token", firstName: "firstname", lastName: "lastname", login: "login"};
deepfreeze(initialState);
let changedState: AuthenticationDataState =
authenticationReducer(initialState, new SetAuthentication(payload));
expect(changedState).not.toBe(initialState);
expect(changedState.jwtToken).toEqual(payload.token);
expect(changedState.account.firstName).toEqual(payload.firstName);
expect(changedState.account.lastName).toEqual(payload.lastName);
expect(changedState.account.login).toEqual(payload.login);
});
示例6: it
it("should unstar the tweet that was passed in the payload if it was false", () => {
let tweet1: Tweet = new Tweet(1, "@KwintenP", "Giving a talk at JSBE", true);
let tweet2: Tweet = new Tweet(3, "@JS_BE", "Giving a meetup, yeaj", true);
let initialState: Array<Tweet> = [tweet1, tweet2];
deepfreeze(initialState);
let changedState: Array<Tweet> = tweetsReducer(initialState,
{
type: TOGGLE_STAR_TWEET,
payload: {
id: 1
}
});
expect(changedState[0].starred).toBeFalsy();
});
示例7: it
it("should return a new state with a different isCollapsed value", () => {
let initialState: CollapsableSidebarContainerState = {
isCollapsed: false
};
deepfreeze(initialState);
let changedState: CollapsableSidebarContainerState =
collapsableSidebarReducer(initialState, new ToggleSidebar());
expect(changedState).not.toBe(initialState);
expect(changedState.isCollapsed).toBe(true);
initialState = {
isCollapsed: true
};
changedState = collapsableSidebarReducer(initialState, new ToggleSidebar());
expect(changedState.isCollapsed).toBe(false);
});
示例8: it
it("should return a new instance with the state cleared", () => {
let initialState: AuthenticationDataState = {
isAuthenticated: true,
jwtToken: "token",
account: {
firstName: "firstName",
lastName: "lastName",
login: "login"
}
};
deepfreeze(initialState);
let changedState: AuthenticationDataState =
authenticationReducer(initialState, {type: DATA_AUTHENTICATION_CLEAR_AUTHENTICATION});
expect(changedState).not.toBe(initialState);
expect(changedState.isAuthenticated).toBe(false);
});
示例9: it
it("should return a new state with a different isCollapsed value", () => {
let initialState: CollapsableSidebarContainerState = {
isCollapsed: false
};
deepfreeze(initialState);
let changedState: CollapsableSidebarContainerState =
collapsableSidebarReducer(initialState, {type: CONTAINER_COLLAPSABLESIDEBAR_TOGGLE});
expect(changedState).not.toBe(initialState);
expect(changedState.isCollapsed).toBe(true);
initialState = {
isCollapsed: true
};
changedState = collapsableSidebarReducer(initialState, {type: CONTAINER_COLLAPSABLESIDEBAR_TOGGLE});
expect(changedState.isCollapsed).toBe(false);
});
示例10: UpdateWine
it("should return a new instance with the correct state", () => {
let initialState: Array<Wine> = [new Wine(), new Wine(), new Wine()];
initialState[0]._id = "fakeid1";
initialState[1]._id = "fakeid2";
initialState[2]._id = "fakeid3";
let updateWine: Wine = Object.assign({}, initialState[0], {
name: "updated"
});
deepfreeze(initialState);
let changedState: Array<Wine> = winesReducer(initialState,
new UpdateWine("fakeid1", updateWine)
);
expect(changedState).not.toBe(initialState);
expect(changedState[0]).not.toBe(initialState[0]);
expect(changedState[0]).not.toBe(updateWine);
expect(changedState[0]).toEqual(updateWine);
});