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


TypeScript QUnit.test函数代码示例

本文整理汇总了TypeScript中QUnit.test函数的典型用法代码示例。如果您正苦于以下问题:TypeScript test函数的具体用法?TypeScript test怎么用?TypeScript test使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: run

 public run(): void {
     QUnit.test("hello test", (assert) => {
         assert.ok(1 === 1, "Passed!");
     });
     //
     QUnit.test("Promise test", (assert) => {
         var done = assert.async();
         test_func().then((r: string) => {
             assert.ok(true, 'text is ' + r);
             done();
         }).catch((err) => {
             assert.ok(false, err.toString());
             done();
         });
     });
     //
     QUnit.test("PouchDatabase test", (assert) => {
         var done = assert.async();
         let base = new PouchDatabase();
         base.db.then((xdb) => {
             assert.ok((xdb !== undefined) && (xdb !== null), "db OK!");
             done();
         },(ex)=>{
             assert.ok(false, ex.toString());
             done();
             }).catch((err) => {
             assert.ok(false, err.toString());
             done();
         });
     });
 }// run
开发者ID:boubad,项目名称:TxDatalib,代码行数:31,代码来源:dummy.ts

示例2: module

        module('the params belong to a different user', function(hooks) {
          const escapedName = 'Test%20User';
          const publicKey = '53edcbe7d1cdd289e9f4ea74eab12c6dd78720124efd9ad331d6e174aae5677c';

          hooks.beforeEach(async function() {
            const url = `/invite?name=${escapedName}&publicKey=${publicKey}`;

            await visit(url);
          });

          test('a redirect to the correct direct message chat', function(assert) {
            assert.expect(1);

            assert.equal(currentURL(), `/chat/privately-with/${publicKey}`);
            percySnapshot(assert as any);
          });

          test('the contact is added to the list of contacts', async function(assert) {
            const store = getService<DS.Store>('store');

            const record = await store.findRecord('contact', publicKey);

            assert.ok(record);
          });
        });
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:25,代码来源:acceptance-test.ts

示例3: module

