Files
2022-01-20 20:30:18 +01:00

3.4 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d824e367417b2b2512c57 オブジェクトがコンストラクターのインスタンスであるかどうかをテストする 2 301605 test-if-an-object-is-an-instance-of-a-constructor

--description--

注意点として、このプロジェクトは Replit の始動プロジェクト、または GitHub からクローンされたプロジェクトに基づいて構築されています。

#instanceOf は、オブジェクトがコンストラクターのインスタンスであることをアサートします。

--instructions--

tests/1_unit-tests.js の中の、Objects スイート内の #18 に分類されたテストにおいて、テストを合格にする (true と評価する必要があります) ために、それぞれの assertassert.instanceOf または assert.notInstanceOf に変更してください。 アサートに渡された引数を変更しないでください。

--hints--

すべてのテストに合格する必要があります。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
    (data) => {
      assert.equal(data.state, 'passed');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

最初のアサーションに対して、正しいメソッドを選ぶ必要があります - instanceOf もしくは notInstanceOf です。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
    (data) => {
      assert.equal(
        data.assertions[0].method,
        'notInstanceOf',
        'myCar is not an instance of Plane'
      );
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - instanceOf もしくは notInstanceOf です。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
    (data) => {
      assert.equal(
        data.assertions[1].method,
        'instanceOf',
        'airlinePlane is an instance of Plane'
      );
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - instanceOf もしくは notInstanceOf です。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
    (data) => {
      assert.equal(
        data.assertions[2].method,
        'instanceOf',
        'everything is an Object in JavaScript...'
      );
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - instanceOf もしくは notInstanceOfです。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
    (data) => {
      assert.equal(
        data.assertions[3].method,
        'notInstanceOf',
        'myCar.wheels is not an instance of String'
      );
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/