示例#1
0
  it('should handle ADD_TODO', () => {
    const oldState = [];
    freeze(oldState);
    const state1 = todos(oldState, { type: types.ADD_TODO, text: 'FooBar' });

    assert.deepStrictEqual(state1, [{
      id: 0,
      text: 'FooBar',
      completed: false,
    }]);

    freeze(state1);
    const state2 = todos(state1, { type: types.ADD_TODO, text: 'FooBar2' });

    assert.deepStrictEqual(state2, [
      {
        id: 1,
        text: 'FooBar2',
        completed: false,
      },
      {
        id: 0,
        text: 'FooBar',
        completed: false,
      },
    ]);
  });
    it('should call dispatched logger/crashReporter middleware', () => {
      assert.throws(() => store.dispatch({ type: 'INCREMENT' }));

      assert.deepStrictEqual(spy.getCall(0).args, [{ type: 'INCREMENT' }]);
      assert.deepStrictEqual(spy.getCall(1).args, [1]);
      assert.deepStrictEqual(spy.getCall(2).args, [{ type: 'INCREMENT' }]);
      assert.deepStrictEqual(spy.getCall(3).args, [new Error('Too many count'), 1]);
    });
示例#3
0
  it('can handle SET_EDIT_MODE action', () => {
    assert.deepStrictEqual(reducers(false, {
      type: 'SET_EDIT_MODE',
      bool: true,
    }), true);

    assert.deepStrictEqual(reducers(true, {
      type: 'SET_EDIT_MODE',
      bool: true,
    }), true);
  });
示例#4
0
      it('returns an intersection', () => {
        const a1 = { top: -20, left: 0, height: 20, width: 40 };
        const a2 = { top: 0, left: 0, height: 20, width: 40 };
        assert.deepStrictEqual(utils.intersection(a1, a2), {
          top: 0, left: 0, right: 40, bottom: 0,
          height: 0, width: 40
        });

        const a3 = { top: -20, left: 40, height: 20, width: 20 };
        assert.deepStrictEqual(utils.intersection(a1, a3), {
          top: -20, left: 40, right: 40, bottom: 0,
          height: 20, width: 0
        });
      });
示例#5
0
      it('returns an intersection', () => {
        const a1 = { top: 0, left: 0, height: 100, width: 100 };
        const a2 = { top: 25, left: 25, height: 50, width: 50 };
        assert.deepStrictEqual(utils.intersection(a1, a2), {
          top: 25, left: 25, right: 75, bottom: 75,
          height: 50, width: 50
        });

        const a3 = { top: 50, left: 50, height: 50, width: 50 };
        assert.deepStrictEqual(utils.intersection(a1, a3), {
          top: 50, left: 50, right: 100, bottom: 100,
          height: 50, width: 50
        });
      });
示例#6
0
      it('returns an intersection', () => {
        const a1 = { top: -100, left: -80, height: 50, width: 20 };
        const a2 = { top: -120, left: -100, height: 40, width: 60 };
        assert.deepStrictEqual(utils.intersection(a1, a2), {
          top: -100, left: -80, right: -60, bottom: -80,
          height: 20, width: 20
        });

        const a3 = { top: -80, left: -100, height: 10, width: 60 };
        assert.deepStrictEqual(utils.intersection(a1, a3), {
          top: -80, left: -80, right: -60, bottom: -70,
          height: 10, width: 20
        });
      });
示例#7
0
 it('should return initial state', () => {
   assert.deepStrictEqual(todos(undefined, {}), [{
     text: 'Use Redux',
     id: 0,
     completed: false,
   }]);
 });
示例#8
0
  it('should handle COMPLETE_TODO', () => {
    const oldState = [
      {
        id: 1,
        text: 'FooBar2',
        completed: false,
      },
      {
        id: 0,
        text: 'FooBar',
        completed: false,
      },
    ];
    freeze(oldState);

    assert.deepStrictEqual(todos(oldState, {
      type: types.COMPLETE_TODO,
      id: 0,
    }), [
      {
        id: 1,
        text: 'FooBar2',
        completed: false,
      },
      {
        id: 0,
        text: 'FooBar',
        completed: true,
      },
    ]);
  });
