shoe-converter
Version:
Making it possible to convert the shoe size and gender of one brand to another.
115 lines (114 loc) • 4.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
describe("src/index.ts", () => {
let result;
function convertFrom(brand, system, gender, size) {
return {
brand: brand,
system: system,
gender: gender,
size: size,
};
}
function convertTo(brand, system, gender) {
return {
brand: brand,
system: system,
gender: gender,
};
}
const brand = {
from: convertFrom("nike", "eu", "men", "43"),
to: convertTo("adidas", "eu", "men"),
};
const system = {
from: convertFrom("nike", "eu", "men", "45"),
to: convertTo("nike", "us", "men"),
};
const brandAndSystem = {
from: convertFrom("adidas", "us", "men", "9"),
to: convertTo("nike", "eu", "men"),
};
const gender = {
from: convertFrom("nike", "us", "women", "11.5"),
to: convertTo("nike", "us", "men"),
};
const genderAndSystem = {
from: convertFrom("nike", "eu", "women", "41"),
to: convertTo("nike", "us", "men"),
};
const genderAndBrand = {
from: convertFrom("adidas", "us", "men", "8"),
to: convertTo("nike", "us", "women"),
};
const genderAndBrandAndSystem = {
from: convertFrom("nike", "uk", "men", "4"),
to: convertTo("adidas", "us", "women"),
};
const jpToCm = {
from: convertFrom("nike", "jp", "men", "30"),
to: convertTo("nike", "cm", "women"),
};
// TODO: Add errors!
describe("Successfully convert size across brands", () => {
test("should return 45 1/3", () => {
result = "45 1/3";
expect((0, index_1.convert)(brand)).toStrictEqual(result);
});
});
describe("Successfully convert system", () => {
test("should return 11", () => {
result = "11";
expect((0, index_1.convert)(system)).toStrictEqual(result);
});
});
describe("Successfully convert size across brands and system", () => {
test("should return 41", () => {
result = "41";
expect((0, index_1.convert)(brandAndSystem)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders", () => {
test("should return 10", () => {
result = "10";
expect((0, index_1.convert)(gender)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders and systems", () => {
test("should return 8", () => {
result = "8";
expect((0, index_1.convert)(genderAndSystem)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders and brands", () => {
test("should return 8.5", () => {
result = "8.5";
expect((0, index_1.convert)(genderAndBrand)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders, brands and system", () => {
test("should return 6.5", () => {
result = "6.5";
expect((0, index_1.convert)(genderAndBrandAndSystem)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders and brands", () => {
test("should return 8.5", () => {
result = "8.5";
expect((0, index_1.convert)(genderAndBrand)).toStrictEqual(result);
});
});
describe("Successfully convert size across genders, brands and system", () => {
test("should return 6.5", () => {
result = "6.5";
expect((0, index_1.convert)(genderAndBrandAndSystem)).toStrictEqual(result);
});
});
describe("Successfully handle system 'jp' as 'cm'", () => {
test("should return 30", () => {
result = "30";
expect((0, index_1.convert)(jpToCm)).toStrictEqual(result);
});
});
});