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


TypeScript assert.fail方法代码示例

本文整理汇总了TypeScript中chai.assert.fail方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.fail方法的具体用法?TypeScript assert.fail怎么用?TypeScript assert.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chai.assert的用法示例。


在下文中一共展示了assert.fail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

 test('resolves only once', async () => {
   const deferred = new Deferred<string>();
   deferred.resolve('foo');
   try {
     deferred.resolve('bar');
     assert.fail();
   } catch (e) {
     // pass
   }
   try {
     deferred.reject(new Error('bar'));
     assert.fail();
   } catch (e) {
     // pass
   }
 });
开发者ID:asdfg9822,项目名称:polymer-analyzer,代码行数:16,代码来源:utils_test.ts

示例2: it

        it(`an inline or anonymous interface must be explicitly annotated with ObjectSchema()`, function () {
            try {
                class ClassToValidate {
                    @Keys({
                        nestedProperty: Joi.number()
                    })
                    public myProperty! : {
                        nestedProperty : number;
                    };
                }
                assert.fail();
            } catch (err) {
                if (!(err instanceof ConstraintDefinitionError)) {
                    throw err;
                }
                assert.equal(err.message, "No validation schema exists, nor could it be inferred from the design:type metadata, for property \"myProperty\". Please decorate the property with a type schema.");
            }

            const validator = new Validator();
            class ClassToValidate2 {
                @Keys({
                    nestedProperty: Joi.number()
                })
                @ObjectSchema()
                public myProperty! : {
                    nestedProperty : number;
                };
            }

            const instance = new ClassToValidate2();
            instance.myProperty = {
                nestedProperty: 123
            };
            isValid(validator, instance);
        });
开发者ID:laurence-myers,项目名称:tsdv-joi,代码行数:35,代码来源:gotchas.ts

示例3: it

 it('should get the next game in a circular loop', () => {
   const countsPerGame: Dict<number> = {};
   const firstGameName: GameName = 'piano-game';
   let currentGameName: GameName = firstGameName;
   let loopCount = 0;
   while (true) {
     currentGameName = getNextGame(currentGameName);
     // Track the number of times we see each game so we can ensure that it circles back.
     countsPerGame[currentGameName] = (countsPerGame[currentGameName] || 0) + 1;
     // Break when we circle back to the first game
     if (currentGameName === firstGameName) {
       break;
     }
     // Sanity check the loop count in case the exit condition never hits.
     loopCount++;
     if (loopCount > 999) {
       assert.fail('Looped way too many times - getting the next game name should be circular.');
       break;
     }
   }
   assert(
     values(countsPerGame).every((count: number) => count === 1),
     'should have looped through each game once'
   );
   assert.equal(
     Object.keys(countsPerGame).length,
     3,
     'expected to loop through exactly 3 game names'
   );
 });
开发者ID:agaricus,项目名称:ear-sharpener,代码行数:30,代码来源:test.ts

示例4: catch

 function checkNoOpHandler<T>(requestInfo: RequestInfo<T>): void {
   try {
     requestInfo.handler(fakeXhrIo({}), '');
   } catch (e) {
     assert.fail('Remove handler threw');
   }
 }
开发者ID:RameshBhupathi,项目名称:firebase-js-sdk,代码行数:7,代码来源:requests_test.ts

示例5: it

  it('creates externs, adds type comments and rewrites imports', () => {
    const diagnostics: ts.Diagnostic[] = [];

    const closure = toClosureJS(
        {sourceMap: true, experimentalDecorators: true} as ts.CompilerOptions,
        ['test_files/underscore/export_underscore.ts', 'test_files/underscore/underscore.ts'],
        {isTyped: true}, diagnostics);

    if (!closure) {
      diagnostics.forEach(v => console.log(JSON.stringify(v)));
      assert.fail();
      return;
    }

    expect(closure.externs).to.contain(`/** @const */
var __NS = {};
 /** @type {number} */
__NS.__ns1;
`);

    const underscoreDotJs = closure.jsFiles.get('test_files/underscore/underscore.js');
    expect(underscoreDotJs).to.contain(`goog.module('test_files.underscore.underscore')`);
    expect(underscoreDotJs).to.contain(`/** @type {string} */`);

    const exportUnderscoreDotJs = closure.jsFiles.get('test_files/underscore/export_underscore.js');
    expect(exportUnderscoreDotJs)
        .to.contain(`goog.module('test_files.underscore.export_underscore')`);
  });
开发者ID:lucidsoftware,项目名称:tsickle,代码行数:28,代码来源:e2e_main_test.ts

示例6: it

    it ('Can authenticate with BearerToken', async () => {
        var request = new Authenticate();
        request.provider = "credentials";
        request.userName = "test";
        request.password = "test";
        var authResponse = await testClient.post(request);
        var jwtToken = authResponse.bearerToken;
        chai.expect(jwtToken).not.empty;

        //Clear existing User Session
        var logout = new Authenticate();
        logout.provider = "logout";
        await testClient.post(logout);

        var newClient = new JsonServiceClient(TEST_URL);

        try {
            //New Client without BearerToken should fail
            await newClient.post(new Authenticate());
            chai.assert.fail(0,1, "Should not be allowed to authenticate");
        } catch (e) {
            if (e instanceof chai.AssertionError)
                throw e;

            const status = (e as ErrorResponse).responseStatus;
            chai.expect(status.errorCode).to.equal("401");
            chai.expect(status.message).to.equal("Unauthorized");

            //New Client with BearerToken
            newClient.bearerToken = jwtToken;
            var success = await newClient.post(new Authenticate());
            chai.expect(success.userId).not.empty;
            chai.expect(success.sessionId).not.empty;
        }
    })
开发者ID:ServiceStack,项目名称:servicestack-client,代码行数:35,代码来源:client.spec.ts

示例7: it

 it("should verify ParseXml - invalid xml input", async function() {
     try {
         await CommandHelper.ParseXml("<?xml><<<<");
         assert.fail("didn't throw!");
     } catch (err) {
         assert.isTrue(err.message.startsWith("Unexpected end"));
     }
 });
开发者ID:creativewebmatrixsolutions,项目名称:vsts-vscode,代码行数:8,代码来源:commandhelper.test.ts

示例8: assertError

export function assertError(fn: () => any, code: string) {
    try {
        fn();
    } catch (e) {
        assert.equal(e.code, code);
        return;
    }
    assert.fail();
}
开发者ID:MaKleSoft,项目名称:padlock,代码行数:9,代码来源:helpers.ts

示例9: function

 helper.dataDrivenTest(tests, function(data, expect) {
   try {
     parse(data);
   } catch (e) {
     assert.match(e.message, expect);
     return;
   }
   assert.fail(undefined, undefined, "No exception thrown.");
 });
开发者ID:brewsoftware,项目名称:bolt,代码行数:9,代码来源:parser-test.ts

示例10: it

 it("should throw an error if the same actionNamespace is used twice", function () {
   new CachedDataReducer<Request, Response>(apiEndpointMock, "duplicatenamespace");
   try {
     new CachedDataReducer<Request, Response>(apiEndpointMock, "duplicatenamespace");
   } catch (e) {
     assert(_.isError(e));
     return;
   }
   assert.fail("Expected to fail after registering a duplicate actionNamespace.");
 });
开发者ID:tlvenn,项目名称:cockroach,代码行数:10,代码来源:cachedDataReducer.spec.ts


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