示例#9
0
文件: index.js 项目: tjbenton/docs
    test(async (t) => {
      let actual = options.actual(file, t)
      let expected = fs.readJson(file.replace(path.extname(file), '.json'))

      actual = await actual
      expected = await expected

      if (options.test) {
        options.test(t, { file, actual, expected })
        if (!options.diff) {
          return
        }
      }

      try {
        assert.deepStrictEqual(actual, expected, file)
        t.pass(file)
      } catch (e) {
        const delta = json.diff(actual, expected)
        const diff = json.formatters.console.format(delta)
        const spaces = '  '
        t.fail(file)
        console.log('')
        console.log(spaces + file)
        console.log(diff.split('\n').map((line) => spaces + spaces + line).join('\n'))
        console.log('')
      }
    })
示例#10
0
 it('should return request', () => {
   const req = ws.createTeamInvitationRequest(100, 'uname');
   assert.deepStrictEqual(req, {
     method: 'PUT',
     uri: 'https://api.github.com/teams/100/memberships/uname',
   });
 });
示例#11
0
 it('returns an intersection', () => {
   const area = { top: 0, left: 0, height: 100, width: 50 };
   assert.deepStrictEqual(utils.intersection(area, area), {
     top: 0, left: 0, right: 50, bottom: 100,
     height: 100, width: 50
   });
 });
示例#12
0
        it('should create tIME chunk from the buffer which is created by tIME#toArrayBuffer', () => {
            const actual = new tIME(2000, 11, 1, 12, 34, 56);
            const chunk = Chunk.fromArrayBuffer(actual.toArrayBuffer());
            const expected = tIME.fromArrayBuffer(chunk.data);

            assert.deepStrictEqual(actual, expected);
        });
示例#13
0
 it("Should handle SIGN_IN_REQUEST", () => {
   assert.deepStrictEqual(reducer(undefined, { type: "SIGN_IN_REQUEST" }), {
     isFetching: true,
     authenticated: false,
     hasJwtToken: false,
     user: null
   });
 });
示例#14
0
 it('returns an intersection', () => {
   const a1 = { top: 0, left: 0, height: 100, width: 50 };
   const a2 = { top: 10, left: 20, height: 60, width: 80 };
   assert.deepStrictEqual(utils.intersection(a1, a2), {
     top: 10, left: 20, right: 50, bottom: 70,
     height: 60, width: 30
   });
 });
 mustCall(() => {
   const result = JSON.parse(data);
   const expected = {
     time: { start: 1, end: 3 },
     break: { start: 2, end: 5 },
     members: [{ id: 1 }, { id: 2 }]
   };
   assert.deepStrictEqual(result, expected);
 })
示例#16
0
    it('should delete key', () => {
      const obj = { a: 1, b: 2 };
      const a = delete obj.a;
      const c = delete obj.c;

      assert.deepStrictEqual(obj, { b: 2 });
      assert.strictEqual(a, true);
      assert.strictEqual(c, true);
    });
示例#17
0
  it("incrementAsync()", () => {
    const saga = incrementAsync();

    assert.deepStrictEqual(
      saga.next().value,
      call(delay, 1000)
    );

    assert.deepStrictEqual(
      saga.next().value,
      put(createAction(INCREMENT)())
    );

    assert.deepStrictEqual(
      saga.next(),
      { done: true, value: undefined }
    );
  });
