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


TypeScript assert.ifError函數代碼示例

本文整理匯總了TypeScript中assert.ifError函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript ifError函數的具體用法?TypeScript ifError怎麽用?TypeScript ifError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ifError函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: done

        request.get({url:domain+'/files/'+this.file.fileId, json:true}, (err, rs, updated:IFile) => {
          assert.ifError(err)
          assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + updated)
          assert.equal(updated.name, "asdf", "didn't update. maybe it updated the fileId") // data.txt
          assert.equal(updated.ext, "txt", "changed extension!")
          assert.equal(updated.url, this.file.url)

          this.book.files = [updated]

          // your responsibility to update the book's version
          request.put({url:domain+"/books/"+this.bookId, json:this.book}, (err, rs, body) => {
            assert.ifError(err)
            assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + body)

            request.get({url:domain+'/books/'+this.bookId+'/files', json:true}, (err, rs, files:IFile[]) => {
              assert.ifError(err)
              assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + files)
              assert.equal(files.length, 1)
              var updated = files[0]
              assert.equal(updated.name, "asdf", "didn't update. maybe it updated the fileId") // data.txt
              assert.equal(updated.ext, "txt", "changed extension!")
              assert.equal(updated.url, this.file.url)
              done()
            })

          })

        })
開發者ID:emenwin,項目名稱:librosapp,代碼行數:28,代碼來源:files.test.ts

示例2: done

 request.get({url: domain + '/genres/'+this.book.genre+'/books', json:true}, (err, rs, books:IBook[]) => {
   assert.ifError(err)
   assert.equal(rs.statusCode, 200)
   assert.equal(books[0].genre, this.book.genre)
   assert.ok(books.filter((book:IBook) => book.bookId == this.book.bookId).length)
   done()
 })
開發者ID:emenwin,項目名稱:librosapp,代碼行數:7,代碼來源:genres.test.ts

示例3: function

 bq.createJob({}, function(err, job, resp) {
   assert.ifError(err);
   assert.strictEqual(job, fakeJob);
   assert.strictEqual(job.metadata, RESPONSE);
   assert.strictEqual(resp, RESPONSE);
   done();
 });
開發者ID:brgmn,項目名稱:nodejs-bigquery,代碼行數:7,代碼來源:index.ts

示例4: walkTest

	export async function walkTest() {
		const dirs: string[] = []
		const files: string[] = []
		await new fileSystem.FileSystem().walk(".", {
			other() {

			},
			error(e) {
				assert.ifError(e)
			},
			dir(p) {
				dirs.push(path.relative(root, p).replace(/\\/g, "/"))
			},
			file(p) {
				files.push(path.relative(root, p).replace(/\\/g, "/"))
			},
			walkDir() {

			}
		})
		assert.deepStrictEqual(dirs.sort(), ["", "dir1", "dir1/sub1", "dir1/sub2", "dir2"])
		assert.deepStrictEqual(files.sort(), ["dir1/sub1/f3.txt", "dir1/sub1/f4.txt", "dir1/sub2/f5.txt", "f1.txt", "f2.txt"])

		await new fileSystem.FileSystem().walk("404", {})
	}
開發者ID:tpack,項目名稱:utilskit,代碼行數:25,代碼來源:fileSystem.test.ts

示例5: done

 api.wait(brk, err2 => {
   assert.ifError(err2);
   const frame = brk.stackFrames[0];
   const args = frame.arguments;
   const locals = frame.locals;
   // TODO: Determine how to remove these casts to any.
   ctxMembers = brk.variableTable.slice(brk.variableTable.length - 1)[0]!
     .members;
   assert.deepStrictEqual(
     ctxMembers!.length,
     1,
     'There should be one member in the context variable value'
   );
   assert.deepStrictEqual(ctxMembers![0], {name: 'a', value: '10'});
   assert.strictEqual(args.length, 0, 'There should be zero arguments');
   if (utils.satisfies(process.version, '>=11')) {
     assert.strictEqual(locals.length, 3, 'There should be three locals');
     assert.deepStrictEqual(locals[0].name, 'this');
     assert.deepStrictEqual(locals[1], {name: 'b', value: '1'});
     assert.deepStrictEqual(locals[2].name, 'context');
   } else {
     assert.strictEqual(locals.length, 2, 'There should be two locals');
     assert.deepStrictEqual(locals[0], {name: 'b', value: '1'});
     assert.deepStrictEqual(locals[1].name, 'context');
   }
   api.clear(brk, err3 => {
     assert.ifError(err3);
     done();
   });
 });
開發者ID:GoogleCloudPlatform,項目名稱:cloud-debug-nodejs,代碼行數:30,代碼來源:test-this-context.ts

示例6: assert

    api.set(bp, err => {
      assert.ifError(err);
      api.wait(bp, err => {
        assert.ifError(err);
        const exp = bp.evaluatedExpressions[0];
        assert(exp);
        const varIndex = exp!.varTableIndex;
        assert(varIndex);
        const members = bp.variableTable[varIndex!]!.members;
        assert(members);
        for (const entry of members!) {
          if (entry.name === 'title') {
            assert(entry.value === undefined);
          }
        }

        api.clear(bp, err => {
          assert.ifError(err);
          done();
        });
      });
      process.nextTick(() => {
        code.foo();
      });
    });
開發者ID:GoogleCloudPlatform,項目名稱:cloud-debug-nodejs,代碼行數:25,代碼來源:test-expression-side-effect.ts

示例7: function

 fs.readFile(this.file.url.replace(localFileMatch[0], ""), function(err, body) {
   assert.ifError(err)
   var asdf = body.toString()
   assert.ok(asdf.match('data'))
   done()
   
   })
開發者ID:emenwin,項目名稱:librosapp,代碼行數:7,代碼來源:files.test.ts

示例8: function

        table.createLoadJob(file, function(err, job) {
          assert.ifError(err);

          job.on('error', done).on('complete', function() {
            done();
          });
        });
開發者ID:brgmn,項目名稱:nodejs-bigquery,代碼行數:7,代碼來源:bigquery.ts


注:本文中的assert.ifError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。