"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const DateTime_1 = require("./DateTime");
const ExifTime_1 = require("./ExifTime");
const _chai_spec_1 = require("./_chai.spec");
describe("ExifTime", () => {
    describe(".fromEXIF()", () => {
        for (const z of [
            { inputSuffix: "", outputSuffix: "", zone: undefined },
            { inputSuffix: "Z", outputSuffix: "+00:00", zone: "UTC" },
            { inputSuffix: "+2", outputSuffix: "+02:00", zone: "UTC+2" },
            { inputSuffix: "-04:00", outputSuffix: "-04:00", zone: "UTC-4" },
        ]) {
            describe(`with timezone ${JSON.stringify(z)}`, () => {
                it("parses hour/minute/second", () => {
                    const et = ExifTime_1.ExifTime.fromEXIF("12:03:45" + z.inputSuffix);
                    (0, _chai_spec_1.expect)(et).to.containSubset({
                        hour: 12,
                        minute: 3,
                        second: 45,
                        millisecond: undefined,
                        zone: z.zone,
                    });
                    (0, _chai_spec_1.expect)(et.toString()).to.eql("12:03:45" + z.outputSuffix);
                });
                it("parses hour/minute/second/millis", () => {
                    const et = ExifTime_1.ExifTime.fromEXIF("18:08:05.813" + z.inputSuffix);
                    (0, _chai_spec_1.expect)(et).to.containSubset({
                        hour: 18,
                        minute: 8,
                        second: 5,
                        millisecond: 813,
                        zone: z.zone,
                    });
                    (0, _chai_spec_1.expect)(et.toString()).to.eql("18:08:05.813" + z.outputSuffix);
                });
                it("parses hour/minute/second/micros", () => {
                    const et = ExifTime_1.ExifTime.fromEXIF("08:20:55.207340" + z.inputSuffix);
                    (0, _chai_spec_1.expect)(et).to.containSubset({
                        hour: 8,
                        minute: 20,
                        second: 55,
                        millisecond: 207,
                        zone: z.zone,
                    });
                    (0, _chai_spec_1.expect)(et.millis).to.be.eql(207);
                    (0, _chai_spec_1.expect)(et.toString()).to.eql("08:20:55.207" + z.outputSuffix);
                });
            });
        }
        describe("from GPS", () => {
            it("hour/minute/second/millis", () => {
                const et = ExifTime_1.ExifTime.fromEXIF("05:28:09.123");
                (0, _chai_spec_1.expect)([et.hour, et.minute, et.second, et.millis]).to.eql([
                    5, 28, 9, 123,
                ]);
            });
        });
    });
    it("renders EXIF for 12:34:56", () => {
        (0, _chai_spec_1.expect)((0, DateTime_1.toExifString)(new ExifTime_1.ExifTime(12, 34, 56))).to.eql("12:34:56");
    });
    it("renders EXIF for 01:02:03", () => {
        (0, _chai_spec_1.expect)((0, DateTime_1.toExifString)(new ExifTime_1.ExifTime(1, 2, 3))).to.eql("01:02:03");
    });
    it("renders EXIF for 01:02:03", () => {
        (0, _chai_spec_1.expect)((0, DateTime_1.toExifString)(new ExifTime_1.ExifTime(1, 2, 3))).to.eql("01:02:03");
    });
    describe("rejects invalid raw values", () => {
        for (const ea of [
            null,
            undefined,
            "",
            " ",
            "0",
            "00",
            "01",
            "02",
            "0001",
            "1958",
            "a",
        ]) {
            it(`rejects ${JSON.stringify(ea)}`, () => {
                (0, _chai_spec_1.expect)(ExifTime_1.ExifTime.fromEXIF(ea)).to.eql(undefined);
            });
        }
    });
});
//# sourceMappingURL=ExifTime.spec.js.map