当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript deep-freeze.default方法代码示例

本文整理汇总了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' });
 });
开发者ID:Jason-Rev,项目名称:tsmerge,代码行数:7,代码来源:test.ts

示例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);
  });
开发者ID:eddieLiu69,项目名称:react-webpack-node-tmpl,代码行数:31,代码来源:todo.ts

示例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);
  });
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:25,代码来源:student.spec.ts

示例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);
  });
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:32,代码来源:adminStudent.spec.ts

示例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);
  });
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:26,代码来源:index.spec.ts

示例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);
    });
开发者ID:Edu680,项目名称:react-typescript-samples,代码行数:9,代码来源:reposReducer.spec.ts

示例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);
  });
开发者ID:Edu680,项目名称:react-typescript-samples,代码行数:10,代码来源:membersReducer.spec.ts

示例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;
    });
开发者ID:Lemoncode,项目名称:OpenSouthCodeReact,代码行数:10,代码来源:httpReducer.spec.ts

示例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);
    });
开发者ID:ardiadrianadri,项目名称:react-typescript-samples,代码行数:10,代码来源:memberReducer.spec.ts


注:本文中的deep-freeze.default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。