You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
707 B
TypeScript

import { describe, it, expect } from "vitest";
import { missingNumber } from "./missingNumber.ts";
describe("missingNumber", () => {
it("[3, 0, 1] expect 2", () => {
const nums = [3, 0, 1];
expect(missingNumber(nums)).toBe(2);
});
it("[0, 1] expect 2", () => {
const nums = [0, 1];
expect(missingNumber(nums)).toBe(2);
});
it("[9, 6, 4, 2, 3, 5, 7 , 0, 1] expect 8", () => {
const nums = [9, 6, 4, 2, 3, 5, 7, 0, 1];
expect(missingNumber(nums)).toBe(8);
});
it("[0] expect 1", () => {
const nums = [0];
expect(missingNumber(nums)).toBe(1);
});
it("[1, 2] expect 0", () => {
const nums = [1, 2];
expect(missingNumber(nums)).toBe(0);
});
});