當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript deep-freeze類代碼示例

本文整理匯總了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;未經允許,請勿轉載。