module('Integration | Component | search/search-facet', function(hooks) {
  setupRenderingTest(hooks);

  test('it renders', async function(assert) {
    await createTest(this);
    assert.equal(getTextNoSpaces(this), 'Facet1Value11Value210');
  });

  test('it renders with clear', async function(assert) {
    await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
  });

  test('clear action', async function(assert) {
    const { wasClearCalled } = await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
    await click(CLEAR_BTN_SELECTOR);
    assert.ok(wasClearCalled(), 'Clear was called');
  });

  test('facet changed action', async function(assert) {
    const { wasChangedCalled } = await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
    await click(FACET_OPTION_SELECTOR);
    assert.ok(wasChangedCalled(), 'Clear was called');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:27,代码来源:search-facet-test.ts

示例4: module

module('Acceptance | search', function(hooks) {
  setupApplicationTest(hooks);

  test('Search does not through an error when typing', async function(assert) {
    await appLogin();
    await visit('/');

    assert.equal(currentURL(), '/browse/datasets', 'We made it to the home page in one piece');
    fillIn(searchBarSelector, 'Hello darkness my old friend');
    assert.ok(true, 'Did not encounter an error when filling in search bar');
  });

  test('visiting /search and restoring facet selections', async function(assert) {
    await appLogin();
    await visit('/search?facets=(fabric%3AList(prod%2Ccorp))&keyword=car');

    assert.equal(currentURL(), '/search?facets=(fabric%3AList(prod%2Ccorp))&keyword=car');

    const { prod, corp, dev, ei } = getCheckboxes(this);
    const searchBar = querySelector<HTMLInputElement>(this, searchBarSelector) || { value: '' };

    assert.ok(prod.checked);
    assert.ok(corp.checked);
    assert.notOk(dev.checked);
    assert.notOk(ei.checked);
    assert.equal(searchBar.value, 'car');

    await click(getCheckboxSelector('ei'));

    assert.equal(currentURL(), '/search?facets=(fabric%3AList(prod%2Ccorp%2Cei))&keyword=car');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:32,代码来源:search-test.ts

示例5: module

    module('yourself', function(hooks) {
      setupRelayConnectionMocks(hooks);

      hooks.beforeEach(async function() {
        await visit('/chat/privately-with/me');
      });

      test('page renders with default states', function(assert) {
        assert.equal(currentURL(), '/chat/privately-with/me');

        assert.notOk(chat.textarea.isDisabled(), 'textarea is enabled');
        assert.ok(chat.submitButton.isDisabled(), 'submit button is disabled');
        assert.equal(chat.messages.all().length, 0, 'history is blank');
      });

      test('there are 0 messages to start with', function(assert) {
        const result = chat.messages.all().length;

        assert.equal(result, 0);
      });

      module('text is entered', function(hooks) {
        hooks.beforeEach(async function() {
          await chat.textarea.fillIn('a message');
        });

        test('the chat button is not disabled', function(assert) {
          assert.notOk(chat.submitButton.isDisabled());
        });

        module('submit is clicked', function(hooks) {
          hooks.beforeEach(async function() {
            chat.submitButton.click();
            await waitFor(chat.selectors.submitButton + '[disabled]');
          });

          test('inputs are disabled', function(assert) {
            // assert.equal(chat.messages.all().length, 0, 'history is blank');
            // assert.ok(chat.textarea.isDisabled(), 'textarea is disabled');
            assert.ok(chat.submitButton.isDisabled(), 'submitButton is disabled');

            percySnapshot(assert as any);
          });
        });

        module('enter is pressed', function(hooks) {
          hooks.beforeEach(async function() {
            triggerEvent(chat.selectors.form, 'submit');
            await waitFor(chat.selectors.submitButton + '[disabled]');
          });

          test('inputs are disabled', function(assert) {
            // assert.ok(chat.textarea.isDisabled(), 'textarea is disabled');
            assert.ok(chat.submitButton.isDisabled(), 'submitButton is disabled');

            percySnapshot(assert as any);
          });
        });
      });
    });
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:60,代码来源:-acceptance-test.ts

示例6: module

module('Unit | Utility | debug logger', function(hooks) {
  let log: SinonStub;

  hooks.beforeEach(function() {
    debug.enable('test:sample-key');
    log = sinon.stub(console, 'log');
  });

  hooks.afterEach(function() {
    debug.disable();
    log.restore();
  });

  test('it honors an explicit key', function(assert) {
    const logger = debugLogger('test:sample-key');
    logger('placeholder message');

    let [message] = A(log.args).get('lastObject') || [''];
    assert.ok(/test:sample-key/.test(message), 'Log entry should contain the namespace');
    assert.ok(/placeholder message/.test(message), 'Log entry should contain the message');
  });

  test('it throws with a useful message when it can\'t determine a key', function(assert) {
    const logger = debugLogger();

    assert.throws(function() {
      logger('message');
    }, /explicit key/);

    assert.throws(function() {
      let object = { debug: logger };
      object.debug('message');
    }, /explicit key/);
  });
});
开发者ID:salsify,项目名称:ember-debug-logger,代码行数:35,代码来源:debug-logger-test.ts

示例7: module

module('TestHelper | create-current-user', function(hooks) {
  setupApplicationTest(hooks);
  clearLocalStorage(hooks);

  test('a new user is created and kept in cache', async function(assert) {
    const before = getStore().peekAll('user');

    assert.equal(before.length, 0);

    await createCurrentUser();

    const after = getStore().peekAll('user');

    assert.equal(after.length, 1);
    assert.equal(after.toArray()[0].id, 'me');
  });

  test('a new user is created and stored', async function(assert) {
    const before = await getStore().findAll('user');

    assert.equal(before.length, 0);

    await createCurrentUser();

    const after = await getStore().findAll('user');

    assert.equal(after.length, 1);
    assert.equal(after.toArray()[0].id, 'me');
  });

  test('the user is set on the identity service', async function(assert) {
    const before = getService<CurrentUserService>('currentUser').record;

    assert.notOk(before);

    const user = await createCurrentUser();

    const after = getService<CurrentUserService>('currentUser').record;

    assert.deepEqual(after, user);
  });

  module('user is setup in a beforeEach', function(hooks) {
    setupCurrentUser(hooks);

    test('the user is logged in', function(assert) {
      const isLoggedIn = getService<CurrentUserService>('currentUser').isLoggedIn;

      assert.ok(isLoggedIn);
    });

    test('identity exists', async function(assert) {
      const exists = await getService<CurrentUserService>('currentUser').exists();

      assert.ok(exists);
    });
  });
});
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:58,代码来源:create-current-user-test.ts

示例8: module

module('Unit | Utility | nacl', function() {
  test('libsodium uses wasm', async function(assert) {
    const sodium = await nacl.libsodium();
    const isUsingWasm = (sodium as any).libsodium.usingWasm;

    assert.ok(isUsingWasm);
  });

  test('generateAsymmetricKeys | works', async function(assert) {
    const boxKeys = await nacl.generateAsymmetricKeys();

    assert.ok(boxKeys.publicKey);
    assert.ok(boxKeys.privateKey);
  });

  test('encryptFor/decryptFrom | works with Uint8Array', async function(assert) {
    const receiver = await nacl.generateAsymmetricKeys();
    const sender = await nacl.generateAsymmetricKeys();

    const msgAsUint8 = Uint8Array.from([104, 101, 108, 108, 111]); // hello
    const ciphertext = await nacl.encryptFor(msgAsUint8, receiver.publicKey, sender.privateKey);
    const decrypted = await nacl.decryptFrom(ciphertext, sender.publicKey, receiver.privateKey);

    assert.deepEqual(msgAsUint8, decrypted);
  });

  test('encryptFor/decryptFrom | works with large data', async function(assert) {
    const receiver = await nacl.generateAsymmetricKeys();
    const sender = await nacl.generateAsymmetricKeys();

    let bigMsg: number[] = [];
    for (let i = 0; i < 128; i++) {
      bigMsg = bigMsg.concat([104, 101, 108, 108, 111]);
    }

    const msgAsUint8 = Uint8Array.from(bigMsg); // hello * 128 = 640 Bytes
    const ciphertext = await nacl.encryptFor(msgAsUint8, receiver.publicKey, sender.privateKey);
    const decrypted = await nacl.decryptFrom(ciphertext, sender.publicKey, receiver.privateKey);

    assert.deepEqual(msgAsUint8, decrypted);
  });

  test('splitNonceFromMessage | separates the nonce', async function(assert) {
    // prettier-ignore
    const msg = [
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
    ];

    const messageWithNonce = Uint8Array.from([...msg, 25]);

    const [nonce, notTheNonce] = await nacl.splitNonceFromMessage(messageWithNonce);

    assert.deepEqual(nonce, Uint8Array.from(msg));
    assert.deepEqual(notTheNonce, Uint8Array.from([25]));
  });
});
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:56,代码来源:unit-test.ts


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