示例#18
0
      it('returns a completed list', () => {
        assert.deepStrictEqual(utils.complete('top'), ['top', 'right', 'bottom', 'left']);
        assert.deepStrictEqual(utils.complete('right'), ['right', 'top', 'bottom', 'left']);
        assert.deepStrictEqual(utils.complete('bottom'), ['bottom', 'top', 'right', 'left']);
        assert.deepStrictEqual(utils.complete('left'), ['left', 'top', 'right', 'bottom']);

        assert.deepStrictEqual(utils.complete(['top']), ['top', 'right', 'bottom', 'left']);
        assert.deepStrictEqual(utils.complete(['right']), ['right', 'top', 'bottom', 'left']);
        assert.deepStrictEqual(utils.complete(['bottom']), ['bottom', 'top', 'right', 'left']);
        assert.deepStrictEqual(utils.complete(['left']), ['left', 'top', 'right', 'bottom']);
      });
  it('can parse csv', () => {
    const csv = fs.readFileSync(`${__dirname}/data/test.csv`);
    const records = parse(csv, { columns: true });

    assert.deepStrictEqual(
      [{ col1: 'a', col2: '', col3: 'c' },
        { col1: 'd', col2: 'e', col3: 'f' }],
      records,
    );
  });
    it("Should be normalized display property", () => {
      const prefixer = new Prefixer({ userAgent: "all" });

      assert.deepStrictEqual(
        autoPrefixAndNormalizeStyles(prefixer, {
          display: "flex"
        }), {
          display: "flex"
        }
      );
    });
示例#21
0
 it('should return request', () => {
   const req = ws.createAuthorizationRequest('code');
   assert.deepStrictEqual(req, {
     method: 'POST',
     uri: 'https://github.com/login/oauth/access_token',
     form: {
       client_id: ws.clientId,
       client_secret: ws.clientSecret,
       code: 'code',
     },
   });
 });
示例#22
0
 const server = http.createServer((req, res) => {
   assert.deepStrictEqual(
     req.headers,
     {
       authorization: `token ${ws.personalToken}`,
       'user-agent': 'Request-Promise',
       host: '127.0.0.1:15000',
       connection: 'close',
     },
   );
   res.end('{"mocked":"response"}');
 });
示例#23
0
  describe('signInLink', () => {
    const ws = new Github();
    const link = ws.signInLink('csrf');

    assert(link instanceof urijs);
    assert.strictEqual(link.protocol(), 'https');
    assert.strictEqual(link.host(), 'github.com');
    assert.strictEqual(link.path(), '/login/oauth/authorize');
    assert.deepStrictEqual(link.search(true), {
      client_id: ws.clientId,
      state: 'csrf',
      scope: 'user:email',
    });
  });
 it('will change state to manage history', () => {
   assert.deepStrictEqual(store.getState(), {
     counter: {
       past: [],
       present: 0,
       future: [],
       history: {
         past: [],
         present: 0,
         future: [],
       },
     },
   });
 });
 it("Should be get color 1 ~ 4", () => {
   assert.deepStrictEqual(
     getColors({
       color1: "val1",
       color2: "val2",
       color3: "val3",
       color4: "val4"
     }),
     [
       "val1",
       "val2",
       "val3",
       "val4"
     ]
   );
 });
 it("Should be get singleColor", () => {
   assert.deepStrictEqual(
     getColors({
       singleColor: "single",
       color1: "val1",
       color2: "val2",
       color3: "val3",
       color4: "val4"
     }),
     [
       "single",
       "single",
       "single",
       "single"
     ]
   );
 });
    it("Should be get prefixed styles", () => {
      const prefixer = new Prefixer({ userAgent: ios6 });

      assert.deepStrictEqual(
        autoPrefixAndNormalizeStyles(prefixer, {
          display: "flex",
          boxSizing: "border-box",
          transform: "rotate(0)",
          userSelect: "none"
        }), {
          display: "-webkit-box",
          boxSizing: "border-box",
          WebkitTransform: "rotate(0)",
          WebkitUserSelect: "none"
        }
      );
    });
    it('add past history when state has changed', () => {
      store.dispatch({ type: 'INCREMENT' });

      assert.deepStrictEqual(store.getState(), {
        counter: {
          past: [0],
          present: 1,
          future: [],
          history: {
            future: [],
            history: {
              future: [],
              past: [],
              present: 0,
            },
            past: [
              0,
            ],
            present: 1,
          },
        },
      });
    });
示例#29
0
 mustCall(() => {
   const actual = JSON.parse(data);
   const expected = { result: "hoge" };
   assert.deepStrictEqual(actual, expected);
 })
示例#30
0
 mustCall(actual => {
   const expected = { message: "message! hoge" };
   assert.deepStrictEqual(actual, expected);
 })