// 78: Promise - API overview
// To do: make all tests pass, leave the assert lines unchanged!
// Follow the hints of the failure messages!

describe('`Promise` API overview', function() {
  it('`new Promise()` requires a function as param', () => {
    //// const param = null;
    const param = () => {};
    assert.doesNotThrow(() => { new Promise(param); });
  });
  describe('resolving a promise', () => {
    // reminder: the test passes when a fulfilled promise is returned
    it('via constructor parameter `new Promise((resolve) => { resolve(); })`', () => {
      //// const param = () => { resolve(); };
      const param = (resolve) => { resolve(); };
      return new Promise(param);
    });
    it('using `Promise.resolve()`', () => {
      //// return Promise.reject('all fine');
      return Promise.resolve('all fine');
    });
  });
  describe('a rejected promise', () => {
    it('using the constructor parameter', (done) => {
      //// const promise = new Promise((reject) => { reject(); });
      const promise = new Promise((_, reject) => { reject(); });
      promise
        .then(() => done(new Error('The promise is expected to be rejected.')))
        .catch(() => done());
    });
    it('via `Promise.reject()`', (done) => {
      //// const promise = Promise.resolve();
      const promise = Promise.reject();
      promise
        .then(() => done(new Error('The promise is expected to be rejected.')))
        .catch(() => done());
    });
  });
  const resolvingPromise = Promise.resolve();
  const rejectingPromise = Promise.reject();
  describe('`Promise.all()`', () => {
    it('`Promise.all([p1, p2])` resolves when all promises resolve', () =>
      //// Promise.all([resolvingPromise, rejectingPromise, resolvingPromise])
      Promise.all([resolvingPromise, resolvingPromise])
    );
    it('`Promise.all([p1, p2])` rejects when a promise is rejected', (done) => {
      //// Promise.all([resolvingPromise])
      Promise.all([resolvingPromise, rejectingPromise ])
        .then(() => done(new Error('The promise is expected to be rejected.')))
        .catch(() => done())
    });
  });
  describe('`Promise.race()`', () => {
    it('`Promise.race([p1, p2])` resolves when one of the promises resolves', () =>
      //// Promise.race([rejectingPromise])
      Promise.race([resolvingPromise, rejectingPromise])
    );
    it('`Promise.race([p1, p2])` rejects when one of the promises rejects', (done) => {
      //// Promise.race([resolvingPromise])
      Promise.race([rejectingPromise, resolvingPromise])
        .then(() => done(new Error('The promise is expected to be rejected.')))
        .catch(() => done())
    });
    it('`Promise.race([p1, p2])` order matters (and timing)', () =>
      //// Promise.race([rejectingPromise, resolvingPromise])
      Promise.race([resolvingPromise, rejectingPromise])
    );
  });
});

@@ -1482,27 +1482,26 @@
 const resolv
-ing
+ed
 Promise = Pr
@@ -1527,27 +1527,26 @@
 const reject
-ing
+ed
 Promise = Pr
@@ -1696,35 +1696,34 @@
 mise.all(%5Bresolv
-ing
+ed
 Promise, rejecti
@@ -1717,27 +1717,26 @@
 mise, reject
-ing
+ed
 Promise, res
@@ -1730,35 +1730,34 @@
 dPromise, resolv
-ing
+ed
 Promise%5D)%0A      
@@ -1767,35 +1767,34 @@
 mise.all(%5Bresolv
-ing
+ed
 Promise, resolvi
@@ -1784,35 +1784,34 @@
 dPromise, resolv
-ing
+ed
 Promise%5D)%0A    );
@@ -1914,35 +1914,34 @@
 mise.all(%5Bresolv
-ing
+ed
 Promise%5D)%0A      
@@ -1951,35 +1951,34 @@
 mise.all(%5Bresolv
-ing
+ed
 Promise, rejecti
@@ -1972,27 +1972,26 @@
 mise, reject
-ing
+ed
 Promise %5D)%0A 
@@ -2262,27 +2262,26 @@
 race(%5Breject
-ing
+ed
 Promise%5D)%0A  
@@ -2296,35 +2296,34 @@
 ise.race(%5Bresolv
-ing
+ed
 Promise, rejecti
@@ -2313,35 +2313,34 @@
 dPromise, reject
-ing
+ed
 Promise%5D)%0A    );
@@ -2455,27 +2455,26 @@
 race(%5Bresolv
-ing
+ed
 Promise%5D)%0A  
@@ -2489,35 +2489,34 @@
 ise.race(%5Breject
-ing
+ed
 Promise, resolvi
@@ -2506,35 +2506,34 @@
 dPromise, resolv
-ing
+ed
 Promise%5D)%0A      
@@ -2738,27 +2738,26 @@
 race(%5Breject
-ing
+ed
 Promise, res
@@ -2755,27 +2755,26 @@
 mise, resolv
-ing
+ed
 Promise%5D)%0A  
@@ -2797,19 +2797,18 @@
 (%5Bresolv
-ing
+ed
 Promise,
@@ -2814,19 +2814,18 @@
 , reject
-ing
+ed
 Promise%5D

Fix the names, since the assignment makes the promises resolved/rejected.